0

I have strange error in my code:

import dsltest.models.Plant    
import dsltest.controllers.PlantController.create

package dsltest.assemblers {

assembler PlantAssembler : Plant {

    state CREATES
        create => PENDING
    end

    state PENDING

    end
}
}

Error: "dsltest.controllers.PlantController.create cannot be resolved to a type." occurs at import(second line). There is no error at first line import.

"create" is a method encapsulated by controller-"PlantController"

I tried to clean project, but it didn't help. Please someone help me to solve this.

1 Answers1

2

You should use a static import declaration to import static members:

import static dsltest.controllers.PlantController.create

Otherwise dsltest.controllers.PlantController.create is treated as a reference to JvmDeclaredType.

Anton Kosyakov
  • 365
  • 1
  • 7
  • 1
    Is the method static? Do you still get the same error? – Anton Kosyakov Feb 28 '16 at 03:30
  • 1
    The method must be static. You cannot import instance methods, since you need an instance of PlantController class first. – Anton Kosyakov Mar 03 '16 at 00:02
  • Default semantic of XImportSection is similar to java: https://docs.oracle.com/javase/specs/jls/se8/html/jls-7.html#jls-7.5. As you can see it does not implicitly create an instance of the imported type and put it on the scope of the declared type. Do you infer a class for PlantAssembler and a method for each state? If so, you can add a field with extension modifier of type PlantController to this class. – Anton Kosyakov Mar 03 '16 at 00:13