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.
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)
Created attachment 139374 [details] stacktrace
The 2 Groovy classes were in the same default package ("javaapplication1") :)
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).
NPE fixed in: http://hg.netbeans.org/web-main/rev/0654387c9f73
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.
Issue 151325 already exists for sanitization improvements.
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
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 :)
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)