use of org.metaborg.core.tracing.Resolution in project spoofax by metaborg.
the class ResolverService method resolve.
private Resolution resolve(@Nullable TermWithRegion tuple) {
if (tuple == null) {
return null;
}
final IStrategoTerm output = tuple.term;
final ISourceRegion offsetRegion = tuple.region;
final Collection<ISourceLocation> targets = Lists.newLinkedList();
if (output.getTermType() == IStrategoTerm.LIST) {
for (IStrategoTerm subterm : output) {
final ISourceLocation targetLocation = common.getTargetLocation(subterm);
if (targetLocation == null) {
logger.debug("Cannot get target location for {}", subterm);
continue;
}
targets.add(targetLocation);
}
} else {
final ISourceLocation targetLocation = common.getTargetLocation(output);
if (targetLocation == null) {
logger.debug("Reference resolution failed, cannot get target location for {}", output);
return null;
}
targets.add(targetLocation);
}
if (targets.isEmpty()) {
logger.debug("Reference resolution failed, cannot get target locations for {}", output);
return null;
}
return new Resolution(offsetRegion, targets);
}
Aggregations