public BookmarkInContextInfo invoke() {
      myBookmarkAtPlace = null;
      myFile = null;
      myLine = -1;

      BookmarkManager bookmarkManager = BookmarkManager.getInstance(myProject);
      if (ToolWindowManager.getInstance(myProject).isEditorComponentActive()) {
        Editor editor = CommonDataKeys.EDITOR.getData(myDataContext);
        if (editor != null) {
          Document document = editor.getDocument();
          myLine = editor.getCaretModel().getLogicalPosition().line;
          myFile = FileDocumentManager.getInstance().getFile(document);
          myBookmarkAtPlace = bookmarkManager.findEditorBookmark(document, myLine);
        }
      }

      if (myFile == null) {
        myFile = CommonDataKeys.VIRTUAL_FILE.getData(myDataContext);
        myLine = -1;

        if (myBookmarkAtPlace == null && myFile != null) {
          myBookmarkAtPlace = bookmarkManager.findFileBookmark(myFile);
        }
      }
      return this;
    }
  @Nullable
  public Object getData(String dataId) {

    if (CommonDataKeys.PROJECT.is(dataId)) {
      return editor != null ? editor.getProject() : null;
    } else if (CommonDataKeys.VIRTUAL_FILE.is(dataId)) {
      return editor != null ? editor.getFile() : null;
    } else if (CommonDataKeys.VIRTUAL_FILE_ARRAY.is(dataId)) {
      return editor != null ? new VirtualFile[] {editor.getFile()} : new VirtualFile[] {};
    } else if (CommonDataKeys.PSI_FILE.is(dataId)) {
      return getData(CommonDataKeys.PSI_ELEMENT.getName());
    } else if (CommonDataKeys.PSI_ELEMENT.is(dataId)) {
      VirtualFile file = editor != null ? editor.getFile() : null;
      return file != null && file.isValid()
          ? PsiManager.getInstance(editor.getProject()).findFile(file)
          : null;
    } else if (LangDataKeys.PSI_ELEMENT_ARRAY.is(dataId)) {
      return editor != null
          ? new PsiElement[] {(PsiElement) getData(CommonDataKeys.PSI_ELEMENT.getName())}
          : new PsiElement[] {};
    } else if (PlatformDataKeys.COPY_PROVIDER.is(dataId) && copyPasteSupport != null) {
      return this;
    } else if (PlatformDataKeys.CUT_PROVIDER.is(dataId) && copyPasteSupport != null) {
      return copyPasteSupport.getCutProvider();
    } else if (PlatformDataKeys.DELETE_ELEMENT_PROVIDER.is(dataId)) {
      return deleteProvider;
    } else if (ImageComponentDecorator.DATA_KEY.is(dataId)) {
      return editor != null ? editor : this;
    }

    return null;
  }
  /** @return selected editor or <code>null</code> */
  @Nullable
  private static VirtualFile getFile(final DataContext context) {
    Project project = CommonDataKeys.PROJECT.getData(context);
    if (project == null) {
      return null;
    }

    return CommonDataKeys.VIRTUAL_FILE.getData(context);
  }
 public void update(AnActionEvent e) {
   Module module = LangDataKeys.MODULE.getData(e.getDataContext());
   if (module == null) {
     e.getPresentation().setEnabledAndVisible(false);
   } else {
     VirtualFile selectedFile = CommonDataKeys.VIRTUAL_FILE.getData(e.getDataContext());
     e.getPresentation()
         .setEnabledAndVisible(
             PluginUtil.isModuleRoot(selectedFile, module)
                     && AzureModuleType.AZURE_MODULE.equals(
                         module.getOptionValue(Module.ELEMENT_TYPE))
                 || PluginUtil.isRoleFolder(selectedFile, module) /* ||
                   ModuleTypeId.JAVA_MODULE.equals(module.getOptionValue(Module.ELEMENT_TYPE))*/);
   }
 }
  public static void setDirectoryName(@NotNull FindModel model, @NotNull DataContext dataContext) {
    PsiElement psiElement = null;
    Project project = CommonDataKeys.PROJECT.getData(dataContext);

    if (project != null && !DumbServiceImpl.getInstance(project).isDumb()) {
      try {
        psiElement = CommonDataKeys.PSI_ELEMENT.getData(dataContext);
      } catch (IndexNotReadyException ignore) {
      }
    }

    String directoryName = null;

    if (psiElement instanceof PsiDirectory) {
      directoryName = ((PsiDirectory) psiElement).getVirtualFile().getPresentableUrl();
    }

    if (directoryName == null && psiElement instanceof PsiDirectoryContainer) {
      final PsiDirectory[] directories = ((PsiDirectoryContainer) psiElement).getDirectories();
      directoryName =
          directories.length == 1 ? directories[0].getVirtualFile().getPresentableUrl() : null;
    }

    Module module = LangDataKeys.MODULE_CONTEXT.getData(dataContext);
    if (module != null) {
      model.setModuleName(module.getName());
    }

    Editor editor = CommonDataKeys.EDITOR.getData(dataContext);
    if (model.getModuleName() == null || editor == null) {
      model.setDirectoryName(directoryName);
      model.setProjectScope(
          directoryName == null && module == null && !model.isCustomScope() || editor != null);
      if (directoryName != null) {
        model.setCustomScope(false); // to select "Directory: " radio button
      }

      // for convenience set directory name to directory of current file, note that we doesn't
      // change default projectScope
      if (directoryName == null) {
        VirtualFile virtualFile = CommonDataKeys.VIRTUAL_FILE.getData(dataContext);
        if (virtualFile != null && !virtualFile.isDirectory())
          virtualFile = virtualFile.getParent();
        if (virtualFile != null) model.setDirectoryName(virtualFile.getPresentableUrl());
      }
    }
  }
  @Nullable
  private static VirtualFile findPomXml(@NotNull DataContext dataContext) {
    VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(dataContext);
    if (file == null) return null;

    if (file.isDirectory()) {
      file = file.findChild("pom.xml");
      if (file == null) return null;
    }

    MavenProjectsManager manager = MavenActionUtil.getProjectsManager(dataContext);
    if (manager == null) return null;
    MavenProject mavenProject = manager.findProject(file);
    if (mavenProject == null) return null;

    return file;
  }