@Nullable
  private static PsiElement getElementToCopy(
      @Nullable final Editor editor, final DataContext dataContext) {
    PsiElement element = null;
    if (editor != null) {
      PsiReference reference = TargetElementUtilBase.findReference(editor);
      if (reference != null) {
        element = reference.getElement();
      }
    }

    if (element == null) {
      element = LangDataKeys.PSI_ELEMENT.getData(dataContext);
    }
    if (element == null && editor == null) {
      VirtualFile virtualFile = PlatformDataKeys.VIRTUAL_FILE.getData(dataContext);
      Project project = PlatformDataKeys.PROJECT.getData(dataContext);
      if (virtualFile != null && project != null) {
        element = PsiManager.getInstance(project).findFile(virtualFile);
      }
    }
    if (element instanceof PsiFile && !((PsiFile) element).getViewProvider().isPhysical()) {
      return null;
    }

    for (QualifiedNameProvider provider : Extensions.getExtensions(QualifiedNameProvider.EP_NAME)) {
      PsiElement adjustedElement = provider.adjustElementToCopy(element);
      if (adjustedElement != null) return adjustedElement;
    }
    return element;
  }
  @Override
  protected void gotoActionPerformed(final AnActionEvent e) {
    final Project project = e.getData(PlatformDataKeys.PROJECT);
    if (project == null) return;

    PsiDocumentManager.getInstance(project).commitAllDocuments();

    final PsiElement psiElement = LangDataKeys.PSI_ELEMENT.getData(e.getDataContext());
    final PsiFile psiFile = LangDataKeys.PSI_FILE.getData(e.getDataContext());
    final VirtualFile virtualFile = PlatformDataKeys.VIRTUAL_FILE.getData(e.getDataContext());

    FeatureUsageTracker.getInstance().triggerFeatureUsed("navigation.goto.inspection");

    final GotoInspectionModel model = new GotoInspectionModel(project);
    showNavigationPopup(
        e,
        model,
        new GotoActionCallback<Object>() {
          @Override
          protected ChooseByNameFilter<Object> createFilter(@NotNull ChooseByNamePopup popup) {
            popup.setSearchInAnyPlace(true);
            return super.createFilter(popup);
          }

          @Override
          public void elementChosen(ChooseByNamePopup popup, final Object element) {
            ApplicationManager.getApplication()
                .invokeLater(
                    new Runnable() {
                      @Override
                      public void run() {
                        runInspection(
                            project,
                            (InspectionToolWrapper) element,
                            virtualFile,
                            psiElement,
                            psiFile);
                      }
                    });
          }
        });
  }
 private VirtualFile getVirtualFiles(AnActionEvent e) {
   return PlatformDataKeys.VIRTUAL_FILE.getData(e.getDataContext());
 }
 public static Module getCurrentModule() {
   final Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
   VirtualFile file =
       PlatformDataKeys.VIRTUAL_FILE.getData(DataManager.getInstance().getDataContext(owner));
   return ModuleUtil.findModuleForFile(file, getCurrentProject());
 }
 private VirtualFile getDir(DataContext dataContext) {
   VirtualFile file = PlatformDataKeys.VIRTUAL_FILE.getData(dataContext);
   if (file == null || !file.isDirectory()) return null;
   return file;
 }