Search in sources :

Example 1 with RecursiveTreeElementWalkingVisitor

use of com.intellij.psi.impl.source.tree.RecursiveTreeElementWalkingVisitor in project intellij-community by JetBrains.

the class StubBasedPsiElementBase method dumpCreationTraces.

@NotNull
private String dumpCreationTraces(@NotNull 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();
}
Also used : RecursiveTreeElementWalkingVisitor(com.intellij.psi.impl.source.tree.RecursiveTreeElementWalkingVisitor) CompositeElement(com.intellij.psi.impl.source.tree.CompositeElement) PsiElement(com.intellij.psi.PsiElement) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

PsiElement (com.intellij.psi.PsiElement)1 CompositeElement (com.intellij.psi.impl.source.tree.CompositeElement)1 RecursiveTreeElementWalkingVisitor (com.intellij.psi.impl.source.tree.RecursiveTreeElementWalkingVisitor)1 NotNull (org.jetbrains.annotations.NotNull)1