Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 16:58 Go to next message
Konstantin W is currently offline Konstantin WFriend
Messages: 1
Registered: November 2014
Junior Member
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 06:14 Go to previous messageGo to next message
Sasikanth Bharadwaj is currently offline Sasikanth BharadwajFriend
Messages: 1
Registered: November 2014
Junior Member
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 06:31 Go to previous message
Dong Qiu is currently offline Dong QiuFriend
Messages: 1
Registered: December 2014
Junior Member
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 Dec 15 00:14:19 GMT 2024

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

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

Back to the top