use of org.eclipse.xtext.generator.trace.ITraceURIConverter in project xtext-core by eclipse.
the class AbstractTrace method isAssociatedWith.
protected boolean isAssociatedWith(AbstractTraceRegion region, AbsoluteURI uri, IProjectConfig project) {
ITraceURIConverter traceURIConverter = getService(uri, ITraceURIConverter.class);
if (traceURIConverter == null) {
traceURIConverter = getService(getLocalURI(), ITraceURIConverter.class);
}
SourceRelativeURI convertedUri = traceURIConverter.getURIForTrace(project, uri);
return convertedUri.equals(region.getAssociatedSrcRelativePath());
}
use of org.eclipse.xtext.generator.trace.ITraceURIConverter 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