1

I have written xtend code that generates java classes, but in the generated java classes, there is an error in the package. Error: "The declared package "systemunit.abstractsystemunit" does not match the expected package "systemunit.abstractsystemunit""

private static def dispatch void generateFiles(SystemUnit systemUnit, IFileSystemAccess fsa) {
    println("generateFiles(SystemUnit systemUnit): " + systemUnit)


    val String packageName=StatesMLCodeGeneratorStrings.getSystemUnitPackageName(systemUnit)
    val String className=StatesMLCodeGeneratorStrings.getSystemUnitClassName(systemUnit)

    fsa.generateFile('''«packageName»/«className».java''', '''
        // Generating code for «systemUnit.name»
        package «packageName»;

        public class «className»{

        }
    ''')
}

Does someone knows that is the problem and how to resolve in XTend ?

Thanks in advnace !

Davd
  • 113
  • 1
  • 2
  • 8
  • 1
    What is the folder structure of the generated code? My guess is the generated classes aren't in the right directories. The generated classes should be in `/systemunit/abstractsystemunit/SomeClass.java` – Christopher Schneider Dec 28 '16 at 14:17
  • the thing is that the declared package in the generated java class has absolutely the same path to the expected package in the tree view. I still don't know where is the problem ? :( In the tree view of Model Explorer in Eclipse everything is fine, but there is an error when I open the generated class, in the first row where – Davd Dec 28 '16 at 14:30
  • Could just be an Eclipse issue, then. Make sure the project is configured correctly, and the generated source folder is correctly marked as a source directory. – Christopher Schneider Dec 28 '16 at 14:36
  • @ChristopherSchneider thanks, I should generate it slash /, instead of dot . when naming the packages :D – Davd Dec 30 '16 at 17:43

0 Answers0