use of org.eclipse.xtext.util.ITextRegion in project xtext-core by eclipse.
the class TracingSugar method location.
/**
* @return ILocationData covering the <code>fullTextRegion</code> of the given EObject.
*/
public ILocationData location(EObject obj) {
ITextRegion region = locationProvider.getFullTextRegion(obj);
SourceRelativeURI uri = traceURIConverter.getURIForTrace(obj.eResource());
return new LocationData((ITextRegionWithLineInformation) region, uri);
}
use of org.eclipse.xtext.util.ITextRegion in project xtext-xtend by eclipse.
the class FlexTokenRegionProviderTest method testTokenSplit_1.
@Test
public void testTokenSplit_1() throws Exception {
String model = " axb ";
ITextRegion tokenRegion = tokenRegionProvider.getTokenRegion(model, new TextRegion(2, 1));
assertEquals(1, tokenRegion.getOffset());
assertEquals(3, tokenRegion.getLength());
}
use of org.eclipse.xtext.util.ITextRegion in project xtext-xtend by eclipse.
the class FlexTokenRegionProviderTest method testTokenMerge_1.
@Test
public void testTokenMerge_1() throws Exception {
String model = " ab ";
ITextRegion tokenRegion = tokenRegionProvider.getTokenRegion(model, new TextRegion(2, 0));
assertEquals(1, tokenRegion.getOffset());
assertEquals(2, tokenRegion.getLength());
}
use of org.eclipse.xtext.util.ITextRegion in project xtext-xtend by eclipse.
the class XtendFoldingRegionProvider method computeImportFolding.
protected void computeImportFolding(XtendFile xtendFile, IFoldingRegionAcceptor<ITextRegion> foldingRegionAcceptor) {
if (xtendFile.getImportSection() != null && xtendFile.getImportSection().getImportDeclarations().size() > 1) {
ICompositeNode node = NodeModelUtils.findActualNodeFor(xtendFile.getImportSection());
if (node != null) {
ITextRegion textRegion = node.getTextRegion();
((IFoldingRegionAcceptorExtension<ITextRegion>) foldingRegionAcceptor).accept(textRegion.getOffset(), textRegion.getLength(), foldingPreferences.isFoldImports());
}
}
}
use of org.eclipse.xtext.util.ITextRegion in project xtext-xtend by eclipse.
the class XtendHighlightingCalculator method highlightSpecialIdentifiers.
@Override
protected void highlightSpecialIdentifiers(ILeafNode leafNode, IHighlightedPositionAcceptor acceptor, TerminalRule idRule) {
super.highlightSpecialIdentifiers(leafNode, acceptor, idRule);
if (contextualKeywords != null && contextualKeywords.contains(leafNode.getGrammarElement())) {
ITextRegion leafRegion = leafNode.getTextRegion();
acceptor.addPosition(leafRegion.getOffset(), leafRegion.getLength(), HighlightingStyles.DEFAULT_ID);
}
}
Aggregations