org.eclipse.xtext.resource.OutdatedStateManager Java Examples

The following examples show how to use org.eclipse.xtext.resource.OutdatedStateManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XtextDocumentModifyTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
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;
}
 
Example #2
Source File: DocumentPartitionerTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
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;
}
 
Example #3
Source File: OutlineTreeProviderTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
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;	
}
 
Example #4
Source File: DamagerRepairerPerformanceTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
protected Document createDocument(String before) {
	DocumentTokenSource source = new DocumentTokenSource();
	source.setLexer(new Provider<Lexer>() {
		@Override
		public Lexer get() {
			return new org.eclipse.xtext.parser.antlr.internal.InternalXtextLexer();
		}
	});
	XtextDocument document = new XtextDocument(source, null, new OutdatedStateManager(), new OperationCanceledManager());
	document.set(before);
	return document;
}
 
Example #5
Source File: TypeResourceServices.java    From xtext-extras with Eclipse Public License 2.0 4 votes vote down vote up
public OutdatedStateManager getOutdatedStateManager() {
	return outdatedStateManager;
}
 
Example #6
Source File: XtextDocument.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * @since 2.8
 * @noreference This constructor is not intended to be referenced by clients. Only for testing
 */
public XtextDocument(DocumentTokenSource tokenSource, ITextEditComposer composer, OutdatedStateManager outdatedStateManager, OperationCanceledManager operationCanceledManager) {
	this(tokenSource, composer);
	this.outdatedStateManager = outdatedStateManager;
	this.operationCanceledManager = operationCanceledManager;
}