public void actionPerformed(final AnActionEvent e) {
    final Project project = CommonDataKeys.PROJECT.getData(e.getDataContext());
    if (project == null) return;

    final PsiFile file = LangDataKeys.PSI_FILE.getData(e.getDataContext());
    FileAssociationsConfigurable.editAssociations(project, file);
  }
  public void update(final AnActionEvent event) {
    super.update(event);

    final Presentation presentation = event.getPresentation();
    final DataContext context = event.getDataContext();
    Module module = (Module) context.getData(LangDataKeys.MODULE.getName());
    PsiFile currentFile = (PsiFile) context.getData(LangDataKeys.PSI_FILE.getName());
    Editor editor = (Editor) context.getData(PlatformDataKeys.EDITOR.getName());
    // VirtualFile currentFile = (VirtualFile)
    // context.getData(PlatformDataKeys.VIRTUAL_FILE.getName());
    if (currentFile != null && editor != null) {
      boolean isSSFile =
          currentFile
              .getFileType()
              .getDefaultExtension()
              .equals(SilverStripeFileType.DEFAULT_EXTENSION);
      SelectionModel selectionModel = editor.getSelectionModel();
      String selectedText = selectionModel.getSelectedText();
      this.selectedText = selectedText;
      this.selectonModel = selectionModel;
      this.editor = editor;
      this.currentFile = currentFile;
      if (selectedText == null) {
        presentation.setEnabled(false);
      }
      if (!isSSFile) {
        presentation.setEnabled(false);
        presentation.setVisible(false);
      }
    } else {
      presentation.setEnabled(false);
      presentation.setVisible(false);
    }
  }
  @Override
  public void update(AnActionEvent e) {
    final DataContext dataContext = e.getDataContext();
    final Presentation presentation = e.getPresentation();

    final boolean enabled = LangDataKeys.PSI_FILE.getData(dataContext) instanceof DartFile;

    presentation.setVisible(enabled);
    presentation.setEnabled(enabled);
  }
  public void actionPerformed(AnActionEvent e) {
    final Editor editor = getEditor(e);
    final Project project = editor.getProject();
    assert project != null;
    final PsiFile psiFile = LangDataKeys.PSI_FILE.getData(e.getDataContext());
    if (psiFile == null) return;
    final I18nQuickFixHandler handler = getHandler(e);
    if (handler == null) return;

    doI18nSelectedString(project, editor, psiFile, handler);
  }
    @Override
    public void execute(Editor editor, DataContext dataContext) {
      Project project = CommonDataKeys.PROJECT.getData(dataContext);
      if (project == null) {
        return;
      }

      PsiFile psiFile = LangDataKeys.PSI_FILE.getData(dataContext);
      if (psiFile == null) {
        return;
      }

      process(psiFile, editor, project, editor.getCaretModel().getOffset());
    }
 @Nullable
 private static PsiElement[] getPsiElements(DataContext dataContext) {
   PsiElement[] elements = LangDataKeys.PSI_ELEMENT_ARRAY.getData(dataContext);
   if (elements == null) {
     final Object data = LangDataKeys.PSI_ELEMENT.getData(dataContext);
     if (data != null) {
       elements = new PsiElement[] {(PsiElement) data};
     } else {
       final Object data1 = LangDataKeys.PSI_FILE.getData(dataContext);
       if (data1 != null) {
         elements = new PsiElement[] {(PsiFile) data1};
       }
     }
   }
   return elements;
 }
  @Override
  public void actionPerformed(AnActionEvent e) {

    DataContext context = e.getDataContext();
    Editor editor = PlatformDataKeys.EDITOR.getData(context);
    PsiFile psiFile = LangDataKeys.PSI_FILE.getData(context);
    if (psiFile == null) return;

    List<GotoRelatedItem> items = getItems(psiFile, editor, context);
    if (items.isEmpty()) return;
    if (items.size() == 1 && items.get(0).getElement() != null) {
      items.get(0).navigate();
      return;
    }
    if (ApplicationManager.getApplication().isUnitTestMode()) {
      System.out.println(items);
    }
    createPopup(items, "Go to Related Files").showInBestPositionFor(context);
  }
  @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);
                      }
                    });
          }
        });
  }
 @Override
 public void update(AnActionEvent e) {
   e.getPresentation().setEnabled(LangDataKeys.PSI_FILE.getData(e.getDataContext()) != null);
 }
  @Override
  public void actionPerformed(final AnActionEvent e) {
    final PsiFile psiFile = LangDataKeys.PSI_FILE.getData(e.getDataContext());
    if (!(psiFile instanceof DartFile)) {
      return;
    }
    final VirtualFile virtualFile = DartResolveUtil.getRealVirtualFile(psiFile);
    if (virtualFile == null) {
      return;
    }
    final DartSettings settings = DartSettingsUtil.getSettings();
    final VirtualFile dart2js = settings.getDart2JS();
    if (dart2js == null) {
      Messages.showOkCancelDialog(
          e.getProject(),
          DartBundle.message("dart.sdk.bad.dart2js.path", settings.getDart2JSUrl()),
          DartBundle.message("dart.warning"),
          icons.DartIcons.Dart_16);
      return;
    }

    final String jsFilePath = virtualFile.getPath() + ".js";
    final Dart2JSSettingsDialog dialog =
        new Dart2JSSettingsDialog(psiFile.getProject(), jsFilePath);
    dialog.show();
    if (!dialog.isOK()) {
      return;
    }

    new Task.Backgroundable(psiFile.getProject(), "dart2js", true) {
      public void run(@NotNull ProgressIndicator indicator) {
        indicator.setText("Running dart2js...");
        indicator.setFraction(0.0);
        final GeneralCommandLine command = new GeneralCommandLine();
        command.setExePath(dart2js.getPath());
        if (dialog.isCheckedMode()) {
          command.addParameter("--checked");
        }
        if (dialog.isMinify()) {
          command.addParameter("--minify");
        }
        command.addParameter("--out=" + dialog.getOutputPath());
        command.addParameter(virtualFile.getPath());

        // save on disk
        ApplicationManager.getApplication()
            .invokeAndWait(
                new Runnable() {
                  @Override
                  public void run() {
                    FileDocumentManager.getInstance().saveAllDocuments();
                  }
                },
                ModalityState.defaultModalityState());

        try {
          final String output = ScriptRunnerUtil.getProcessOutput(command);
          ProgressManager.progress("");
          LOG.debug(output);
          boolean error = !output.isEmpty();
          if (error) {
            Notifications.Bus.notify(
                new Notification(
                    e.getPresentation().getText(),
                    DartBundle.message("dart2js.title"),
                    DartBundle.message("dart2js.js.file.creation.error", output),
                    NotificationType.ERROR));
            return;
          }
          Notifications.Bus.notify(
              new Notification(
                  e.getPresentation().getText(),
                  DartBundle.message("dart2js.title"),
                  DartBundle.message("dart2js.js.file.created", jsFilePath),
                  NotificationType.INFORMATION));

          final String parentDir = VfsUtil.getParentDir(dialog.getOutputPath());
          assert parentDir != null;
          final VirtualFile outputParentVirtualFile =
              VirtualFileManager.getInstance().findFileByUrl(VfsUtilCore.pathToUrl(parentDir));
          if (outputParentVirtualFile != null) {
            outputParentVirtualFile.refresh(true, false);
          }
        } catch (ExecutionException ex) {
          LOG.error(ex);
          Notifications.Bus.notify(
              new Notification(
                  e.getPresentation().getText(),
                  DartBundle.message("dart2js.title"),
                  DartBundle.message("dart2js.js.file.creation.error", ex.getMessage()),
                  NotificationType.ERROR));
        }
        indicator.setFraction(1.0);
      }
    }.setCancelText("Stop").queue();
  }