Java Code Examples for org.eclipse.xtext.generator.trace.AbstractTraceRegion#getMyOffset()
The following examples show how to use
org.eclipse.xtext.generator.trace.AbstractTraceRegion#getMyOffset() .
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: AbstractTrace.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
protected AbstractTraceRegion findTraceRegionAt(int offset, boolean includeRegionEnd) { AbstractTraceRegion candidate = getRootTraceRegion(); if (candidate == null || !encloses(candidate, offset, includeRegionEnd)) { // we have an inconsistent state - no candidate matches return null; } outer: while(candidate != null) { // TODO binary search? List<? extends AbstractTraceRegion> children = candidate.getNestedRegions(); if (children.isEmpty()) { return candidate; } for(AbstractTraceRegion child: children) { if (encloses(child, offset, includeRegionEnd)) { candidate = child; continue outer; } else { if (child.getMyOffset() > offset) { return candidate; } } } return candidate; } return null; }
Example 2
Source File: CompilerTraceTest.java From xtext-xtend with Eclipse Public License 2.0 | 5 votes |
public AbstractTraceRegion merge(final List<AbstractTraceRegion> regions) { boolean _isEmpty = regions.isEmpty(); boolean _not = (!_isEmpty); Assert.assertTrue(_not); int _size = regions.size(); boolean _greaterThan = (_size > 1); if (_greaterThan) { ITextRegionWithLineInformation rootLocation = ITextRegionWithLineInformation.EMPTY_REGION; ITextRegionWithLineInformation associated = ITextRegionWithLineInformation.EMPTY_REGION; for (final AbstractTraceRegion child : regions) { { int _myOffset = child.getMyOffset(); int _myLength = child.getMyLength(); int _myLineNumber = child.getMyLineNumber(); int _myEndLineNumber = child.getMyEndLineNumber(); TextRegionWithLineInformation _textRegionWithLineInformation = new TextRegionWithLineInformation(_myOffset, _myLength, _myLineNumber, _myEndLineNumber); rootLocation = rootLocation.merge(_textRegionWithLineInformation); ILocationData childAssociation = child.getMergedAssociatedLocation(); if ((childAssociation != null)) { associated = associated.merge(childAssociation); } } } final RootTraceRegionForTesting root = new RootTraceRegionForTesting(rootLocation, associated); for (final AbstractTraceRegion child_1 : regions) { child_1.setParent(root); } return root; } else { return IterableExtensions.<AbstractTraceRegion>head(regions); } }
Example 3
Source File: AbstractTrace.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public ILocationInResource getBestAssociatedLocation(ITextRegion region) { AbstractTraceRegion right = findTraceRegionAtRightOffset(region.getOffset() + region.getLength()); if (right != null && encloses(right, region.getOffset(), true)) { if (right.getMyOffset() + right.getMyLength() == region.getOffset() + region.getLength()) return getMergedLocationInResource(right); } AbstractTraceRegion left = findTraceRegionAtLeftOffset(region.getOffset()); return mergeRegions(left, right); }