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 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"); } } } }
@Nullable public URI getAssociatedPath() { ILocationData data = getMergedAssociatedLocation(); if (data != null) { URI result = data.getPath(); if (result != null) { return result; } } if (parent == null) return null; boolean uriSeen = false; for (ILocationData associated : getAssociatedLocations()) if (associated.getPath() != null) { if (!uriSeen) uriSeen = true; else return null; } return parent.getAssociatedPath(); }
protected Map<URI, List<Pair<ILocationData, AbstractTraceRegion>>> collectMatchingLocations(@Nullable URI expectedAssociatedPath) { Map<URI, List<Pair<ILocationData, AbstractTraceRegion>>> result = Maps.newHashMapWithExpectedSize(2); Iterator<AbstractTraceRegion> treeIterator = treeIterator(); while(treeIterator.hasNext()) { AbstractTraceRegion next = treeIterator.next(); URI associatedPath = next.getAssociatedPath(); List<Pair<ILocationData, AbstractTraceRegion>> matchingLocations = getCollectingList(associatedPath, expectedAssociatedPath, result); for(ILocationData locationData: next.getAssociatedLocations()) { if (associatedPath == null) { matchingLocations = getCollectingList(locationData.getPath(), expectedAssociatedPath, result); } if (matchingLocations != null) { matchingLocations.add(Tuples.create(locationData, next)); } } } return result; }
for(ILocationData data: allData) { if (path != null) { if (!path.equals(data.getPath())) { return null; if (data.getPath() == null) { if (!allNull) throw new IllegalStateException("Iff multiple associated locations are present, the path has to be set"); } else { allNull = false; path = data.getPath();
/** * Creates a new location for a target resource that matches the given {@code location}. * @param location the location * @return the location in resource, <code>null</code> detecting a path fails. */ @Nullable protected ILocationInResource createLocationInResourceFor(ILocationData location, AbstractTraceRegion traceRegion) { URI path = location.getPath(); if (path == null) path = traceRegion.getAssociatedPath(); if (path == null) return null; return new LocationInResource(location.getOffset(), location.getLength(), location.getLineNumber(), location.getEndLineNumber(), path, this); }
public void writeLocation(ILocationData location, Callback<AbstractTraceRegion, ILocationData> callback) throws IOException { callback.doWriteLocation(location.getOffset(), location.getLength(), location.getLineNumber(), location.getEndLineNumber(), location.getPath()); }
AbstractTraceRegion region = iterator.next(); for(ILocationData location: region.getAssociatedLocations()) { URI path = location.getPath(); if (path != null) { sourceTraces.put(path, tracePath);
int splittedLength = nextLocation.getLength() - nextLength; int splittedBeginLine = nextEndLine; ILocationData splitted = new LocationData(currentEndOffset, splittedLength, splittedBeginLine, nextLocation.getEndLineNumber(), nextLocation.getPath()); for(int j = i + 1; j < locations.size() && splitted != null; j++) { ILocationData shiftMe = locations.get(j).getFirst();