コード例 #1
0
 /**
  * Runs an artifact analysis for the given file by searching the given extension point for an
  * {@link IArtifactAnalysis} that matches its language ID.
  *
  * <p>This is a utility method generally invoked from {@link #doArtifactAnalysis(ITranslationUnit,
  * List)}.
  *
  * <p>It is assumed that only one extension will be contributed per language ID. If multiple
  * extensions are found, it is unspecified which one will be run.
  *
  * @param extensionPointID
  * @param tu
  * @param includes
  * @param allowPrefixOnlyMatch
  * @return {@link ScanReturn}
  * @since 6.0
  */
 protected ScanReturn runArtifactAnalysisFromExtensionPoint(
     String extensionPointID,
     final ITranslationUnit tu,
     final List<String> includes,
     final boolean allowPrefixOnlyMatch) {
   try {
     final String languageID = tu.getLanguage().getId();
     for (IConfigurationElement config :
         Platform.getExtensionRegistry().getConfigurationElementsFor(extensionPointID)) {
       try {
         if (languageID.equals(config.getAttribute("languageID"))) {
           IArtifactAnalysis artifactAnalysis =
               (IArtifactAnalysis) config.createExecutableExtension("class"); // $NON-NLS-1$
           return artifactAnalysis.runArtifactAnalysis(
               languageID, tu, includes, allowPrefixOnlyMatch);
         }
       } catch (CoreException e) {
         CommonPlugin.log(e.getClass().getSimpleName() + ": " + e.getMessage());
       }
     }
   } catch (CoreException e) {
     e.printStackTrace();
     CommonPlugin.log(
         IStatus.ERROR,
         "RunAnalyseMPICommandHandler: Error setting up analysis for project "
             + tu.getCProject()
             + " error="
             + e.getMessage()); // $NON-NLS-1$ //$NON-NLS-2$
   }
   return new ScanReturn();
 }
コード例 #2
0
 /**
  * Show something in the status line; this is used when we don't have easy access to the view for
  * getting the StatusLineManager.
  *
  * @param message
  * @param debugMessage
  */
 private void showStatusMessage(String message, String debugMessage) {
   if (false) {
     message += " - "; // $NON-NLS-1$
     message += debugMessage;
   }
   IWorkbenchWindow ww = CommonPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
   IWorkbenchPage page = ww.getActivePage();
   IViewReference[] viewRefs = page.getViewReferences();
   for (int j = 0; j < viewRefs.length; j++) {
     IViewReference reference = viewRefs[j];
     IViewPart vp = reference.getView(false);
     if (vp != null) {
       vp.getViewSite().getActionBars().getStatusLineManager().setMessage(message);
     }
   }
 }
コード例 #3
0
  /**
   * Constructor for the "Run Analysis" action
   *
   * @param name the type of artifact e.g. "MPI" or "OpenMP"
   * @param visitor the visitor that will put the markers on the source files
   * @param markerID marker ID
   */
  public RunAnalyseHandlerBase(String name, ArtifactMarkingVisitor visitor, String markerID) {
    this.name = name;
    this.visitor = visitor;
    this.markerID = markerID;

    traceOn = CommonPlugin.getTraceOn();
    if (traceOn) {
      System.out.println("RunAnalyseBase.ctor: traceOn=" + traceOn); // $NON-NLS-1$
    }

    // get the navigator, project explorer, c/C++ projects view, etc
    // need to get selectionChanged on that, to cache the most recent
    // selection there,
    // otherwise HanderUtil will tell us latest selection including ones we
    // don't want

  }
コード例 #4
0
 /** Read preferences */
 protected void readPreferences() {
   Preferences pref = CommonPlugin.getDefault().getPluginPreferences();
   forceEcho = pref.getBoolean(IDs.P_ECHO_FORCE);
 }
