Bug 316330 - NPE hovering in JS editor - "Unexpected runtime error while computing a text hover"
Summary: NPE hovering in JS editor - "Unexpected runtime error while computing a text ...
Status: RESOLVED FIXED
Alias: None
Product: JSDT
Classification: WebTools
Component: General (show other bugs)
Version: 3.2   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: 3.2.1   Edit
Assignee: Chris Jaun CLA
QA Contact: Nitin Dahyabhai CLA
URL:
Whiteboard:
Keywords: needinfo
: 304894 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-06-09 11:34 EDT by Michael Rennie CLA
Modified: 2010-06-29 17:39 EDT (History)
3 users (show)

See Also:
thatnitind: review+


Attachments
The script that produces the NPEs (12.66 KB, text/plain)
2010-06-09 11:34 EDT, Michael Rennie CLA
no flags Details
patch - added null checks (3.16 KB, patch)
2010-06-10 17:26 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 Michael Rennie CLA 2010-06-09 11:34:17 EDT
Created attachment 171542 [details]
The script that produces the NPEs

version: 1.2.0.v201006041342-7C78FGDF9JgLWLMLM4Vsye

while hovering around in the JS editor I was hit with this gem:

java.lang.NullPointerException
at org.eclipse.wst.jsdt.internal.compiler.lookup.ArrayBinding.getExactMethod(ArrayBinding.java:233)
at org.eclipse.wst.jsdt.internal.compiler.lookup.Scope.findExactMethod(Scope.java:401)
at org.eclipse.wst.jsdt.internal.compiler.lookup.Scope.getMethod(Scope.java:1813)
at org.eclipse.wst.jsdt.internal.compiler.ast.MessageSend.resolveType(MessageSend.java:307)
at org.eclipse.wst.jsdt.internal.compiler.ast.LocalDeclaration.resolve0(LocalDeclaration.java:234)
at org.eclipse.wst.jsdt.internal.compiler.ast.LocalDeclaration.resolve(LocalDeclaration.java:129)
at org.eclipse.wst.jsdt.internal.compiler.ast.Block.resolve(Block.java:89)
at org.eclipse.wst.jsdt.internal.compiler.ast.AbstractMethodDeclaration.resolveStatements(AbstractMethodDeclaration.java:337)
at org.eclipse.wst.jsdt.internal.compiler.ast.MethodDeclaration.resolveStatements(MethodDeclaration.java:139)
at org.eclipse.wst.jsdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:291)
at org.eclipse.wst.jsdt.internal.compiler.ast.AbstractMethodDeclaration.resolve(AbstractMethodDeclaration.java:362)
at org.eclipse.wst.jsdt.internal.compiler.ast.CompilationUnitDeclaration.resolve(CompilationUnitDeclaration.java:394)
at org.eclipse.wst.jsdt.internal.codeassist.SelectionEngine.select(SelectionEngine.java:733)
at org.eclipse.wst.jsdt.internal.core.Openable.codeSelect(Openable.java:167)
at org.eclipse.wst.jsdt.internal.core.CompilationUnit.codeSelect(CompilationUnit.java:318)
at org.eclipse.wst.jsdt.internal.core.CompilationUnit.codeSelect(CompilationUnit.java:312)
at org.eclipse.wst.jsdt.internal.ui.text.java.hover.AbstractJavaEditorTextHover.getHoverInfo(AbstractJavaEditorTextHover.java:108)
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)

I have no exact steps other than "try hovering in the attached script". I had opened the root script node from www.google.ca in an editor, and hovering would produce the given NPE constantly. I will attach the script.
Comment 1 Chris Jaun CLA 2010-06-09 13:52:47 EDT
That is a very unusual spot for a NPE.

My guess is this has something to do with your project set up. Please explain your set up.
Comment 2 Michael Rennie CLA 2010-06-10 14:25:18 EDT
(In reply to comment #1)

> My guess is this has something to do with your project set up. Please explain
> your set up.

My setup is very simple. Put the attached script is a normal (non-JavaScript) project and open it with the JSDT editor.
Comment 3 Chris Jaun CLA 2010-06-10 17:26:00 EDT
Created attachment 171674 [details]
patch - added null checks
Comment 4 Chris Jaun CLA 2010-06-10 17:26:50 EDT
This happens when not in a JS project because it cannot resolve the Array type leading to the NPE.

If we can't resolve the Array type we need to make sure ArrayBinding does not throw NPE's.
Comment 5 Nitin Dahyabhai CLA 2010-06-28 21:23:28 EDT
Approving, but should ArrayBinding#getInferredType() ever return null?
Comment 6 Chris Jaun CLA 2010-06-29 09:36:24 EDT
Patch checked in.

Not sure getInferredType should ever return null.

Probably not, but at least it won't throw a NPE for now.
Comment 7 Chris Jaun CLA 2010-06-29 17:39:50 EDT
*** Bug 304894 has been marked as a duplicate of this bug. ***