use of org.eclipse.xtext.generator.trace.SourceRelativeURI 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.generator.trace.SourceRelativeURI in project xtext-core by eclipse.
the class AbstractTraceForURIProvider method getTraceToTarget.
public Trace getTraceToTarget(final SomeFile sourceFile, final AbsoluteURI absoluteSourceResource, final IProjectConfig projectConfig) {
final List<PersistedTrace> traceFiles = findInverseTraceFiles(sourceFile);
if (traceFiles.isEmpty() || projectConfig == null) {
return null;
}
Trace result = newAbstractTrace(sourceFile);
result.setTraceToSource(false);
final IResourceServiceProvider serviceProvider = getServiceProvider(absoluteSourceResource);
final ITraceURIConverter traceURIConverter = serviceProvider.get(ITraceURIConverter.class);
result.setTraceRegionProvider(new ITraceRegionProvider() {
@Override
public AbstractTraceRegion getTraceRegion() {
List<AbstractTraceRegion> result = newArrayList();
SourceRelativeURI sourceUriForTrace = traceURIConverter.getURIForTrace(projectConfig, absoluteSourceResource);
for (PersistedTrace traceFile : traceFiles) {
AbsoluteURI generatedFileURI = getGeneratedLocation(traceFile);
if (generatedFileURI == null) {
throw new TraceNotFoundException();
}
AbstractTraceRegion traceRegion = cachedTraces.getTraceRegion(traceFile);
SourceRelativeURI generatedUriForTrace = getGeneratedUriForTrace(projectConfig, absoluteSourceResource, generatedFileURI, traceURIConverter);
if (sourceUriForTrace != null && generatedUriForTrace != null) {
result.addAll(traceRegion.invertFor(sourceUriForTrace, generatedUriForTrace));
}
}
if (result.isEmpty())
throw new TraceNotFoundException();
return AbstractTraceRegion.mergedFrom(result);
}
});
return result;
}
Aggregations