@Override public void visit(final IAstNode node) throws InvocationTargetException { if (node instanceof RAstNode) { ((RAstNode) node).acceptInR(this); return; } if (node.getStopOffset() >= fStartOffset && fStopOffset >= node.getOffset()) { node.acceptInChildren(this); return; } }
@Override public void visit(final SourceComponent node) throws InvocationTargetException { if (fNext == null) { final IAstNode parent = node.getParent(); if (node.fStopOffset >= fOffset && // R script file or inside R chunk (parent == null || (parent.getOffset() <= fOffset && fOffset <= parent.getStopOffset()))) { fContainer = node; node.acceptInRChildren(this); return; } } }
public static RAstNode findNextCommands(final IAstNode root, final int offset) { final NextCommandsSearchVisitor visitor = new NextCommandsSearchVisitor(offset); try { root.accept(visitor); } catch (final InvocationTargetException e) { } return visitor.fNext; }
public static RAstNode findLowestFDefAssignment(final IAstNode root, final int offset) { final LowestFDefAssignmentSearchVisitor visitor = new LowestFDefAssignmentSearchVisitor(offset); try { root.accept(visitor); } catch (final OperationCanceledException e) { } catch (final InvocationTargetException e) { } return visitor.fAssignment; }
public static RAstNode[] findDeepestCommands( final IAstNode root, final int startOffset, final int stopOffset) { final DeepestCommandsSearchVisitor visitor = new DeepestCommandsSearchVisitor(startOffset, stopOffset); try { root.accept(visitor); } catch (final InvocationTargetException e) { } return visitor.fCommands.toArray(new RAstNode[visitor.fCommands.size()]); }