Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 472720 - [templates] Editor template with import declaration throws Exception org.eclipse.jface.text.BadLocationException
Summary: [templates] Editor template with import declaration throws Exception org.ecli...
Status: CLOSED DUPLICATE of bug 494691
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.5   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-07-15 07:32 EDT by Tobias Hirning CLA
Modified: 2016-06-27 07:34 EDT (History)
4 users (show)

See Also:


Attachments
Template to reprocude the problem (280 bytes, text/xml)
2015-07-15 07:32 EDT, Tobias Hirning CLA
no flags Details
Screenshots which displays the emtpy error message. (235.98 KB, image/jpeg)
2015-07-15 07:32 EDT, Tobias Hirning CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Hirning CLA 2015-07-15 07:32:06 EDT
Created attachment 255209 [details]
Template to reprocude the problem

Observed on Kubuntu 14.04.2 LTS with GTK 3.10.8 and
Eclipse Java EE IDE for Web Developers.
Version: Mars Release (4.5.0)
Build id: 20150621-1200

Steps to reproduce:
1. Go to Window->Preferences->Java->Editor->Templates
2. Create a template (like the one attached) with an import declaration using the "${:import (package1, package2)}" notation.
3. Create a new class and delete _everything_ from it.
4. Type the template name, use autocompletion and select your template

Observed behaviour:
Eclipse shows a empty error window (see screenshot) and the error log show the follwing stack trace:
org.eclipse.jface.text.BadLocationException
	at org.eclipse.jface.text.AbstractDocument.replace(AbstractDocument.java:1179)
	at org.eclipse.core.internal.filebuffers.SynchronizableDocument.replace(SynchronizableDocument.java:194)
	at org.eclipse.jface.text.AbstractDocument.replace(AbstractDocument.java:1210)
	at org.eclipse.core.internal.filebuffers.SynchronizableDocument.replace(SynchronizableDocument.java:180)
	at org.eclipse.jdt.internal.ui.text.template.contentassist.TemplateProposal.apply(TemplateProposal.java:215)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertProposal(CompletionProposalPopup.java:963)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertSelectedProposalWithMask(CompletionProposalPopup.java:914)
	at org.eclipse.jface.text.contentassist.CompletionProposalPopup.verifyKey(CompletionProposalPopup.java:1358)
	at org.eclipse.jface.text.contentassist.ContentAssistant$InternalListener.verifyKey(ContentAssistant.java:814)
	at org.eclipse.jface.text.TextViewer$VerifyKeyListenersManager.verifyKey(TextViewer.java:493)
	at org.eclipse.swt.custom.StyledTextListener.handleEvent(StyledTextListener.java:66)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4481)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1327)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1351)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1336)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1117)
	at org.eclipse.swt.custom.StyledText.handleKeyDown(StyledText.java:5990)
	at org.eclipse.swt.custom.StyledText$7.handleEvent(StyledText.java:5682)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4481)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1327)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1351)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1336)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1363)
	at org.eclipse.swt.widgets.Widget.gtk_key_press_event(Widget.java:763)
	at org.eclipse.swt.widgets.Control.gtk_key_press_event(Control.java:3317)
	at org.eclipse.swt.widgets.Composite.gtk_key_press_event(Composite.java:785)
	at org.eclipse.swt.widgets.Widget.windowProc(Widget.java:1965)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:5590)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4717)
	at org.eclipse.swt.internal.gtk.OS._gtk_main_do_event(Native Method)
	at org.eclipse.swt.internal.gtk.OS.gtk_main_do_event(OS.java:9272)
	at org.eclipse.swt.widgets.Display.eventProc(Display.java:1225)
	at org.eclipse.swt.internal.gtk.OS._g_main_context_iteration(Native Method)
	at org.eclipse.swt.internal.gtk.OS.g_main_context_iteration(OS.java:2422)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3428)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1127)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1018)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:156)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:654)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:337)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:598)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:139)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:380)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:235)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:606)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:669)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:608)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1515)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1488)


Expected behaviour:
As far as I can see I'm using the syntax described in the help:
http://help.eclipse.org/mars/index.jsp?topic=%2Forg.eclipse.jdt.doc.user%2Fconcepts%2Fconcept-template-variables.htm
But even if I would be using wrong syntax the error message should display some useful text for the user.
Comment 1 Tobias Hirning CLA 2015-07-15 07:32:42 EDT
Created attachment 255210 [details]
Screenshots which displays the emtpy error message.
Comment 2 Stephan Herrmann CLA 2015-07-18 08:42:30 EDT
(In reply to Tobias Hirning from comment #0)
> org.eclipse.jface.text.BadLocationException
> 	at org.eclipse.jface.text.AbstractDocument.replace(AbstractDocument.java:1179)
> 	at org.eclipse.core.internal.filebuffers.SynchronizableDocument.replace(SynchronizableDocument.java:194)
> 	at org.eclipse.jface.text.AbstractDocument.replace(AbstractDocument.java:1210)
> 	at org.eclipse.core.internal.filebuffers.SynchronizableDocument.replace(SynchronizableDocument.java:180)
> 	at org.eclipse.jdt.internal.ui.text.template.contentassist.TemplateProposal.apply(TemplateProposal.java:215)

Seems to be pointing towards JDT/Text ...
Comment 3 Noopur Gupta CLA 2016-06-27 07:34:21 EDT

*** This bug has been marked as a duplicate of bug 494691 ***