protected static ILocationData createLocationData(ITraceURIConverter converter, ILocationInFileProvider locationProvider, EObject object, ILocationInFileProviderExtension.RegionDescription query) { return createLocationData(converter, locationProvider, object, query, true); }
protected static Set<ILocationData> createAllLocationData(ITraceURIConverter converter, ILocationInFileProvider locationProvider, IJvmModelAssociations jvmModelAssociations, EObject object, ILocationInFileProviderExtension.RegionDescription query, boolean skipEmpty) { Set<EObject> sourceElements = jvmModelAssociations.getSourceElements(object); Set<ILocationData> result = Collections.emptySet(); if (sourceElements.isEmpty()) { ILocationData locationData = createLocationData(converter, locationProvider, object, query, skipEmpty); if (locationData != null) { result = Collections.singleton(locationData); } } else { result = Sets.newHashSet(); for(EObject sourceElement: sourceElements) { ILocationData locationData = createLocationData(converter, locationProvider, sourceElement, query, skipEmpty); if (locationData != null) { result.add(locationData); } } } return result; }
@Override public ITreeAppendable trace(Iterable<? extends EObject> objects) { if (Iterables.isEmpty(objects)) throw new IllegalArgumentException("List of objects may not be empty"); int size = Iterables.size(objects); if (size == 1) return trace(objects.iterator().next(), false); Set<ILocationData> newData = new LinkedHashSet<ILocationData>(size); for(EObject object: objects) { ILocationData locationData = createLocationData(traceURIConverter, locationProvider, object, ILocationInFileProviderExtension.RegionDescription.FULL); if (locationData != null) newData.add(locationData); } if (newData.isEmpty() && !isUseForDebugging()) return this; return trace(newData, false); }
@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); }
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; }