use of org.eclipse.xtext.resource.OutdatedStateManager 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.resource.OutdatedStateManager 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.resource.OutdatedStateManager in project xtext-eclipse by eclipse.
the class OutlineTreeProviderTest method createXtextDocument.
protected XtextDocument createXtextDocument(String modelAsText) throws Exception {
final XtextResource resource = getResource(modelAsText, "test.outlinetestlanguage");
DocumentTokenSource tokenSource = new DocumentTokenSource();
tokenSource.setLexer(new Provider<Lexer>() {
@Override
public Lexer get() {
return new InternalXtextLexer();
}
});
XtextDocument xtextDocument = new XtextDocument(tokenSource, null, new OutdatedStateManager(), new OperationCanceledManager());
xtextDocument.setInput(resource);
xtextDocument.set(modelAsText);
return xtextDocument;
}
Aggregations