This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 235175 - NullPointerException at org.netbeans.modules.groovy.editor.api.completion.GroovyCompletionResult.afterInsert
Summary: NullPointerException at org.netbeans.modules.groovy.editor.api.completion.Gro...
Status: VERIFIED FIXED
Alias: None
Product: groovy
Classification: Unclassified
Component: Editor (show other bugs)
Version: 7.4
Hardware: All All
: P3 normal (vote)
Assignee: Martin Janicek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-08-28 14:01 UTC by Vladimir Riha
Modified: 2013-08-29 07:07 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter: 203402


Attachments
stacktrace (3.32 KB, text/plain)
2013-08-28 14:01 UTC, Vladimir Riha
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Riha 2013-08-28 14:01:40 UTC
Build: NetBeans IDE Dev (Build 201308280001)
VM: Java HotSpot(TM) Client VM, 24.0-b55, Java(TM) SE Runtime Environment, 1.7.0_40-b39
OS: Linux

User Comments:
vriha: Reproducing issue 234833




Stacktrace: 
java.lang.NullPointerException
   at org.netbeans.modules.groovy.editor.api.completion.GroovyCompletionResult.afterInsert(GroovyCompletionResult.java:106)
   at org.netbeans.modules.csl.editor.completion.GsfCompletionItem$DelegatedItem.substituteText(GsfCompletionItem.java:357)
   at org.netbeans.modules.csl.editor.completion.GsfCompletionItem.defaultAction(GsfCompletionItem.java:504)
   at org.netbeans.modules.csl.editor.completion.GsfCompletionItem$DelegatedItem.defaultAction(GsfCompletionItem.java:121)
   at org.netbeans.modules.editor.completion.CompletionImpl.dispatchKeyEvent(CompletionImpl.java:651)
   at org.netbeans.modules.editor.completion.CompletionImpl.keyPressed(CompletionImpl.java:380)
Comment 1 Vladimir Riha 2013-08-28 14:01:41 UTC
Created attachment 139374 [details]
stacktrace
Comment 2 Vladimir Riha 2013-08-28 14:02:49 UTC
The 2 Groovy classes were in the same default package ("javaapplication1") :)
Comment 3 Martin Janicek 2013-08-28 14:43:06 UTC
I'm able to reproduce and finally can see what's going on and why the reproduction wasn't reliable. When you copy-paste the code from your original description, the editor is trying to parse the file, but since the:

class Foo {
    Foo() {
        Test t = new Test
    }
}

..isn't valid code, parser fails and the AST is broken. Because of that ModuleNode isn't set and fast import feature will fail. After one completion, the parser will successfully parse the document and any other attempt to reproduce it again on the same source file will not succeed.

So it should be reproducible in every new file (and copy-pasted source code). I'll fix the NPE, but the fast import won't be able to resolve the import in such case anyway (until the parser succeed once).
Comment 4 Martin Janicek 2013-08-28 14:56:33 UTC
NPE fixed in: http://hg.netbeans.org/web-main/rev/0654387c9f73
Comment 5 Martin Janicek 2013-08-28 15:03:47 UTC
If we want to solve also the second problem (which should be quite rare because if you type the code by your-self, the editor will have correct AST) then we need to improve sanitization to be able to automatically correct such code. Do not think we should do such changes for 7.4, but it's something to think about for the next release.
Comment 6 Martin Janicek 2013-08-28 15:06:34 UTC
Issue 151325 already exists for sanitization improvements.
Comment 7 Quality Engineering 2013-08-29 01:42:17 UTC
Integrated into 'main-silver', will be available in build *201308290001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/0654387c9f73
User: Martin Janicek <mjanicek@netbeans.org>
Log: #235175 - NullPointerException at org.netbeans.modules.groovy.editor.api.completion.GroovyCompletionResult.afterInsert
Comment 8 Vladimir Riha 2013-08-29 07:04:49 UTC
Thanks Martine. As for the sanitization of pasted code, I think this won't be happening often in "real world" as I'd be expecting users to usually paste valid code, only here in BZ it is a bit more common use case :)
Comment 9 Vladimir Riha 2013-08-29 07:07:05 UTC
Verified

Product Version: NetBeans IDE Dev (Build 201308290001)
Java: 1.7.0_40; Java HotSpot(TM) Client VM 24.0-b55
Runtime: Java(TM) SE Runtime Environment 1.7.0_40-b39
System: Linux version 3.2.0-48-generic-pae running on i386; UTF-8; en_US (nb)