void (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); } }); }