Skip to content

Commit

Permalink
Make ReconcilingUnitOfWork injectable
Browse files Browse the repository at this point in the history
https://bugs.eclipse.org/bugs/show_bug.cgi?id=452515

Change-Id: I34037c8946e7008f87cb8e03e83e8f20eacc4b70
Signed-off-by: Christian Dietrich <christian.dietrich@itemis.de>
  • Loading branch information
cdietrich authored and Sebastian Zarnekow committed Nov 25, 2014
1 parent 28023d1 commit 610f9de
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Expand Up @@ -45,6 +45,7 @@
import org.eclipse.xtext.ui.editor.model.IXtextDocumentContentObserver.Processor;
import org.eclipse.xtext.ui.editor.model.edit.ITextEditComposer;
import org.eclipse.xtext.ui.editor.model.edit.ReconcilingUnitOfWork;
import org.eclipse.xtext.ui.editor.model.edit.ReconcilingUnitOfWork.ReconcilingUnitOfWorkProvider;
import org.eclipse.xtext.util.CancelIndicator;
import org.eclipse.xtext.util.concurrent.CancelableUnitOfWork;
import org.eclipse.xtext.util.concurrent.IUnitOfWork;
Expand All @@ -68,6 +69,9 @@ public class XtextDocument extends Document implements IXtextDocument {
@Inject
private OperationCanceledManager operationCanceledManager;

@Inject
private ReconcilingUnitOfWorkProvider reconcilingUnitOfWorkProvider;

/**
* @since 2.8
* @noreference This constructor is not intended to be referenced by clients. Only for testing
Expand Down Expand Up @@ -134,7 +138,7 @@ public void process(XtextResource state) throws Exception {}
public <T> T modify(IUnitOfWork<T, XtextResource> work) {
// do a dummy read only, to make sure any scheduled changes get applied.
readOnly(noWork);
IUnitOfWork<T, XtextResource> reconcilingUnitOfWork = new ReconcilingUnitOfWork<T>(work, this, composer);
IUnitOfWork<T, XtextResource> reconcilingUnitOfWork = reconcilingUnitOfWorkProvider.<T>get(work, this, composer);
return internalModify(reconcilingUnitOfWork);
}

Expand Down
Expand Up @@ -16,6 +16,7 @@
import org.eclipse.xtext.util.CancelIndicator;
import org.eclipse.xtext.util.concurrent.IUnitOfWork;


/**
* Translates semantic changes to a document's EMF resource to text edits on
* the document. As the document's text and the model are being synced again
Expand Down Expand Up @@ -88,4 +89,18 @@ public boolean hasDocumentChanged() {
return documentChanged;
}
}

/**
* Provides a ReconcilingUnitOfWork
* @author Christian Dietrich - Initial contribution and API
*
* @since 2.8
*/
public static class ReconcilingUnitOfWorkProvider {

public <T> ReconcilingUnitOfWork<T> get(IUnitOfWork<T, XtextResource> work, IXtextDocument document, ITextEditComposer composer) {
return new ReconcilingUnitOfWork<T>(work, document, composer);
}

}
}

0 comments on commit 610f9de

Please sign in to comment.