Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » ASTVisitor's ImportDeclaration from Package or JAR?(AST-scanning abstract-syntax-tree import source)
ASTVisitor's ImportDeclaration from Package or JAR? [message #1478400] Tue, 18 November 2014 11:58 Go to next message
Eclipse UserFriend
Helo everyone. I have an ASTVisitor-implementing class with (among others) this method:

@Override
public boolean visit(final ImportDeclaration node) {...}

Is there any way to find out whether the ImportDeclaration is from another package of the project which the ASTVisitor is going through or if it's from a .jar?

I tried node.resolveBinding().isSynthetic(), but it seems never to be synthetic despite me having imports from a library.


PS: I asked this question also on stackoverflow (26998754); if you want to reply there, I will copy the solution here.
Re: ASTVisitor's ImportDeclaration from Package or JAR? [message #1479077 is a reply to message #1478400] Wed, 19 November 2014 01:14 Go to previous messageGo to next message
Eclipse UserFriend
isSynthetic indicates that the binding was "made up" by the compiler. To find out whether a binding is from source or not, you should use the isFromSource() API in ITypeBinding
Re: ASTVisitor's ImportDeclaration from Package or JAR? [message #1514260 is a reply to message #1479077] Wed, 17 December 2014 01:31 Go to previous message
Eclipse UserFriend
The solution is valid for ITypeBinding. For the on-demand import declaration, the node.resolveBinding() returns the type of IPackageBinding, and IPackageBinding does not have the method isFromSource(). Do you have any solution for IPackageBinding whether it is from source or jars?
Previous Topic:A problem with Eclipse Luna Mac version
Next Topic:Compile Error
Goto Forum:
  


Current Time: Sun Aug 31 13:16:46 EDT 2025

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

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

Back to the top