eclipse-xtext / eclipse-xtext/xtext

EGit Merge tool doesn't work with XtextEditor

Open
#2,384 24 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Steps to reproduce:

  • create an Xtext project (with at least one Xtext document) and add it to a Git repository
  • on master branch: change the Xtext document and commit it
  • switch to another branch (cloned from master) and change the same Xtext document (with another modification which should provoke a merge conflict with master branch's file), commit it
  • merge branch master into the current branch so that a merge conflict occurs
  • use Team -> Merge Tool on that Xtext document
    The following exception is thrown:
Caused by: org.eclipse.ui.PartInitException: Editor could not be initialized.
	at org.eclipse.ui.texteditor.AbstractTextEditor.internalInit(AbstractTextEditor.java:3188)
	at org.eclipse.ui.texteditor.AbstractTextEditor.init(AbstractTextEditor.java:3197)
	at org.eclipse.xtext.ui.editor.XtextEditor.init(XtextEditor.java:305)
	at org.eclipse.xtext.ui.compare.DefaultMergeViewer.createSourceViewerConfiguration(DefaultMergeViewer.java:190)
	... 62 more
Caused by: java.lang.IllegalArgumentException: document may not be null
	at org.eclipse.xtext.ui.editor.DocumentBasedDirtyResource.connect(DocumentBasedDirtyResource.java:36)
	at org.eclipse.xtext.ui.editor.DirtyStateEditorSupport.initDirtyResource(DirtyStateEditorSupport.java:448)
	at org.eclipse.xtext.ui.editor.DirtyStateEditorSupport.initializeDirtyStateSupport(DirtyStateEditorSupport.java:390)
	at org.eclipse.xtext.ui.editor.XtextEditor.initializeDirtyStateSupport(XtextEditor.java:278)
	at org.eclipse.xtext.ui.editor.XtextEditor.doSetInput(XtextEditor.java:260)
	at org.eclipse.xtext.ui.compare.DefaultMergeEditor.doSetInput(DefaultMergeEditor.java:43)
	at org.eclipse.ui.texteditor.AbstractTextEditor$5.run(AbstractTextEditor.java:3154)
	at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:437)
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:353)
	at org.eclipse.ui.internal.WorkbenchWindow$14.run(WorkbenchWindow.java:2195)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:2191)
	at org.eclipse.ui.texteditor.AbstractTextEditor.internalInit(AbstractTextEditor.java:3172)
	... 65 more

It seems that the Merge Tool uses a StreamContentDocumentProvider instead of an XtextDocumentProvider so that only a plain JFace document object is created.

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 conflict workflow with an Xtext project, then start by reading XtextEditor, DefaultMergeViewer, DocumentBasedDirtyResource, and the mentioned StreamContentDocumentProvider/XtextDocumentProvider behavior. Confirm that Team → Merge Tool fails during XtextEditor initialization; done means the merge viewer opens the conflicted Xtext document without the null-document exception.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.