Active Annotations: Import type references made in template strings defined in method [message #1793058] |
Mon, 30 July 2018 07:26  |
Eclipse User |
|
|
|
I am generating a method declaration in which I use the result of a private method that returns a String.
In that method, I want to add type references.
However, the necessary imports are not added to the generated class, presumably because the method is not part of the method's body assignment.
Here is some nonsense code that demonstrates the problem:
val myClass = findClass(className)
myClass.addMethod("myMethod", [
body = '''
«SomeType» s = new «SomeType»(); // This imports just fine
«getSomeStringWithType()»
'''
])
private static def String getSomeStringWithType() {
return '''
«SomeOtherType» s2 = new «SomeOtherType»(); // This is not imported
'''
}
How can I get SomeOtherType to be imported?
Perhaps there is a way to programmatically add imports to a MutableClassDeclaration?
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.24710 seconds