superInterfaceTypes() resolve binding [message #756262] |
Fri, 11 November 2011 17:31 |
Benjamin Klatt Messages: 36 Registered: September 2010 |
Member |
|
|
Hi,
I am using the JDT ASTParser (JLS3) to parse java code. I set the environment using the setEnvironment() method and resolve bindings:
ASTParser parser = ASTParser.newParser(AST.JLS3);
parser.setResolveBindings(true);
parser.setStatementsRecovery(true);
parser.setBindingsRecovery(true);
Map<String, String> compilerOptions = new HashMap<String, String>();
compilerOptions.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_7);
parser.setCompilerOptions(compilerOptions);
parser.setKind(ASTParser.K_COMPILATION_UNIT);
...
parser.setEnvironment(classpathEntries, sourcepathEntries, encodings, true);
Further, I use a custom ASTVisitor to process TypeDeclarations to read class information out of the tree. So far, everything works fine except of resolving interfaces from other packages.
If I parse the class
package org.somox.extractor.test;
import org.somox.extractor.test.subpackage.SimpleInterface2;
public class SimpleClass implements SimpleInterface, SimpleInterface2 {
...
}
The SimpleInterface is located in the same package as the class. The SimpleInterface2 is located in a subpackage as identified by the import statement.
In my ASTVisitor I use the code
public boolean visit(TypeDeclaration node) {
node.resolveBinding();
...
List<Type> interfaceTypes = node.superInterfaceTypes();
for (Type interfaceType : interfaceTypes) {
ITypeBinding interfaceBinding = interfaceType.resolveBinding();
}
}
The resolve binding always returns a RecoveredTypeBinding with an internal binding of type ProblemReferenceBinding without any package information but a correct compoundName.
I do not figure out what I am missed to make the resolving happen.
I would appriciate if someone has a hint for me to make this working.
Thanks a lot
Benjamin
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03891 seconds