private CompilationUnitEditor findTargetCompilationUnitEditor(
      ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow window =
      HandlerUtil.getActiveWorkbenchWindowChecked(event);
    IWorkbenchPart activePart = window.getActivePage().getActivePart();
    IEditorPart editor = window.getActivePage().getActiveEditor();
    IWorkingCopyManager manager =
      JavaPlugin.getDefault().getWorkingCopyManager();

    try {
      CompilationUnitEditor targetCompilationUnitEditor = null;
      ICompilationUnit compilationUnit = null;
      if (editor == activePart) {
        if (editor instanceof CompilationUnitEditor) {
          targetCompilationUnitEditor = (CompilationUnitEditor) editor;
          compilationUnit =
              manager.getWorkingCopy(targetCompilationUnitEditor
                  .getEditorInput());
        }
      } else {
        if (activePart instanceof PackageExplorerPart) {
          ISelection selection =
              activePart.getSite().getSelectionProvider().getSelection();
          if (selection instanceof IStructuredSelection) {
            IStructuredSelection structuredSelection =
                (IStructuredSelection) selection;
            Object firstElement = structuredSelection.getFirstElement();
            IEditorPart editorPart =
                EditorUtility.openInEditor(firstElement, false);
            if (editorPart instanceof CompilationUnitEditor) {
              targetCompilationUnitEditor = (CompilationUnitEditor) editorPart;
              compilationUnit =
                  manager.getWorkingCopy(targetCompilationUnitEditor
                      .getEditorInput());
              ASTParser parser = ASTParser.newParser(AST.JLS3);
              parser.setKind(ASTParser.K_COMPILATION_UNIT);
              parser.setSource(compilationUnit);
              final CompilationUnit rootCompilationUnit =
                  (CompilationUnit) parser.createAST(null);
            }
          }
        }
      }
      return targetCompilationUnitEditor;
    } catch (PartInitException e) {
      throw new ExecutionException("Could not open editor", e);
    }
  }