Java Code Examples for org.eclipse.xtext.ui.editor.model.XtextDocument#setDocumentPartitioner()

The following examples show how to use org.eclipse.xtext.ui.editor.model.XtextDocument#setDocumentPartitioner() . 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: 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 2
Source File: AbstractXtextDocumentTest.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, outdatedStateManager, operationCanceledManager);
	document.setDocumentPartitioner(partitioner);
	partitioner.connect(document);
	document.set(s);
	return document;
}
 
Example 3
Source File: ContentAssistProcessorTestBuilder.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public IXtextDocument getDocument(final XtextResource xtextResource, final String model) {
	XtextDocument document = get(XtextDocument.class);
	document.set(model);
	document.setInput(xtextResource);
	DocumentPartitioner partitioner = get(DocumentPartitioner.class);
	partitioner.connect(document);
	document.setDocumentPartitioner(partitioner);
	return document;
}
 
Example 4
Source File: ContentAssistProcessorTestBuilder.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
public IXtextDocument getDocument(final XtextResource xtextResource, final String model) {
	XtextDocument document = get(XtextDocument.class);
	document.set(model);
	document.setInput(xtextResource);
	DocumentPartitioner partitioner = get(DocumentPartitioner.class);
	partitioner.connect(document);
	document.setDocumentPartitioner(partitioner);
	return document;
}
 
Example 5
Source File: DotEditorUtils.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
private static IXtextDocument getDocument(final Injector injector,
		final XtextResource xtextResource, final String model) {
	XtextDocument document = injector.getInstance(XtextDocument.class);
	document.set(model);
	document.setInput(xtextResource);
	DocumentPartitioner partitioner = injector
			.getInstance(DocumentPartitioner.class);
	partitioner.connect(document);
	document.setDocumentPartitioner(partitioner);
	return document;
}