Community
Participate
Working Groups
Follow-up of bug 125301 comment 5 point 1. See bug 125301 comment 3 for test case details... Stack trace is: java.lang.IllegalArgumentException at org.eclipse.jdt.core.Signature.getReturnType(Signature.java:1633) at org.eclipse.jdt.core.Signature.getReturnType(Signature.java:1649) at org.eclipse.jdt.ui.JavaElementLabels.getMethodLabel(JavaElementLabels.java:502) at org.eclipse.jdt.ui.JavaElementLabels.getElementLabel(JavaElementLabels.java:410) at org.eclipse.jdt.ui.JavaElementLabels.getElementLabel(JavaElementLabels.java:387) at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.getInfoText(JavadocHover.java:144) at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.getHoverInfo(JavadocHover.java:119) at org.eclipse.jdt.internal.ui.text.java.hover.AbstractJavaEditorTextHover.getHoverInfo(AbstractJavaEditorTextHover.java:112) at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo(BestMatchHover.java:102) at org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy.getHoverInfo(JavaEditorTextHoverProxy.java:69) at org.eclipse.jface.text.TextViewerHoverManager$4.run(TextViewerHoverManager.java:160)
BindingKey.toSignature() returns the type signature for a method belonging to such a type. Would need to escape $ in binding key.
Reproduce using 3.3RC4: 1. Create the following classes (in separate files): public class A$B { public void m() { } } public class X { void foo() { new A$B().m(); } } 2. Hover over m in 'new A$B().m()' Observe: you get the following exception in the .log: !ENTRY org.eclipse.jface.text 4 0 2007-06-21 18:23:45.406 !MESSAGE Unexpected runtime error while computing a text hover !STACK 0 java.lang.IllegalArgumentException at org.eclipse.jdt.core.Signature.getReturnType(Signature.java:1641) at org.eclipse.jdt.core.Signature.getReturnType(Signature.java:1657) at org.eclipse.jdt.ui.JavaElementLabels.getMethodLabel(JavaElementLabels.java:510) at org.eclipse.jdt.ui.JavaElementLabels.getElementLabel(JavaElementLabels.java:427) at org.eclipse.jdt.ui.JavaElementLabels.getElementLabel(JavaElementLabels.java:404) at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.getInfoText(JavadocHover.java:225) at org.eclipse.jdt.internal.ui.text.java.hover.JavadocHover.getHoverInfo(JavadocHover.java:173) at org.eclipse.jdt.internal.ui.text.java.hover.AbstractJavaEditorTextHover.getHoverInfo(AbstractJavaEditorTextHover.java:125) at org.eclipse.jdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo(BestMatchHover.java:102) at org.eclipse.jdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy.getHoverInfo(JavaEditorTextHoverProxy.java:69) at org.eclipse.jface.text.TextViewerHoverManager$4.run(TextViewerHoverManager.java:165)
I'm seeing the same with a regular method whose name contains '$'. Question: why is BindingKeyParser.nextToken() interpreting '$' as a delimiter? I just commented that line (186 in BindingKeyParser v1.32) and getMethodLabel() worked fine in my case. I couldn't quickly find documentation for the syntax of binding keys. Is '$' used as a delimiter other than for Outer$Inner classes? It seems, the case of '$' in a method name could be solved by adding a flag to nextToken() in order to interpret '$' only while parsing a type name?
Actually, in getFullQualifiedName() we don't know beforehand if A$B is the member type name, or the name of cu that contains the type (see parseSecondaryType()). Thus we cannot pass a flag to getNextToken(). However getNextToken() can be fixed to handle this case.
Created attachment 87181 [details] Proposed fix and regression tests
Fix and tests released for 3.4M5
Verified for 3.4M5 using I20080204-0010