Exemplo n.º 1
0
 /** Implemented for Handler; this replaces run() which is for actions. */
 public Object execute(ExecutionEvent event) throws ExecutionException {
   if (traceOn) {
     System.out.println("RunAnalyseHandlerBase.execute()..."); // $NON-NLS-1$
   }
   getSelection(event);
   if (traceOn) {
     System.out.println("selection: " + selection); // $NON-NLS-1$
   }
   run();
   AnalysisDropdownHandler.setLastHandledAnalysis(this, selection);
   return null;
 }
Exemplo n.º 2
0
  /**
   * Run the analysis on the current selection (file, container, or multiple-selection)
   *
   * @param monitor progress monitor on which to report progress.
   * @param indent indent amount, in number of spaces, used only for debug printing.
   * @param includes
   * @return true if any errors were found.
   * @throws InterruptedException
   */
  @SuppressWarnings("unchecked")
  // on Iterator
  protected boolean runResources(IProgressMonitor monitor, int indent, List<String> includes)
      throws InterruptedException {
    boolean foundError = false;
    // First, count files so we know how much work to do.
    // note this is number of files of any type, not necessarily number of
    // files that will be analyzed.
    int count = countFilesSelected();

    monitor.beginTask(Messages.RunAnalyseHandlerBase_29, count);
    if (traceOn) {
      System.out.println("RAHB.runResources(): using selection: " + selection); // $NON-NLS-1$
    }
    // Get elements of a possible multiple selection
    IStructuredSelection lastSel = AnalysisDropdownHandler.getInstance().getLastSelection();
    Iterator<IStructuredSelection> iter = lastSel.iterator(); // fix analysis
    // selection
    // bug
    // 327122

    while (iter.hasNext()) {
      if (monitor.isCanceled()) {
        // this is usually caught here while processing
        // multiple-selection of files
        throw new InterruptedException();
      }
      Object obj = iter.next(); // piece of selection
      // It can be a Project, Folder, File, etc...
      if (obj instanceof IAdaptable) {
        // ICElement covers folders and translationunits
        // If fortran file (*.f*) and Photran not installed, ce is null
        // and we ignore it (first) here.
        final ICElement ce = (ICElement) ((IAdaptable) obj).getAdapter(ICElement.class); // cdt40
        if (ce != null) {
          // cdt40
          // IASTTranslationUnit atu = tu.getAST(); not yet
          boolean err = runResource(monitor, ce, indent, includes);
          if (traceOn) {
            System.out.println(
                "Error (err="
                    + err
                    + ")running analysis on "
                    + ce.getResource().getName()); // $NON-NLS-1$ //$NON-NLS-2$
          }
        }
      }
    }
    monitor.done();
    return foundError;
  }