ModPsiNavigator (@NotNull Editor editor) { return new ModPsiNavigator() { @Override public void select(@NotNull PsiElement element) { select(element.getTextRange()); } @Override public void select(@NotNull TextRange range) { editor.getSelectionModel().setSelection(range.getStartOffset(), range.getEndOffset()); } @Override public void moveTo(int offset) { editor.getCaretModel().moveToOffset(offset); } @Override public void moveTo(@NotNull PsiElement element) { moveTo(element.getTextRange().getStartOffset()); } @Override public void moveToPrevious(char ch) { Document document = editor.getDocument(); int offset = editor.getCaretModel().getOffset(); CharSequence sequence = document.getCharsSequence(); while (offset > 0 && sequence.charAt(offset) != ch) { offset--; } editor.getCaretModel().moveToOffset(offset); } @Override public int getCaretOffset() { return editor.getCaretModel().getOffset(); } }; }