Java 类com.intellij.util.WalkingState 实例源码

项目:intellij-ce-playground    文件:IntervalTreeImpl.java   
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;
    }
  });
}
项目:intellij-ce-playground    文件:RecursiveLighterASTNodeWalkingVisitor.java   
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);
      }
    }
  };
}
项目:tools-idea    文件:IntervalTreeImpl.java   
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;
    }
  });
}
项目:consulo    文件:IntervalTreeImpl.java   
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;
  });
}
项目:consulo    文件:RecursiveLighterASTNodeWalkingVisitor.java   
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);
      }
    }
  };
}
项目:intellij-ce-playground    文件:IntervalTreeImpl.java   
@NotNull
private static <T extends MutableInterval> WalkingState.TreeGuide<IntervalNode<T>> getGuide() {
  //noinspection unchecked
  return (WalkingState.TreeGuide)INTERVAL_TREE_GUIDE_INSTANCE;
}
项目:tools-idea    文件:IntervalTreeImpl.java   
private static <T extends MutableInterval> WalkingState.TreeGuide<IntervalNode<T>> getGuide() {
  //noinspection unchecked
  return (WalkingState.TreeGuide)INTERVAL_TREE_GUIDE_INSTANCE;
}
项目:consulo    文件:IntervalTreeImpl.java   
@Nonnull
private static <T> WalkingState.TreeGuide<IntervalNode<T>> getGuide() {
  //noinspection unchecked
  return (WalkingState.TreeGuide)INTERVAL_TREE_GUIDE_INSTANCE;
}