Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 324530 - Illegal Argument Exception on hover in user library
Summary: Illegal Argument Exception on hover in user library
Status: RESOLVED FIXED
Alias: None
Product: JSDT
Classification: WebTools
Component: General (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2.3   Edit
Assignee: Chris Jaun CLA
QA Contact: Nitin Dahyabhai CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-04 21:47 EDT by Scott Kellicker CLA
Modified: 2010-09-28 17:16 EDT (History)
1 user (show)

See Also:
thatnitind: review+


Attachments
user library (1.33 KB, text/plain)
2010-09-04 21:47 EDT, Scott Kellicker CLA
no flags Details
patch (4.24 KB, patch)
2010-09-15 16:54 EDT, Chris Jaun CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Scott Kellicker CLA 2010-09-04 21:47:06 EDT
Build Identifier: Helios and current Sep 2, 2010 JSDT source code

Not sure if the jsDocs in this $foobar function are correct, but shouldn't throw an exception.

!STACK 0
java.lang.IllegalArgumentException
	at org.eclipse.wst.jsdt.core.Signature.toCharArray(Signature.java:1168)
	at org.eclipse.wst.jsdt.core.Signature.toCharArray(Signature.java:1135)
	at org.eclipse.wst.jsdt.core.Signature.toCharArray(Signature.java:1240)
	at org.eclipse.wst.jsdt.core.Signature.toString(Signature.java:1599)
	at org.eclipse.wst.jsdt.ui.JavaScriptElementLabels.getTypeSignatureLabel(JavaScriptElementLabels.java:752)
	at org.eclipse.wst.jsdt.ui.JavaScriptElementLabels.getMethodLabel(JavaScriptElementLabels.java:486)
	at org.eclipse.wst.jsdt.ui.JavaScriptElementLabels.getElementLabel(JavaScriptElementLabels.java:428)
	at org.eclipse.wst.jsdt.ui.JavaScriptElementLabels.getElementLabel(JavaScriptElementLabels.java:405)
	at org.eclipse.wst.jsdt.internal.ui.text.java.hover.JavadocHover.getInfoText(JavadocHover.java:218)
	at org.eclipse.wst.jsdt.internal.ui.text.java.hover.JavadocHover.getHoverInfo(JavadocHover.java:166)
	at org.eclipse.wst.jsdt.internal.ui.text.java.hover.AbstractJavaEditorTextHover.getHoverInfo(AbstractJavaEditorTextHover.java:116)
	at org.eclipse.wst.jsdt.internal.ui.text.java.hover.BestMatchHover.getHoverInfo(BestMatchHover.java:99)
	at org.eclipse.wst.jsdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy.getHoverInfo(JavaEditorTextHoverProxy.java:67)
	at org.eclipse.jface.text.TextViewerHoverManager$4.run(TextViewerHoverManager.java:168)


Reproducible: Always

Steps to Reproduce:
1. Add tstlib_bug1.js as a user library to a Static Web Project
2. Create test.js
3. Using content assist verify can do $foo<ctrl-space> to add foobar
4. Now hover over foo bar and get exception.
Comment 1 Scott Kellicker CLA 2010-09-04 21:47:54 EDT
Created attachment 178219 [details]
user library
Comment 2 Scott Kellicker CLA 2010-09-04 21:55:43 EDT
Comment on attachment 178219 [details]
user library

The @param says 'a' instead of 'obj'.  Same crash even if changed to 'obj'.
Comment 3 Scott Kellicker CLA 2010-09-09 11:06:02 EDT
The problem seems to be in JavaScriptElements.getMethodLabel() when the resolvedKey seems to get incorrectly translated to resolvedSig:

public static void getMethodLabel(IFunction method, long flags, StringBuffer buf) {
  try {
    BindingKey resolvedKey= getFlag(flags, USE_RESOLVED) && method.isResolved() ? new BindingKey(method.getKey()) : null;
    String resolvedSig= (resolvedKey != null) ? resolvedKey.toSignature() : null;
    . . .
}
resolvedKey is "X/moo/WebContent/mootools-1.2.4-core-nc.js;.$random(AA)A"
resolvedSig is ";".



BTW,
I've observed this with mootools 1.2.4 core.js as well.
Add mootools1.2.4-core.js to WebContext.
Create test.js
Add $random(1,5).  Hover over random.  Same result.
Comment 4 Chris Jaun CLA 2010-09-15 16:54:28 EDT
Created attachment 178982 [details]
patch

Removed some closure/wildcare stuff from the BindingKeyParser.
Comment 5 Scott Kellicker CLA 2010-09-15 19:48:36 EDT
I tested with top of tree + patch.
Works great-- No NPE and even a hover.
Nice.
Comment 6 Nitin Dahyabhai CLA 2010-09-28 17:16:10 EDT
Checked into HEAD and maintenance.