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
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/
public class Clazz1 implements Interface1 {}

child class (/Users/me/someProject/src/
public class Clazz2 extends Clazz1 {}

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

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

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

String content = FileUtils.readFileToString(javaFile);

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: Wed Jun 20 23:23:15 GMT 2018

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

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

Back to the top