use of org.spoofax.terms.visitor.IStrategoTermVisitor in project spoofax by metaborg.
the class TracingService method toTermsWithin.
private Iterable<IStrategoTerm> toTermsWithin(IStrategoTerm ast, final ISourceRegion region) {
if (ast == null || region == null) {
return Iterables2.empty();
}
final Collection<IStrategoTerm> parsed = Lists.newLinkedList();
final IStrategoTermVisitor visitor = new AStrategoTermVisitor() {
@Override
public boolean visit(IStrategoTerm term) {
final ISourceLocation location = location(term);
if (location != null && region.contains(location.region())) {
parsed.add(term);
// no need to check the children, as this term is already within the given region
return false;
}
return true;
}
};
StrategoTermVisitee.topdown(visitor, ast);
return parsed;
}
use of org.spoofax.terms.visitor.IStrategoTermVisitor in project spoofax by metaborg.
the class TracingService method toTerms.
private Iterable<IStrategoTerm> toTerms(IStrategoTerm ast, final ISourceRegion region) {
if (ast == null || region == null) {
return Iterables2.empty();
}
final Collection<IStrategoTerm> parsed = Lists.newLinkedList();
final IStrategoTermVisitor visitor = new AStrategoTermVisitor() {
@Override
public boolean visit(IStrategoTerm term) {
final ISourceLocation location = location(term);
if (location != null && location.region().contains(region)) {
parsed.add(term);
return false;
}
return true;
}
};
StrategoTermVisitee.bottomup(visitor, ast);
return parsed;
}
Aggregations