eclipse-xtext / eclipse-xtext/xtext

Xtext editor throws java.lang.IllegalStateException on touching files outside of eclipse workspace

Open
#2,491 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
831
Forks
330
Avg merge
3d 7h
Merged PRs (30d)
12

Description

Steps to reproduce

  1. Import org.eclipse.xtext.example.arithmetics example project.
  2. Launch the project and create sample.calc dsl file with below content
    image
  3. Write a batch script which recursively touch sample.calc file outside of eclipse workspace.
    image
      :loop
       copy /b sample.calc +,,
      goto loop
    
  4. Open sample.calc in Xtext editor
  5. IllegalState exception is thrown below is the stacktrace for same

Analysis :

  • When ever the resource is changed within editor. XtextEditor triggers a firePropertyChange(int).
  • Editor sees the resource which has changed is dirty and calls the DirtyStateManager.discardDirtyState(IDirtyResource).
  • Internally calls PersistentDataAwareDirtyResource(DocumentBasedDirtyResource).getURI().
  • For the dirty resource org.eclipse.xtext.ui.editor.DocumentBasedDirtyResource.initiallyProcessResource(XtextResource) does not get the description and finally throws exception as the description is null.

stacktrace :

      java.lang.IllegalStateException: Cannot use getURI if this dirty resource is currently not initialized
	at org.eclipse.xtext.ui.editor.DocumentBasedDirtyResource.getURI(DocumentBasedDirtyResource.java:129)
	at org.eclipse.xtext.ui.editor.DirtyStateEditorSupport$ClientAwareDirtyResource.getURI(DirtyStateEditorSupport.java:299)
	at org.eclipse.xtext.ui.editor.DirtyStateManager.discardDirtyState(DirtyStateManager.java:63)
	at org.eclipse.xtext.ui.editor.DirtyStateEditorSupport.markEditorClean(DirtyStateEditorSupport.java:477)
	at org.eclipse.xtext.ui.editor.XtextEditor$1.propertyChanged(XtextEditor.java:208)
	at org.eclipse.ui.part.WorkbenchPart.firePropertyChange(WorkbenchPart.java:124)
	at org.eclipse.ui.texteditor.AbstractTextEditor.firePropertyChange(AbstractTextEditor.java:6339)
	at org.eclipse.ui.texteditor.AbstractTextEditor$ElementStateListener.lambda$1(AbstractTextEditor.java:445)
	at org.eclipse.ui.texteditor.AbstractTextEditor$ElementStateListener.execute(AbstractTextEditor.java:587)
	at org.eclipse.ui.texteditor.AbstractTextEditor$ElementStateListener.elementDirtyStateChanged(AbstractTextEditor.java:447)
	at org.eclipse.ui.texteditor.AbstractDocumentProvider.fireElementDirtyStateChanged(AbstractDocumentProvider.java:664)
	at org.eclipse.ui.editors.text.FileDocumentProvider.handleElementContentChanged(FileDocumentProvider.java:820)
	at org.eclipse.ui.editors.text.FileDocumentProvider$FileSynchronizer$2.execute(FileDocumentProvider.java:260)
	at org.eclipse.ui.editors.text.FileDocumentProvider$SafeChange.run(FileDocumentProvider.java:150)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:40)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:185)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3987)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3615)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$5.run(PartRenderingEngine.java:1157)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1046)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:155)
	at org.eclipse.ui.internal.Workbench.lambda$3(Workbench.java:644)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:338)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:551)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:153)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:150)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:203)
	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:401)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:255)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:657)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:594)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1465)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1438)        
    ``` 
       

 

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the org.eclipse.xtext.example.arithmetics project, an externally touched sample.calc file, and the provided batch script. Start with DocumentBasedDirtyResource.initiallyProcessResource and getURI, then trace DirtyStateManager.discardDirtyState through DirtyStateEditorSupport and XtextEditor. Done means repeatedly touching the file outside the workspace no longer throws IllegalStateException.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
desktop-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.