Skip to main content



      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 06:57 Go to next message
Eclipse UserFriend
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 07:45 Go to previous messageGo to next message
Eclipse UserFriend
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 08:16 Go to previous message
Eclipse UserFriend
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: Mon Jul 14 21:57:00 EDT 2025

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

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

Back to the top