Search in sources :

Example 1 with ITextEditComposer

use of org.eclipse.xtext.ui.editor.model.edit.ITextEditComposer in project xtext-eclipse by eclipse.

the class DocumentLockerTest method testModifySetsOutdatedFalse.

@Test
public void testModifySetsOutdatedFalse() {
    DocumentTokenSource _createTokenSource = this.createTokenSource();
    ITextEditComposer _createTextEditComposer = this.createTextEditComposer();
    final XtextDocument document = new XtextDocument(_createTokenSource, _createTextEditComposer, this.outdatedStateManager, this.operationCanceledManager);
    XtextResource _xtextResource = new XtextResource();
    final Procedure1<XtextResource> _function = (XtextResource it) -> {
        EList<Resource> _resources = new XtextResourceSet().getResources();
        _resources.add(it);
    };
    final XtextResource resource = ObjectExtensions.<XtextResource>operator_doubleArrow(_xtextResource, _function);
    document.setInput(resource);
    final IUnitOfWork<Object, XtextResource> _function_1 = (XtextResource it) -> {
        Object _xblockexpression = null;
        {
            Assert.assertFalse(document.getCancelIndicator().isCanceled());
            _xblockexpression = null;
        }
        return _xblockexpression;
    };
    document.<Object>internalModify(_function_1);
    final CancelIndicator indicator = document.getCancelIndicator();
    Assert.assertFalse(indicator.isCanceled());
    document.set("fupp");
    Assert.assertTrue(indicator.isCanceled());
    final IUnitOfWork<Object, XtextResource> _function_2 = (XtextResource it) -> {
        Object _xblockexpression = null;
        {
            Assert.assertFalse(document.getCancelIndicator().isCanceled());
            _xblockexpression = null;
        }
        return _xblockexpression;
    };
    document.<Object>internalModify(_function_2);
}
Also used : EList(org.eclipse.emf.common.util.EList) DocumentTokenSource(org.eclipse.xtext.ui.editor.model.DocumentTokenSource) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) XtextDocument(org.eclipse.xtext.ui.editor.model.XtextDocument) IXtextDocument(org.eclipse.xtext.ui.editor.model.IXtextDocument) XtextResource(org.eclipse.xtext.resource.XtextResource) CancelIndicator(org.eclipse.xtext.util.CancelIndicator) ITextEditComposer(org.eclipse.xtext.ui.editor.model.edit.ITextEditComposer) AbstractXtextDocumentTest(org.eclipse.xtext.ui.tests.editor.model.AbstractXtextDocumentTest) Test(org.junit.Test)

Example 2 with ITextEditComposer

use of org.eclipse.xtext.ui.editor.model.edit.ITextEditComposer in project xtext-eclipse by eclipse.

the class DocumentLockerTest method testNoUpdateContentProcessOnReentrant.

@Test
public void testNoUpdateContentProcessOnReentrant() {
    final ArrayList<String> s = CollectionLiterals.<String>newArrayList();
    DocumentTokenSource _createTokenSource = this.createTokenSource();
    ITextEditComposer _createTextEditComposer = this.createTextEditComposer();
    final XtextDocument document = new XtextDocument(_createTokenSource, _createTextEditComposer, this.outdatedStateManager, this.operationCanceledManager) {

        @Override
        protected boolean updateContentBeforeRead() {
            return s.add("x");
        }
    };
    XtextResource _xtextResource = new XtextResource();
    final Procedure1<XtextResource> _function = (XtextResource it) -> {
        EList<Resource> _resources = new XtextResourceSet().getResources();
        _resources.add(it);
    };
    XtextResource _doubleArrow = ObjectExtensions.<XtextResource>operator_doubleArrow(_xtextResource, _function);
    document.setInput(_doubleArrow);
    Assert.assertEquals(0, s.size());
    final IUnitOfWork<Object, XtextResource> _function_1 = (XtextResource it) -> {
        Assert.assertEquals(1, s.size());
        final IUnitOfWork<Object, XtextResource> _function_2 = (XtextResource it_1) -> {
            Assert.assertEquals(1, s.size());
            final IUnitOfWork<Object, XtextResource> _function_3 = (XtextResource it_2) -> {
                Assert.assertEquals(1, s.size());
                return null;
            };
            document.<Object>readOnly(_function_3);
            return null;
        };
        document.<Object>readOnly(_function_2);
        return null;
    };
    document.<Object>readOnly(_function_1);
    Assert.assertEquals(1, s.size());
}
Also used : IUnitOfWork(org.eclipse.xtext.util.concurrent.IUnitOfWork) EList(org.eclipse.emf.common.util.EList) DocumentTokenSource(org.eclipse.xtext.ui.editor.model.DocumentTokenSource) XtextResourceSet(org.eclipse.xtext.resource.XtextResourceSet) XtextDocument(org.eclipse.xtext.ui.editor.model.XtextDocument) IXtextDocument(org.eclipse.xtext.ui.editor.model.IXtextDocument) XtextResource(org.eclipse.xtext.resource.XtextResource) ITextEditComposer(org.eclipse.xtext.ui.editor.model.edit.ITextEditComposer) AbstractXtextDocumentTest(org.eclipse.xtext.ui.tests.editor.model.AbstractXtextDocumentTest) Test(org.junit.Test)

Aggregations

EList (org.eclipse.emf.common.util.EList)2 XtextResource (org.eclipse.xtext.resource.XtextResource)2 XtextResourceSet (org.eclipse.xtext.resource.XtextResourceSet)2 DocumentTokenSource (org.eclipse.xtext.ui.editor.model.DocumentTokenSource)2 IXtextDocument (org.eclipse.xtext.ui.editor.model.IXtextDocument)2 XtextDocument (org.eclipse.xtext.ui.editor.model.XtextDocument)2 ITextEditComposer (org.eclipse.xtext.ui.editor.model.edit.ITextEditComposer)2 AbstractXtextDocumentTest (org.eclipse.xtext.ui.tests.editor.model.AbstractXtextDocumentTest)2 Test (org.junit.Test)2 CancelIndicator (org.eclipse.xtext.util.CancelIndicator)1 IUnitOfWork (org.eclipse.xtext.util.concurrent.IUnitOfWork)1