I have a CompilationUnit that contains a class where a reference to another class is not imported. Eclipse resolves that kind of issue easily and proposes to import the missing class (which is located in the parent package).
How can I import a missing class programmatically without knowing its name or location ?
Reflection, injection, ClassLoader and other runtime mechanisms are not the right choice as I'm processing the classes statically through the Eclipse JDT API. Please, I'm just looking for a static oriented solution.
FYI : this how we list the imports from a CompilationUnit :
List<ImportDeclaration> existingImports = aCompilationUnit.imports();
The problem is that I don't know how to generate missing ImportDeclaration.
Thanks.
[Updated on: Wed, 22 July 2015 16:07] by Moderator