use of org.eclipse.xtext.ui.editor.model.DocumentTokenSource 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);
}
use of org.eclipse.xtext.ui.editor.model.DocumentTokenSource 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());
}
use of org.eclipse.xtext.ui.editor.model.DocumentTokenSource in project xtext-eclipse by eclipse.
the class XtextDocumentModifyTest method createDocument.
private IXtextDocument createDocument(String model) throws Exception {
resource = getResource(new StringInputStream(model));
DocumentTokenSource tokenSource = new DocumentTokenSource();
tokenSource.setLexer(new Provider<Lexer>() {
@Override
public Lexer get() {
return new InternalXtextLexer();
}
});
final XtextDocument document = new XtextDocument(tokenSource, get(ITextEditComposer.class), new OutdatedStateManager(), new OperationCanceledManager()) {
@Override
public <T> T internalModify(IUnitOfWork<T, XtextResource> work) {
try {
return work.exec((XtextResource) resource);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
};
document.set(model);
return document;
}
use of org.eclipse.xtext.ui.editor.model.DocumentTokenSource in project xtext-eclipse by eclipse.
the class DocumentPartitionerTest method getDocument.
public XtextDocument getDocument(String s) {
TerminalsTokenTypeToPartitionMapper mapper = new TerminalsTokenTypeToPartitionMapper() {
{
setTokenDefProvider(new AntlrTokenDefProvider() {
{
setAntlrTokenFileProvider(new XtextAntlrTokenFileProvider());
}
});
}
};
PartitionTokenScanner scanner = new PartitionTokenScanner();
scanner.setMapper(mapper);
DocumentPartitioner partitioner = new DocumentPartitioner(scanner, mapper);
DocumentTokenSource tokenSource = new DocumentTokenSource();
tokenSource.setLexer(new Provider<Lexer>() {
@Override
public Lexer get() {
return new org.eclipse.xtext.parser.antlr.internal.InternalXtextLexer();
}
});
XtextDocument document = new XtextDocument(tokenSource, null, new OutdatedStateManager(), new OperationCanceledManager());
document.setDocumentPartitioner(partitioner);
partitioner.connect(document);
document.set(s);
return document;
}
use of org.eclipse.xtext.ui.editor.model.DocumentTokenSource in project xtext-eclipse by eclipse.
the class DocumentTokenSourceTest method setUp.
@Before
public void setUp() throws Exception {
tokenSource = new DocumentTokenSource();
tokenSource.setLexer(new Provider<Lexer>() {
@Override
public Lexer get() {
return new org.eclipse.xtext.parser.antlr.internal.InternalXtextLexer();
}
});
document = new Document("");
document.addDocumentListener(new IDocumentListener() {
@Override
public void documentChanged(DocumentEvent event) {
tokenSource.updateStructure(event);
}
@Override
public void documentAboutToBeChanged(DocumentEvent event) {
}
});
}
Aggregations