Summary: | IAE in Signature.getReturnType while hovering a method of type having $ in its name | ||||||
---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Frederic Fusier <frederic_fusier> | ||||
Component: | Core | Assignee: | Jerome Lanneluc <jerome_lanneluc> | ||||
Status: | VERIFIED FIXED | QA Contact: | |||||
Severity: | normal | ||||||
Priority: | P3 | CC: | eckart.langhuth, stephan.herrmann | ||||
Version: | 3.2 | ||||||
Target Milestone: | 3.4 M5 | ||||||
Hardware: | PC | ||||||
OS: | Windows XP | ||||||
Whiteboard: | |||||||
Attachments: |
|
Description
Frederic Fusier
2006-02-14 10:53:49 EST
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 |