Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Syntax of compound names for nested classes
Syntax of compound names for nested classes [message #1410672] Thu, 21 August 2014 10:57 Go to next message
Andreas Sewe is currently offline Andreas SeweFriend
Messages: 111
Registered: June 2013
Senior Member
Hi,

I have a problem getting anything other than ProblemReferenceBindings (ProblemReasons.InternalNameProvided) out of my LookupEnvironment when searching for nested classes.
  ["java", "util", "Map$Entry"]
produces the aforementioned ProblemReferenceBinding.
  ["java", "util", "Map", "Entry"]
produces null as does
  ["java", "util", "Map.Entry"]

What's the problem syntax for compound names for nested classes then? Any hints are appreciated.

The PackageBinding for "java.util" has, in its "knownTypes" HashtableOfType an entry for "Map$Entry", so that seems like the proper syntax, but this fails the final
  referenceBinding.isNestedType()
check and results in the ProblemReferenceBinding (which is far less useful than a regular ReferenceBinding; in particular, getMethods doesn't do anything useful).

Best wishes,

Andreas
Re: Syntax of compound names for nested classes [message #1410690 is a reply to message #1410672] Thu, 21 August 2014 11:45 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Disclaimer: all these are internal classes, not public API (I know that Andreas knows this, just to note for casual readers Smile )

It seems none of the methods in LookupEnvironment which are used when resolving a BinaryTypeBinding from .class are accessible to clients.

This implies you'd have to follow the strategy used when resolving AST (source). In that case the compiler doesn't just throw the fully qualified name at the LookupEnvironment but resolves the reference in steps. This means: chop off as much from the tail of the name as needed to get a valid answer from LE. Once you have the ReferenceBinding for the toplevel type, ask it getMemberType(char[]).

HTH,
Stephan
Re: Syntax of compound names for nested classes [message #1410699 is a reply to message #1410690] Thu, 21 August 2014 12:16 Go to previous message
Andreas Sewe is currently offline Andreas SeweFriend
Messages: 111
Registered: June 2013
Senior Member
Hi Stephan. yes this helps, if only to make me search for a simpler solution (for my special case). Wink

As I know that there will be only closest match (since the compound name is derived from the unique declaring type's signature I get from a method completion proposal), I think the following is safe:

ReferenceBinding result = env.getType(compoundName);
if (result instanceof ProblemReferenceBinding) {
    result = (ReferenceBinding) ((ProblemReferenceBinding) result).closestMatch();
}

But I will definitely back this up with test cases.

Anyway, thank you for you help. Much appreciated.
Previous Topic:Updating jee package to 1.3.2 causes javax.net.ssl.SSLKeyException: RSA premaster secret error
Next Topic:JDT Format different between Luna and Kepler
Goto Forum:
  


Current Time: Sat Dec 14 07:59:30 GMT 2024

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

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

Back to the top