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(); }
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); } }); }
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(); }
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); } }); }
@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(); }
private static void transformAllChildren(final ASTNode file) { ((TreeElement)file).acceptTree(new RecursiveTreeElementWalkingVisitor() { }); }