Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » superInterfaceTypes() resolve binding
superInterfaceTypes() resolve binding [message #756262] Fri, 11 November 2011 17:31 Go to next message
Benjamin Klatt is currently offline Benjamin KlattFriend
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
Re: superInterfaceTypes() resolve binding [message #756509 is a reply to message #756262] Mon, 14 November 2011 06:46 Go to previous messageGo to next message
Satyam Kandula is currently offline Satyam KandulaFriend
Messages: 444
Registered: July 2009
Senior Member
You may not be using setEnvironment properly. classpathEntries should be absolute path to the root folder of the classes and sourcepathentries should be absolute path to the root folder of the sources. For eg: if SimpleInterface2 is located on the disk as <path>/src/org/somox/extractor/test/subpackage/SimpleInterface2.java you should mention <path>/src in the sourcepathentry.
Re: superInterfaceTypes() resolve binding [message #756520 is a reply to message #756509] Mon, 14 November 2011 07:32 Go to previous message
Benjamin Klatt is currently offline Benjamin KlattFriend
Messages: 36
Registered: September 2010
Member
Hi Satyam,

thanks a lot. You pointed me to the right issue. I did not see that there was an error in the source directory path generation. And the parser did not claim the not existing directory.

cheers
Benjamin
Previous Topic:Package Explorer Object Adornments
Next Topic:"Comparison method violates its general contract!" Error
Goto Forum:
  


Current Time: Sat Apr 20 03:32:21 GMT 2024

Powered by FUDForum. Page generated in 0.03891 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top