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 139300 - Exception when selecting method from code completion
Summary: Exception when selecting method from code completion
Status: RESOLVED FIXED
Alias: None
Product: javascript
Classification: Unclassified
Component: Editor (show other bugs)
Version: 6.x
Hardware: All All
: P1 blocker (vote)
Assignee: martin_adamek
URL:
Keywords:
: 142104 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-07-08 18:46 UTC by zdro
Modified: 2009-02-27 14:26 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description zdro 2008-07-08 18:46:03 UTC
Product Version: NetBeans IDE Dev (Build 200807040101)
Java: 1.6.0_02; Java HotSpot(TM) Client VM 1.6.0_02-b05
System: Windows XP version 5.1 running on x86; Cp1252; en_US (nb)

While editing Javascript, I bring up the completion window to find a method I want to use.  I press ENTER to select the
method for use.  I then get the following error.  The method template is still inserted, but I am not able to navigate
the template as usual; I am left in regular edit mode.

This has so far only happened when trying to use a method/function of an object.  A regular property does not cause the
error.


java.util.NoSuchElementException
	at java.util.LinkedList.getFirst(LinkedList.java:109)
	at org.netbeans.modules.javascript.editing.JsPretty.handleToken(JsPretty.java:471)
	at org.netbeans.modules.javascript.editing.JsPretty.acceptNode(JsPretty.java:397)
	at org.netbeans.modules.javascript.editing.JsPretty.walk(JsPretty.java:105)
	at org.netbeans.modules.javascript.editing.JsPretty.visitDefault(JsPretty.java:184)
	at org.netbeans.modules.javascript.editing.JsPretty.walk(JsPretty.java:152)
	at org.netbeans.modules.javascript.editing.JsPretty.visitContinuation(JsPretty.java:196)
	at org.netbeans.modules.javascript.editing.JsPretty.walk(JsPretty.java:130)
	at org.netbeans.modules.javascript.editing.JsPretty.visitDefault(JsPretty.java:184)
	at org.netbeans.modules.javascript.editing.JsPretty.walk(JsPretty.java:152)
	at org.netbeans.modules.javascript.editing.JsPretty.format(JsPretty.java:93)
	at org.netbeans.modules.javascript.editing.JsFormatter.reformat(JsFormatter.java:136)
	at org.netbeans.modules.gsf.GsfReformatTask.reformat(GsfReformatTask.java:100)
	at org.netbeans.modules.editor.indent.TaskHandler$MimeItem.runTask(TaskHandler.java:504)
	at org.netbeans.modules.editor.indent.TaskHandler.runTasks(TaskHandler.java:271)
	at org.netbeans.modules.editor.indent.IndentImpl.reformat(IndentImpl.java:293)
	at org.netbeans.modules.editor.indent.FormatterImpl.reformat(FormatterImpl.java:163)
	at org.netbeans.lib.editor.codetemplates.CodeTemplateInsertHandler.insertTemplate(CodeTemplateInsertHandler.java:298)
	at org.netbeans.lib.editor.codetemplates.CodeTemplateInsertHandler.processTemplate(CodeTemplateInsertHandler.java:220)
	at org.netbeans.lib.editor.codetemplates.CodeTemplateManagerOperation.insert(CodeTemplateManagerOperation.java:238)
	at org.netbeans.lib.editor.codetemplates.api.CodeTemplate.insert(CodeTemplate.java:104)
	at
org.netbeans.modules.gsfret.editor.completion.GsfCompletionItem$DelegatedItem.defaultSubstituteText(GsfCompletionItem.java:307)
	at org.netbeans.modules.gsfret.editor.completion.GsfCompletionItem$DelegatedItem.substituteText(GsfCompletionItem.java:282)
	at org.netbeans.modules.gsfret.editor.completion.GsfCompletionItem.defaultAction(GsfCompletionItem.java:467)
	at org.netbeans.modules.editor.completion.CompletionImpl.dispatchKeyEvent(CompletionImpl.java:564)
	at org.netbeans.modules.editor.completion.CompletionImpl.keyPressed(CompletionImpl.java:364)
	at java.awt.AWTEventMulticaster.keyPressed(AWTEventMulticaster.java:233)
	at java.awt.AWTEventMulticaster.keyPressed(AWTEventMulticaster.java:232)
	at java.awt.Component.processKeyEvent(Component.java:5996)
	at javax.swing.JComponent.processKeyEvent(JComponent.java:2799)
	at java.awt.Component.processEvent(Component.java:5815)
	at java.awt.Container.processEvent(Container.java:2058)
	at java.awt.Component.dispatchEventImpl(Component.java:4410)
	at java.awt.Container.dispatchEventImpl(Container.java:2116)
	at java.awt.Component.dispatchEvent(Component.java:4240)
	at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1848)
	at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:697)
	at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:962)
	at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:834)
	at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:661)
	at java.awt.Component.dispatchEventImpl(Component.java:4282)
	at java.awt.Container.dispatchEventImpl(Container.java:2116)
	at java.awt.Window.dispatchEventImpl(Window.java:2429)
	at java.awt.Component.dispatchEvent(Component.java:4240)
