Java 类com.intellij.psi.impl.source.tree.RecursiveTreeElementWalkingVisitor 实例源码

项目:intellij-ce-playground    文件:StubBasedPsiElementBase.java   
private String dumpCreationTraces(FileElement fileElement) {
  final StringBuilder traces = new StringBuilder("\nNow " + Thread.currentThread() + "\n");
  traces.append("My creation trace:\n").append(getUserData(CREATION_TRACE));
  traces.append("AST creation traces:\n");
  fileElement.acceptTree(new RecursiveTreeElementWalkingVisitor(false) {
    @Override
    public void visitComposite(CompositeElement composite) {
      PsiElement psi = composite.getPsi();
      if (psi != null) {
        traces.append(psi).append("@").append(System.identityHashCode(psi)).append("\n");
        String trace = psi.getUserData(CREATION_TRACE);
        if (trace != null) {
          traces.append(trace).append("\n");
        }
      }
      super.visitComposite(composite);
    }
  });
  return traces.toString();
}
项目:intellij-ce-playground    文件:UnwrapHandler.java   
private void restoreCaretPosition(final PsiFile file) {
  ((TreeElement)file.getNode()).acceptTree(new RecursiveTreeElementWalkingVisitor() {
    @Override
    protected void visitNode(TreeElement element) {
      PsiElement el = element.getPsi();
      Integer offset = el.getCopyableUserData(CARET_POS_KEY);

      // continue;
      if (offset != null) {
        myEditor.getCaretModel().moveToOffset(el.getTextOffset() + offset);
        el.putCopyableUserData(CARET_POS_KEY, null);
        return;
      }
      super.visitNode(element);
    }
  });
}
项目:tools-idea    文件:StubBasedPsiElementBase.java   
private String dumpCreationTraces(FileElement fileElement) {
  final StringBuilder traces = new StringBuilder("\nNow " + Thread.currentThread() + "\n");
  traces.append("My creation trace:\n").append(getUserData(CREATION_TRACE));
  traces.append("AST creation traces:\n");
  fileElement.acceptTree(new RecursiveTreeElementWalkingVisitor(false) {
    @Override
    public void visitComposite(CompositeElement composite) {
      PsiElement psi = composite.getPsi();
      if (psi != null) {
        traces.append(psi.toString()).append("@").append(System.identityHashCode(psi)).append("\n");
        String trace = psi.getUserData(CREATION_TRACE);
        if (trace != null) {
          traces.append(trace).append("\n");
        }
      }
      super.visitComposite(composite);
    }
  });
  return traces.toString();
}
项目:tools-idea    文件:DebugUtil.java   
public static void onInvalidated(@NotNull TreeElement treeElement) {
  if (!ourTrackInvalidationCalled) {
    return;
  }

  treeElement.acceptTree(new RecursiveTreeElementWalkingVisitor(false) {
    @Override
    protected void visitNode(TreeElement element) {
      List<Pair<Object, Processor<PsiElement>>> callbacks = element.getUserData(TRACK_INVALIDATION_KEY);
      if (callbacks != null) {
        for (Pair<Object, Processor<PsiElement>> pair : callbacks) {
          Processor<PsiElement> callback = pair.second;
          PsiElement psi = element.getPsi();
          if (psi != null) callback.process(psi);
        }
      }
      super.visitNode(element);
    }
  });
}
项目:tools-idea    文件:UnwrapHandler.java   
private void restoreCaretPosition(final PsiFile file) {
  ((TreeElement)file.getNode()).acceptTree(new RecursiveTreeElementWalkingVisitor() {
    @Override
    protected void visitNode(TreeElement element) {
      PsiElement el = element.getPsi();
      Integer offset = el.getCopyableUserData(CARET_POS_KEY);

      // continue;
      if (offset != null) {
        myEditor.getCaretModel().moveToOffset(el.getTextOffset() + offset);
        el.putCopyableUserData(CARET_POS_KEY, null);
        return;
      }
      super.visitNode(element);
    }
  });
}
项目:consulo    文件:StubBasedPsiElementBase.java   
@Nonnull
private String dumpCreationTraces(@Nonnull FileElement fileElement) {
  final StringBuilder traces = new StringBuilder("\nNow " + Thread.currentThread() + "\n");
  traces.append("My creation trace:\n").append(getUserData(CREATION_TRACE));
  traces.append("AST creation traces:\n");
  fileElement.acceptTree(new RecursiveTreeElementWalkingVisitor(false) {
    @Override
    public void visitComposite(CompositeElement composite) {
      PsiElement psi = composite.getPsi();
      if (psi != null) {
        traces.append(psi).append("@").append(System.identityHashCode(psi)).append("\n");
        String trace = psi.getUserData(CREATION_TRACE);
        if (trace != null) {
          traces.append(trace).append("\n");
        }
      }
      super.visitComposite(composite);
    }
  });
  return traces.toString();
}
项目:consulo    文件:UnwrapHandler.java   
private void restoreCaretPosition(final PsiFile file) {
  ((TreeElement)file.getNode()).acceptTree(new RecursiveTreeElementWalkingVisitor() {
    @Override
    protected void visitNode(TreeElement element) {
      PsiElement el = element.getPsi();
      Integer offset = el.getCopyableUserData(CARET_POS_KEY);

      // continue;
      if (offset != null) {
        myEditor.getCaretModel().moveToOffset(el.getTextOffset() + offset);
        el.putCopyableUserData(CARET_POS_KEY, null);
        return;
      }
      super.visitNode(element);
    }
  });
}
项目:intellij-ce-playground    文件:CodeStyleManagerImpl.java   
private static void transformAllChildren(final ASTNode file) {
  ((TreeElement)file).acceptTree(new RecursiveTreeElementWalkingVisitor() {
  });
}
项目:consulo    文件:CodeStyleManagerImpl.java   
private static void transformAllChildren(final ASTNode file) {
  ((TreeElement)file).acceptTree(new RecursiveTreeElementWalkingVisitor() {
  });
}