org.eclipse.xtext.ui.editor.model.DocumentTokenSource Java Examples
The following examples show how to use
org.eclipse.xtext.ui.editor.model.DocumentTokenSource.
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: StyleRanges.java From statecharts with Eclipse Public License 1.0 | 6 votes |
public List<StyleRange> getRanges(String expression) { final List<StyleRange> ranges = Lists.newArrayList(); DocumentEvent event = new DocumentEvent(); event.fDocument = new DummyDocument(expression); DocumentTokenSource tokenSource = tokenSourceProvider.get(); tokenSource.updateStructure(event); Iterator<ILexerTokenRegion> iterator = tokenSource.getTokenInfos().iterator(); while (iterator.hasNext()) { ILexerTokenRegion next = iterator.next(); TextAttribute attribute = attributeProvider.getAttribute(tokenTypeMapper.getId(next.getLexerTokenType())); StyleRange range = new StyleRange(next.getOffset(), next.getLength(), attribute.getForeground(), attribute.getBackground()); range.font = attribute.getFont(); range.fontStyle = attribute.getStyle(); ranges.add(range); } return merge(ranges); }
Example #2
Source File: XtextDocumentModifyTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
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 #3
Source File: DocumentPartitionerTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
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 #4
Source File: AbstractXtextDocumentTest.java From xtext-eclipse with Eclipse Public License 2.0 | 6 votes |
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 #5
Source File: OutlineTreeProviderTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
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 #6
Source File: BacktrackingLexerPresentationDamagerTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override protected Document createDocument(String before) throws Exception { DocumentTokenSource source = new BacktrackingLexerDocumentTokenSource(); source.setLexer(new Provider<Lexer>() { @Override public Lexer get() { return createLexer(); } }); XtextDocument document = new XtextDocument(source, null, outdatedStateManager, operationCanceledManager); document.set(before); return document; }
Example #7
Source File: DamagerRepairerPerformanceTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
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 #8
Source File: AbstractDamagerRepairerTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected Document createDocument(String before) throws Exception { DocumentTokenSource source = new DocumentTokenSource(); source.setLexer(new Provider<Lexer>() { @Override public Lexer get() { return createLexer(); } }); XtextDocument document = new XtextDocument(source, null, outdatedStateManager, operationCanceledManager); document.set(before); return document; }
Example #9
Source File: AbstractDamagerRepairerTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected Document createDocument(String before) throws Exception { DocumentTokenSource source = new DocumentTokenSource(); source.setLexer(new Provider<Lexer>() { @Override public Lexer get() { return createLexer(); } }); XtextDocument document = new XtextDocument(source, null, outdatedStateManager, operationCanceledManager); document.set(before); return document; }
Example #10
Source File: TransactionalXtextDocument.java From statecharts with Eclipse Public License 1.0 | 4 votes |
@Inject public TransactionalXtextDocument(DocumentTokenSource tokenSource, ITextEditComposer composer) { super(tokenSource, composer); }
Example #11
Source File: N4JSUiModule.java From n4js with Eclipse Public License 1.0 | 4 votes |
/** * Configure the parser based token source for the coloring. */ public Class<? extends DocumentTokenSource> bindDocumentTokenSource() { return ParserBasedDocumentTokenSource.class; }
Example #12
Source File: ParallelReadXtextDocument.java From statecharts with Eclipse Public License 1.0 | 4 votes |
@Inject public ParallelReadXtextDocument(DocumentTokenSource tokenSource, ITextEditComposer composer) { super(tokenSource, composer); }
Example #13
Source File: XtextGMFDocument.java From dsl-devkit with Eclipse Public License 1.0 | 4 votes |
@Inject public XtextGMFDocument(final DocumentTokenSource tokenSource, final ITextEditComposer composer) { super(tokenSource, composer); }
Example #14
Source File: ResponsiveXtextDocument.java From dsl-devkit with Eclipse Public License 1.0 | 4 votes |
@Inject public ResponsiveXtextDocument(final DocumentTokenSource tokenSource, final ITextEditComposer composer) { super(tokenSource, composer); }
Example #15
Source File: XtendUiModule.java From xtext-xtend with Eclipse Public License 2.0 | 4 votes |
public Class<? extends DocumentTokenSource> bindDocumentTokenSource() { return XtendDocumentTokenSource.class; }
Example #16
Source File: DocumentLockerTest.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
private DocumentTokenSource createTokenSource() { DocumentTokenSource tokenSource = new DocumentTokenSource(); tokenSource.setLexer(() -> new InternalXtextLexer()); return tokenSource; }
Example #17
Source File: ValidationJobSchedulerTest.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
@Override public void setUp() throws Exception { super.setUp(); referenceDescriptions = Lists.newArrayList(); dirtyStateManager = new DirtyStateManager(); testMe = new ValidationJobScheduler(); testMe.setDirtyStateManager(dirtyStateManager); testMe.setDescriptionUtils(new DescriptionUtils()); testMe.setResourceDescriptions(this); testMe.setResourceDescriptionManager(new DefaultResourceDescriptionManager()); DocumentTokenSource nullSource = new DocumentTokenSource() { @Override protected IRegion computeDamageRegion(DocumentEvent e) { return new Region(0, 0); } }; document = new XtextDocument(nullSource, null, outdatedStateManager, operationCanceledManager) { @Override public URI getResourceURI() { return documentURI; } @Override public void checkAndUpdateAnnotations() { validationScheduled = true; } }; documentResource = new TestableDocumentResource(); targetResource = new AbstractResourceDescription() { @Override public URI getURI() { return targetURI; } @Override public Iterable<IReferenceDescription> getReferenceDescriptions() { throw new UnsupportedOperationException(); } @Override public Iterable<QualifiedName> getImportedNames() { throw new UnsupportedOperationException(); } @Override protected List<IEObjectDescription> computeExportedObjects() { if (documentResource.importedName == null) throw new UnsupportedOperationException(); return Collections.emptyList(); } }; }
Example #18
Source File: N4JSDocument.java From n4js with Eclipse Public License 1.0 | 4 votes |
/** * Creates a new instance, delegates to {@link XtextDocument#XtextDocument(DocumentTokenSource, ITextEditComposer)}. */ @Inject public N4JSDocument(DocumentTokenSource tokenSource, ITextEditComposer composer) { super(tokenSource, composer); }