public TemporaryTraceRegion(int myOffset, int myLength, int myLineNumber, int myEndLineNumber, List<ILocationData> locations, AbstractTraceRegion parent) { super(new TextRegionWithLineInformation(myOffset, myLength, myLineNumber, myEndLineNumber), locations, parent); }
@Override public ITextRegionWithLineInformation merge(ITextRegionWithLineInformation other) { if (contains(other)) return this; if (other.contains(this)) return other; int newOffset = Math.min(getOffset(), other.getOffset()); int newLength = Math.max(getOffset() + getLength(), other.getOffset() + other.getLength()) - newOffset; int newLineNumber = Math.min(getLineNumber(), other.getLineNumber()); int newEndLineNumber = Math.max(getEndLineNumber(), other.getEndLineNumber()); return new TextRegionWithLineInformation(newOffset, newLength, newLineNumber, newEndLineNumber); }
@Override public ITextRegion merge(ITextRegion other) { if (other instanceof ITextRegionWithLineInformation) return merge((ITextRegionWithLineInformation) other); return super.merge(other); }
public TraceRegion(int myOffset, int myLength, int myLineNumber, int myEndLineNumber, ILocationData locationData, @Nullable AbstractTraceRegion parent) { super(new TextRegionWithLineInformation(myOffset, myLength, myLineNumber, myEndLineNumber), locationData, parent); if (myOffset == myLength && myOffset == 0) { throw new IllegalArgumentException(); } if (parent == null) { if (locationData.getPath() == null) { throw new IllegalArgumentException("associatedPath may not be null"); } } else { if (parent.getAssociatedPath() == null && locationData.getPath() == null) { throw new IllegalArgumentException("associatedPath may not be null"); } } }
public ITextRegionWithLineInformation merge(ITextRegionWithLineInformation other) { if (contains(other)) return this; if (other.contains(this)) return other; int newOffset = Math.min(getOffset(), other.getOffset()); int newLength = Math.max(getOffset() + getLength(), other.getOffset() + other.getLength()) - newOffset; int newLineNumber = Math.min(getLineNumber(), other.getLineNumber()); int newEndLineNumber = Math.max(getEndLineNumber(), other.getEndLineNumber()); return new TextRegionWithLineInformation(newOffset, newLength, newLineNumber, newEndLineNumber); }
@Override public ITextRegion merge(ITextRegion other) { if (other instanceof ITextRegionWithLineInformation) return merge((ITextRegionWithLineInformation) other); return super.merge(other); }
@Override public ITreeAppendable trace(EObject object, EStructuralFeature feature, int indexInList) { ITextRegion textRegion = locationProvider.getFullTextRegion(object, feature, indexInList); if (!(textRegion instanceof ITextRegionWithLineInformation)) { if (log.isDebugEnabled()) log.debug("location provider returned text region without line information. Synthesized dummy data.", new Exception()); textRegion = new TextRegionWithLineInformation(textRegion.getOffset(), textRegion.getLength(), 0, 0); } if (textRegion == ITextRegion.EMPTY_REGION) { return this; } ILocationData newData = createLocationData(traceURIConverter, object, (ITextRegionWithLineInformation) textRegion); return trace(Collections.singleton(newData), false); }
public TraceRegion(int myOffset, int myLength, int myLineNumber, int myEndLineNumber, List<ILocationData> allLocationData, @Nullable AbstractTraceRegion parent) { super(new TextRegionWithLineInformation(myOffset, myLength, myLineNumber, myEndLineNumber), Lists.newArrayList(allLocationData), parent); if (parent == null) { for(ILocationData locationData: allLocationData) { if (locationData.getPath() == null) { throw new IllegalArgumentException("associatedPath may not be null"); } } } else { boolean nullSeen = false; boolean notNullSeen = false; for(ILocationData locationData: allLocationData) { if (locationData.getPath() == null) { nullSeen = true; } else { notNullSeen = true; } if (nullSeen && notNullSeen) { throw new IllegalArgumentException("list of locations is inconsistent"); } } if (parent.getAssociatedPath() == null) { if (nullSeen) { throw new IllegalArgumentException("list of locations is inconsistent with parent"); } } } }
private static ILocationData createLocationData(ITraceURIConverter converter, ILocationInFileProvider locationProvider, EObject object, ILocationInFileProviderExtension.RegionDescription query, boolean skipEmpty) { ITextRegion textRegion = locationProvider instanceof ILocationInFileProviderExtension ? ((ILocationInFileProviderExtension) locationProvider).getTextRegion(object, query) : locationProvider.getFullTextRegion(object); if (!(textRegion instanceof ITextRegionWithLineInformation)) { if (log.isDebugEnabled()) log.debug("location provider returned text region without line information.", new Exception()); if (textRegion != null) textRegion = new TextRegionWithLineInformation(textRegion.getOffset(), textRegion.getLength(), 0, 0); else return null; } // usually we want to skip empty regions but if the root region is empty, we want to use it to store the path information along // with the empty offset / length pair if (skipEmpty && textRegion == ITextRegion.EMPTY_REGION) { return null; } ILocationData newData = createLocationData(converter, object, (ITextRegionWithLineInformation) textRegion); return newData; }
public ITextRegionWithLineInformation getMyRegion() { return new TextRegionWithLineInformation(getMyOffset(), getMyLength(), getMyLineNumber(), getMyEndLineNumber()); }
public ITextRegionWithLineInformation getTextRegion() { ITextRegionWithLineInformation result = new TextRegionWithLineInformation(getOffset(), getLength(), getLineNumber(), getEndLineNumber()); return result; }
protected ITextRegion createRegion(final List<INode> nodes) { ITextRegion result = ITextRegion.EMPTY_REGION; for (INode node : nodes) { if (!isHidden(node)) { int length = node.getLength(); if (length != 0) result = result.merge(new TextRegionWithLineInformation(node.getOffset(), length, node.getStartLine() - 1, node.getEndLine() - 1)); } } return result; }
ITextRegionWithLineInformation associated = ITextRegionWithLineInformation.EMPTY_REGION; for(AbstractTraceRegion child: result) { rootLocation = rootLocation.merge(new TextRegionWithLineInformation(child.getMyOffset(), child.getMyLength(), child.getMyLineNumber(), child.getMyEndLineNumber())); ILocationData childAssociation = child.getMergedAssociatedLocation(); if (childAssociation != null)
region = region.merge(new TextRegionWithLineInformation(data.getOffset(), data.getLength(), data.getLineNumber(), data.getEndLineNumber()));
protected ITextRegionWithLineInformation toTextRegionWithLineInformation(final EObject obj, final ITextRegion textRegion) { if ((textRegion == null)) { return ITextRegionWithLineInformation.EMPTY_REGION; } if ((textRegion instanceof ITextRegionWithLineInformation)) { return ((ITextRegionWithLineInformation)textRegion); } final ICompositeNode node = NodeModelUtils.getNode(obj); if ((node == null)) { int _offset = textRegion.getOffset(); int _length = textRegion.getLength(); return new TextRegionWithLineInformation(_offset, _length, 0, 0); } int _line = NodeModelUtils.getLineAndColumn(node, textRegion.getOffset()).getLine(); final int startLine = (_line - 1); int _offset_1 = textRegion.getOffset(); int _length_1 = textRegion.getLength(); int _plus = (_offset_1 + _length_1); int _line_1 = NodeModelUtils.getLineAndColumn(node, _plus).getLine(); final int endLine = (_line_1 - 1); int _offset_2 = textRegion.getOffset(); int _length_2 = textRegion.getLength(); return new TextRegionWithLineInformation(_offset_2, _length_2, startLine, endLine); } }
/** * @since 2.3 */ protected ITextRegion createRegion(List<INode> nodes, RegionDescription query) { if (query == RegionDescription.FULL || query == RegionDescription.SIGNIFICANT) return createRegion(nodes); ITextRegion result = ITextRegion.EMPTY_REGION; for (INode node : nodes) { for(INode leafNode: node.getLeafNodes()) { if (!isHidden(leafNode, query)) { int length = leafNode.getLength(); if (length != 0) result = result.merge(new TextRegionWithLineInformation(leafNode.getOffset(), length, leafNode.getStartLine() - 1, leafNode.getEndLine() - 1)); } } } return result; }
int length = getNodeLength(child); if (length != 0) { result = result.merge(new TextRegionWithLineInformation(child.getOffset(), length, child.getStartLine() - 1, child.getEndLine() - 1));
protected ILocationData toLocationData(List<INode> nodes) { ITextRegionWithLineInformation result = ITextRegionWithLineInformation.EMPTY_REGION; for (INode node : nodes) { if (!isHidden(node)) { ITextRegionWithLineInformation region = node.getTextRegionWithLineInformation(); if (region.getLength() != 0) { result = result.merge(new TextRegionWithLineInformation(region.getOffset(), region.getLength(), region.getLineNumber() - 1, region.getEndLineNumber() - 1)); } } } if (result.getLength() == 0) return null; return new LocationData(result.getOffset(), result.getLength(), result.getLineNumber(), result.getEndLineNumber(), null); }
continue; result = result.merge(toZeroBasedRegion(new TextRegionWithLineInformation(offset, length, region.getLineNumber(), region.getEndLineNumber())));