Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 319872 - [projection] IllegalStateException once code template has been used inside an xml file
Summary: [projection] IllegalStateException once code template has been used inside an...
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Ant (show other bugs)
Version: 3.2   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.7 M3   Edit
Assignee: Dani Megert CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 327985 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-07-14 11:51 EDT by Olivier Thomann CLA
Modified: 2011-05-26 15:06 EDT (History)
4 users (show)

See Also:


Attachments
Ant script that shows the problem (1.68 KB, text/xml)
2010-07-14 11:51 EDT, Olivier Thomann CLA
no flags Details
Fix (8.15 KB, patch)
2010-10-19 05:57 EDT, Dani Megert CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Olivier Thomann CLA 2010-07-14 11:51:08 EDT
Created attachment 174311 [details]
Ant script that shows the problem

I got this exception trying to undo into an ant script after using a code template.

eclipse.buildId=I20100706-0800
java.version=1.6.0_20-ea
java.vendor=Sun Microsystems Inc.
BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=fr_CA
Command-line arguments:  -os win32 -ws win32 -arch x86 -console

java.lang.IllegalStateException
at org.eclipse.jface.text.projection.ProjectionMapping.toImageLine(ProjectionMapping.java:480)
at org.eclipse.jface.text.projection.ProjectionMapping.toClosestImageLine(ProjectionMapping.java:491)
at org.eclipse.jface.text.TextViewer.getClosestWidgetLineForModelLine(TextViewer.java:5462)
at org.eclipse.jface.text.TextViewer$ViewerState.updateViewport(TextViewer.java:1258)
at org.eclipse.jface.text.TextViewer$ViewerState.restore(TextViewer.java:1238)
at org.eclipse.jface.text.TextViewer.enabledRedrawing(TextViewer.java:5082)
at org.eclipse.jface.text.TextViewer.enabledRedrawing(TextViewer.java:5057)
at org.eclipse.jface.text.TextViewer.setRedraw(TextViewer.java:5142)
at org.eclipse.jface.text.TextViewer.setRedraw(TextViewer.java:5116)
at org.eclipse.jface.text.TextViewerUndoManager$DocumentUndoListener.documentUndoNotification(TextViewerUndoManager.java:174)
at org.eclipse.text.undo.DocumentUndoManager.fireDocumentUndo(DocumentUndoManager.java:929)
at org.eclipse.text.undo.DocumentUndoManager$UndoableCompoundTextChange.undo(DocumentUndoManager.java:472)
at org.eclipse.core.commands.operations.DefaultOperationHistory.doUndo(DefaultOperationHistory.java:415)
at org.eclipse.core.commands.operations.DefaultOperationHistory.undo(DefaultOperationHistory.java:1280)
at org.eclipse.ui.operations.UndoActionHandler.runCommand(UndoActionHandler.java:78)
at org.eclipse.ui.operations.OperationHistoryActionHandler$4.run(OperationHistoryActionHandler.java:311)
at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:464)
at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:372)
at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:507)
at org.eclipse.ui.internal.operations.TimeTriggeredProgressMonitorDialog.access$6(TimeTriggeredProgressMonitorDialog.java:1)
at org.eclipse.ui.internal.operations.TimeTriggeredProgressMonitorDialog$2.run(TimeTriggeredProgressMonitorDialog.java:203)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ui.internal.operations.TimeTriggeredProgressMonitorDialog.run(TimeTriggeredProgressMonitorDialog.java:216)
at org.eclipse.ui.operations.OperationHistoryActionHandler.run(OperationHistoryActionHandler.java:326)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4066)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3657)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2629)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:619)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
at org.eclipse.equinox.launcher.Main.main(Main.java:1383)

Steps to reproduce:
1) Open the attached file and try to use a code template inside the task:
		<jacoco:merge destfile="${exec.file}">
by adding: <fileset|code assist>

You should get many exceptions in the .log file.
Comment 1 Dani Megert CLA 2010-07-14 12:35:07 EDT
Broken since 3.2. Could also be a bug in the Ant editor.
Comment 2 Dani Megert CLA 2010-10-18 02:26:14 EDT
*** Bug 327985 has been marked as a duplicate of this bug. ***
Comment 3 Dani Megert CLA 2010-10-19 05:55:03 EDT
The cause for this is a couple of bugs in Ant, 1) being the main reason for the ISE.

1) AntContext.getEnd() returns an offset which is inside \r\n
2) AntContext.evaluate(Template) results a template string with different
   line delimiters than currently in the editor
3) the AntFoldingStructureProvider has a couple of bugs
4) the AntEditor creates two AntFoldingStructureProvider instead of just one
Comment 4 Dani Megert CLA 2010-10-19 05:57:09 EDT
Created attachment 181163 [details]
Fix
Comment 5 Dani Megert CLA 2010-10-19 06:06:44 EDT
Simple test case:
1. start new workspace
2. create new project
3. add attachment 174311 [details] to the project
4. open the file
5. put caret after first '<'
6. delete rest of the line
7. type "fileset" (line 20 should now be: Tab Tab Tab<fileset
8. Ctrl+Space
Comment 6 Michael Rennie CLA 2010-10-19 11:44:56 EDT
applied patch to HEAD. All unit + smoke tests pass.

Thanks for the patch Dani.