use of org.metaborg.core.outline.OutlineNode in project spoofax by metaborg.
the class OutlineService method toOutlineNode.
@Nullable
private IOutlineNode toOutlineNode(IStrategoTerm term, @Nullable IOutlineNode parent, FileObject location) {
if (!(term instanceof IStrategoAppl)) {
return null;
}
final IStrategoAppl appl = (IStrategoAppl) term;
if (!Tools.hasConstructor(appl, "Node", 2)) {
return null;
}
final IStrategoTerm labelTerm = appl.getSubterm(0);
final String label = label(labelTerm);
final FileObject icon = icon(labelTerm, location);
final ISourceRegion region = region(labelTerm);
final OutlineNode node = new OutlineNode(label, icon, region, parent);
final IStrategoTerm nodesTerm = appl.getSubterm(1);
for (IStrategoTerm nodeTerm : nodesTerm) {
final IOutlineNode childNode = toOutlineNode(nodeTerm, node, location);
if (childNode != null) {
node.addChild(childNode);
}
}
return node;
}
Aggregations