Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Cannot resolve interfaces from superclass in non eclipse project(When trying to resolve superinterfaces, I get always null )
Cannot resolve interfaces from superclass in non eclipse project [message #1109926] Mon, 16 September 2013 06:01
Tomas Mika is currently offline Tomas MikaFriend
Messages: 1
Registered: July 2009
Junior Member
Hi,
I'm trying to find out if the class or some of its parent in src folder implements some interface (which is not the part of the project) by its name, but I cannot resolve the superinterfaces, since they are always null.

Don't you know why this happens?

I was trying to use setEnvironment(..) or setProject(..) with the same result.
- paths are correct
- project exists and is open..

superclass (/Users/me/someProject/src/Clazz1.java):
public class Clazz1 implements Interface1 {}


child class (/Users/me/someProject/src/Clazz2.java):
public class Clazz2 extends Clazz1 {}


parsing code:
File javaFile = new File("/Users/me/someProject/src/Clazz2.java")

ASTParser parser = ASTParser.newParser(AST.JLS4);
parser.setKind(ASTParser.K_COMPILATION_UNIT);

String[] srcPaths = {"/Users/me/someProject/src"};
parser.setEnvironment(null, srcPaths, null, false);
//or parser.setProject(existingAndOpenedJavaProject)
parser.setResolveBindings(true);
parser.setBindingsRecovery(true);

String content = FileUtils.readFileToString(javaFile);
parser.setSource(content.toCharArray());

CompilationUnit unit = (CompilationUnit)parser.createAST(new SubProgressMonitor(monitor, 1));

TypeDeclaration type = (TypeDeclaration)unit.types().get(0);
List<Type> interfaces = type.superInterfaceTypes();

// interfaces null at this point


Previous Topic:service
Next Topic:Identifier
Goto Forum:
  


Current Time: Tue Apr 16 13:42:12 GMT 2024

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

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

Back to the top