[catch] at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
	at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:104)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Comment 1 Petr Blaha 2008-07-09 08:24:20 UTC
Assign to correct component.
Comment 2 martin_adamek 2008-07-22 15:04:46 UTC
Can you please provide code sample where this happened, together with cursor position where to invoke completion? Thanks.
Comment 3 martin_adamek 2008-07-30 22:39:42 UTC
I wasn't able to reproduce, so tried blind fix.
http://hg.netbeans.org/main/rev/ce6d5b4349aa
Comment 4 Quality Engineering 2008-07-31 04:21:51 UTC
Integrated into 'main-golden', available in build *200807310201* on http://bits.netbeans.org/dev/nightly/
Changeset: http://hg.netbeans.org/main/rev/ce6d5b4349aa
User: Martin Adamek <martin_adamek@netbeans.org>
Log: Blind fix for #139300: Exception when selecting method from code completion
Comment 5 zdro 2008-08-04 18:59:46 UTC
Apologies for the delay.  This problem is a bit obscure, so it took me some time to narrow it down to a specific code 
example.  As it turns out, it's quite simple:

for (var i = 0 ; i < 10 ; i++)  // '{' on the NEXT LINE!!!
{
    // any code
}

// Put cursor at the end of this line, and start the completion template for
// the 'eval' function
window.eva


I then get the "NoSuchElementException at java.util.LinkedList.getFirst(LinkedList.java:109)".

Things are then in a bad state, and if I put the brace on the line of the 'for', restart the template for the eval() 
function, and hit RETURN, I get the exception below.  I can not get out of this state unless I reopen the file.


java.lang.NullPointerException
	at org.netbeans.lib.editor.codetemplates.CodeTemplateInsertHandler.release(CodeTemplateInsertHandler.java:425)
	at org.netbeans.lib.editor.codetemplates.CodeTemplateInsertHandler.released
(CodeTemplateInsertHandler.java:452)
	at org.netbeans.lib.editor.codetemplates.textsync.TextRegionEditing.releaseActiveGroup
(TextRegionEditing.java:271)
	at org.netbeans.lib.editor.codetemplates.textsync.TextRegionEditing.activateTextSync
(TextRegionEditing.java:225)
	at org.netbeans.lib.editor.codetemplates.textsync.TextRegionEditing.enterAction(TextRegionEditing.java:306)
	at org.netbeans.lib.editor.codetemplates.textsync.TextRegionEditing$OverrideAction.actionPerformed
(TextRegionEditing.java:452)
	at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1636)
	at javax.swing.JComponent.processKeyBinding(JComponent.java:2849)
	at javax.swing.JComponent.processKeyBindings(JComponent.java:2884)
	at javax.swing.JComponent.processKeyEvent(JComponent.java:2812)
	at java.awt.Component.processEvent(Component.java:5815)
	at java.awt.Container.processEvent(Container.java:2058)
	at java.awt.Component.dispatchEventImpl(Component.java:4410)
	at java.awt.Container.dispatchEventImpl(Container.java:2116)
	at java.awt.Component.dispatchEvent(Component.java:4240)
	at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1848)
	at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:697)
	at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:962)
	at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:834)
	at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:661)
	at java.awt.Component.dispatchEventImpl(Component.java:4282)
	at java.awt.Container.dispatchEventImpl(Container.java:2116)
	at java.awt.Window.dispatchEventImpl(Window.java:2429)
	at java.awt.Component.dispatchEvent(Component.java:4240)
[catch] at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
	at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:104)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
Comment 6 martin_adamek 2008-08-05 13:34:17 UTC
Exactly that NoSuchElementException was fixed on Wed Jul 30. Can you please check the build number you are using?
Comment 7 martin_adamek 2008-08-05 13:45:22 UTC
Btw, with you recent steps to reproduce I was able to reproduce it in older build easily. But mentioned problem is fixed in latest builds.
Comment 8 zdro 2008-08-05 15:38:55 UTC
The build is the same as in my opening comments.  I trust that it is fixed.  I'm just glad that we were able to confirm
that it was the same problem I was seeing.
Comment 9 martin_adamek 2008-08-05 18:35:43 UTC
Ok, your steps to reproduce helped, thanks!
Comment 10 martin_adamek 2008-09-22 13:01:20 UTC
*** Issue 142104 has been marked as a duplicate of this issue. ***