private boolean process(@Nullable IntervalNode<T> root, final int modCountBefore, @NotNull final Processor<? super T> processor) { if (root == null) return true; WalkingState.TreeGuide<IntervalNode<T>> guide = getGuide(); return WalkingState.processAll(root, guide, new Processor<IntervalNode<T>>() { @Override public boolean process(IntervalNode<T> node) { if (!node.processAliveKeys(processor)) return false; if (modCount != modCountBefore) throw new ConcurrentModificationException(); return true; } }); }
protected RecursiveLighterASTNodeWalkingVisitor(@NotNull final LighterAST ast) { this.ast = ast; myWalkingState = new WalkingState<IndexedLighterASTNode>(new LighterASTGuide()) { @Override public void elementFinished(@NotNull IndexedLighterASTNode element) { RecursiveLighterASTNodeWalkingVisitor.this.elementFinished(element.node); if (parentStack.peek() == element) { // getFirstChild returned nothing. otherwise getFirstChild() was not called, i.e. super.visitNode() was not called i.e. just ignore IndexedLighterASTNode[] children = childrenStack.pop(); List<LighterASTNode> list = children.length == 0 ? Collections.<LighterASTNode>emptyList() : ContainerUtil.map(children, new Function<IndexedLighterASTNode, LighterASTNode>() { @Override public LighterASTNode fun(IndexedLighterASTNode node) { return node.node; } }); ast.disposeChildren(list); parentStack.pop(); } } @Override public void visit(@NotNull IndexedLighterASTNode iNode) { LighterASTNode element = iNode.node; RecursiveLighterASTNodeWalkingVisitor visitor = RecursiveLighterASTNodeWalkingVisitor.this; if (element instanceof LighterLazyParseableNode) { visitor.visitLazyParseableNode((LighterLazyParseableNode)element); } else if (element instanceof LighterASTTokenNode) { visitor.visitTokenNode((LighterASTTokenNode)element); } else { visitor.visitNode(element); } } }; }
private boolean process(final IntervalNode<T> root, final Processor<? super T> processor, final int modCountBefore) { if (root == null) return true; WalkingState.TreeGuide<IntervalNode<T>> guide = getGuide(); return WalkingState.processAll(root, guide, new Processor<IntervalNode<T>>() { @Override public boolean process(IntervalNode<T> node) { if (!node.processAliveKeys(processor)) return false; if (modCount != modCountBefore) throw new ConcurrentModificationException(); return true; } }); }
private boolean process(@Nullable IntervalNode<T> root, final int modCountBefore, @Nonnull final Processor<? super T> processor) { if (root == null) return true; WalkingState.TreeGuide<IntervalNode<T>> guide = getGuide(); return WalkingState.processAll(root, guide, node -> { if (!node.processAliveKeys(processor)) return false; if (getModCount() != modCountBefore) throw new ConcurrentModificationException(); return true; }); }
protected RecursiveLighterASTNodeWalkingVisitor(@Nonnull final LighterAST ast) { this.ast = ast; myWalkingState = new WalkingState<IndexedLighterASTNode>(new LighterASTGuide()) { @Override public void elementFinished(@Nonnull IndexedLighterASTNode element) { RecursiveLighterASTNodeWalkingVisitor.this.elementFinished(element.node); if (parentStack.peek() == element) { // getFirstChild returned nothing. otherwise getFirstChild() was not called, i.e. super.visitNode() was not called i.e. just ignore childrenStack.pop(); parentStack.pop(); } } @Override public void visit(@Nonnull IndexedLighterASTNode iNode) { LighterASTNode element = iNode.node; RecursiveLighterASTNodeWalkingVisitor visitor = RecursiveLighterASTNodeWalkingVisitor.this; if (element instanceof LighterLazyParseableNode) { visitor.visitLazyParseableNode((LighterLazyParseableNode)element); } else if (element instanceof LighterASTTokenNode) { visitor.visitTokenNode((LighterASTTokenNode)element); } else { visitor.visitNode(element); } } }; }
@NotNull private static <T extends MutableInterval> WalkingState.TreeGuide<IntervalNode<T>> getGuide() { //noinspection unchecked return (WalkingState.TreeGuide)INTERVAL_TREE_GUIDE_INSTANCE; }
private static <T extends MutableInterval> WalkingState.TreeGuide<IntervalNode<T>> getGuide() { //noinspection unchecked return (WalkingState.TreeGuide)INTERVAL_TREE_GUIDE_INSTANCE; }
@Nonnull private static <T> WalkingState.TreeGuide<IntervalNode<T>> getGuide() { //noinspection unchecked return (WalkingState.TreeGuide)INTERVAL_TREE_GUIDE_INSTANCE; }