コード例 #5
0
  /**
   * Do the "Run Analysis" on a resource (project, folder, or file). Descends to all child nodes,
   * collecting artifacts on each.
   */
  public void run() {
    if (traceOn) {
      System.out.println("RunAnalyseHandlerBase.run()..."); // $NON-NLS-1$
    }

    cancelledByUser = false;
    err = false;
    cumulativeArtifacts = 0;
    readPreferences();

    final int indent = 0;

    if ((selection == null) || selection.isEmpty()) {
      MessageDialog.openWarning(
          null,
          Messages.RunAnalyseHandlerBase_no_files_selected,
          Messages.RunAnalyseHandlerBase_please_select);

      return;
    } else {
      // get preference for include paths
      final List<String> includes = getIncludePath();
      if (areIncludePathsNeeded() && includes.isEmpty()) {
        // System.out.println("RunAnalyseHandlerBase.run(), no include paths found.");
        MessageDialog.openWarning(
            shell,
            name + Messages.RunAnalyseHandlerBase_include_paths_not_found,
            Messages.RunAnalyseHandlerBase_please_first_specify
                + name
                + Messages.RunAnalyseHandlerBase_incl_paths_in_pref_page);

      } else {

        // batch ws modifications *and* report progress
        WorkspaceModifyOperation wmo =
            new WorkspaceModifyOperation() {
              @Override
              protected void execute(IProgressMonitor monitor)
                  throws CoreException, InvocationTargetException, InterruptedException {
                err = runResources(monitor, indent, includes);
              }
            };
        ProgressMonitorDialog pmdialog = new ProgressMonitorDialog(shell);
        try {
          pmdialog.run(true, true, wmo); // fork=true; if false, not
          // cancelable

        } catch (InvocationTargetException e) {
          err = true;
          Throwable cause = e.getCause();
          System.out.println(
              "Error running analysis: ITE: " //$NON-NLS-1$
                  + e.getMessage());
          System.out.println(
              "  cause: "
                  + cause
                  + " - " //$NON-NLS-1$ //$NON-NLS-2$
                  + cause.getMessage());

          cause.printStackTrace();
        } catch (InterruptedException e) {
          cancelledByUser = true;
        }
      } // end else
    }
    if (traceOn) {
      System.out.println(
          "RunAnalyseBase: retd from run iterator, err=" //$NON-NLS-1$
              + err);
    }
    String artsFound =
        "\nNumber of "
            + name
            + " Artifacts found: " //$NON-NLS-1$ //$NON-NLS-2$
            + cumulativeArtifacts;
    if (cancelledByUser) {
      MessageDialog.openInformation(
          null,
          Messages.RunAnalyseHandlerBase_partial_analysis_complete,
          Messages.RunAnalyseHandlerBase_15 + artsFound);
    } else {
      String msg = Messages.RunAnalyseHandlerBase_cancelled_by_user;
      if (!err) {
        String key = IDs.SHOW_ANALYSIS_CONFIRMATION;
        IPreferenceStore pf = CommonPlugin.getDefault().getPreferenceStore();
        boolean showDialog = pf.getBoolean(IDs.SHOW_ANALYSIS_CONFIRMATION);
        if (showDialog) {
          String title = Messages.RunAnalyseHandlerBase_analysis_complete;
          StringBuffer sMsg =
              new StringBuffer(
                  cumulativeArtifacts
                      + " "
                      + name //$NON-NLS-1$
                      + Messages.RunAnalyseHandlerBase_artifacts_found);
          // provide some explanation of why perhaps no artifacts were
          // found.
          // Note: should this perhaps be in a "Details" section of
          // the dialog?
          if (cumulativeArtifacts == 0) {
            // Unless "Recognize artifacts by prefix alone" is set in the preferences (this is the
            // default),
            // this could be a problem with the include file for this API.
            sMsg.append(Messages.RunAnalyseHandlerBase_notfound_0)
                .append(name)
                .append(Messages.RunAnalyseHandlerBase_notfound_1);
            sMsg.append(name).append(Messages.RunAnalyseHandlerBase_notfound_2);
            sMsg.append(Messages.RunAnalyseHandlerBase_notfound_3);
          }
          String togMsg = Messages.RunAnalyseHandlerBase_dont_show_this_again;
          MessageDialogWithToggle.openInformation(
              shell, title, sMsg.toString(), togMsg, false, pf, key);
          showStatusMessage(sMsg.toString(), "RunAnalyseBase.run()"); // $NON-NLS-1$
        }
        activateProblemsView();
        activateArtifactView();
      } else { // error occurred
        showStatusMessage(msg, "RunAnalyseBase.run() error"); // $NON-NLS-1$
        msg = Messages.RunAnalyseHandlerBase_27;
        MessageDialog.openError(null, Messages.RunAnalyseHandlerBase_28, msg + artsFound);
      }
    }
  }