private static void positionCaretToDeclaration(@NotNull Project project, @NotNull PsiFile psiFile, @NotNull PsiElement declaration) {
      if (!psiFile.isPhysical()) return;
      final Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor();
      if (editor != null && (IJSwingUtilities.hasFocus(editor.getComponent()) || ApplicationManager.getApplication().isUnitTestMode())) {
        final PsiFile openedFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
        if (openedFile == psiFile) {
          editor.getCaretModel().moveToOffset(declaration.getTextOffset());
          editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
        }
      }
    }
private static void positionCaretToDeclaration(@NotNull Project project, @NotNull PsiFile psiFile, @NotNull PsiElement declaration)