You can use an ASTVisitor
to check the relevant nodes in your AST. You can then use resolveBinding()
or resolveTypeBinding()
to extract the dependencies. (For this to work you need to turn on "resolveBindings" when you parse.)
I haven't tested this, but this example should give you an idea:
public static IType[] findDependencies(ASTNode node) {
final Set<IType> result = new HashSet<IType>();
node.accept(new ASTVisitor() {
@Override
public boolean visit(SimpleName node) {
ITypeBinding typeBinding = node.resolveTypeBinding();
if (typeBinding == null)
return false;
IJavaElement element = typeBinding.getJavaElement();
if (element != null && element instanceof IType) {
result.add((IType)element);
}
return false;
}
});
return result.toArray(new IType[result.size()]);
}