@Override
 public Change createChange(IProgressMonitor pm) throws CoreException, OperationCanceledException {
   SubMonitor sm = SubMonitor.convert(pm, "Creating a change description.", 20);
   try {
     modelChange = new RootChange(context);
     modelChange.perform(pm);
     sm.done();
   } catch (CoreException exception) {
     RefactoringPlugin.log(IStatus.ERROR, exception.getMessage());
     modelChange = null;
     sm.done();
     throw exception;
   }
   return modelChange;
 }
 public RootChange getChange(IProgressMonitor pm) throws CoreException {
   if (modelChange == null) {
     StringBuffer taksBuffer = new StringBuffer("Creating a change description for ");
     taksBuffer.append(context.getLabel());
     SubMonitor sm = SubMonitor.convert(pm, taksBuffer.toString(), 10);
     try {
       createChange(sm);
       sm.done();
     } catch (CoreException exception) {
       sm.done();
       throw exception;
     }
   }
   return modelChange;
 }
Beispiel #3
0
  private void buildFile(
      BuildContext context, List<IBuildParticipant> participants, IProgressMonitor monitor)
      throws CoreException {
    if (CollectionsUtil.isEmpty(participants)) {
      return;
    }

    SubMonitor sub = SubMonitor.convert(monitor, 2 * participants.size());
    for (IBuildParticipant participant : participants) {
      long startTime = System.nanoTime();
      participant.buildFile(context, sub.newChild(1));
      if (traceParticipantsEnabled) {
        double endTime = ((double) System.nanoTime() - startTime) / 1000000;
        IdeLog.logTrace(
            BuildPathCorePlugin.getDefault(),
            MessageFormat.format(
                "Executed build participant ''{0}'' on ''{1}'' in {2} ms.",
                participant.getName(), context.getURI(), endTime),
            IDebugScopes.BUILDER_PARTICIPANTS); // $NON-NLS-1$
      }

      // stop building if it has been canceled
      if (sub.isCanceled()) {
        break;
      }
    }
    updateMarkers(context, sub.newChild(participants.size()));
    sub.done();
  }
Beispiel #4
0
  @Override
  protected void clean(IProgressMonitor monitor) throws CoreException {
    super.clean(monitor);

    IProject project = getProjectHandle();

    IBuildParticipantManager manager = getBuildParticipantManager();
    if (manager == null) {
      return;
    }
    List<IBuildParticipant> participants = manager.getAllBuildParticipants();
    participants = filterToEnabled(participants, project);

    SubMonitor sub = SubMonitor.convert(monitor, participants.size() + 2);
    sub.worked(1);

    removeProblemsAndTasksFor(project);
    sub.worked(1);

    // FIXME Should we visit all files and call "deleteFile" sort of like what we do with fullBuild?
    for (IBuildParticipant participant : participants) {
      if (sub.isCanceled()) {
        return;
      }

      participant.clean(project, sub.newChild(1));
    }
    sub.done();
  }
Beispiel #5
0
 private void compileFiles(BuildContext[] contexts, IProgressMonitor monitor)
     throws CoreException {
   SubMonitor sub =
       SubMonitor.convert(monitor, "Analyzing Files...", fParticipants.length + contexts.length);
   if (fParticipants != null) {
     for (int i = 0; i < fParticipants.length; i++) {
       if (monitor.isCanceled()) throw new OperationCanceledException();
       try {
         long start = System.currentTimeMillis();
         fParticipants[i].buildStarting(contexts, true, sub.newChild(1));
         if (RubyBuilder.DEBUG)
           System.out.println(
               fParticipants[i].getClass().getSimpleName()
                   + " took "
                   + (System.currentTimeMillis() - start)
                   + "ms");
       } catch (Exception e) {
         RubyCore.log(e);
       }
     }
   }
   for (int i = 0; i < contexts.length; i++) {
     CategorizedProblem[] problems = contexts[i].getProblems();
     if (problems == null || problems.length == 0) {
       sub.worked(1);
       continue;
     }
     for (int j = 0; j < problems.length; j++) {
       markerManager.addProblem(contexts[i].getFile(), problems[j]);
     }
     sub.worked(1);
   }
   sub.done();
 }
 /* (non-Javadoc)
  * @see com.siteview.mde.internal.core.target.impl.AbstractBundleContainer#resolveBundles(com.siteview.mde.internal.core.target.provisional.ITargetDefinition, org.eclipse.core.runtime.IProgressMonitor)
  */
 protected IResolvedBundle[] resolveBundles(ITargetDefinition definition, IProgressMonitor monitor)
     throws CoreException {
   File dir = getDirectory();
   if (dir.isDirectory()) {
     File site = getSite(dir);
     File[] files = site.listFiles();
     SubMonitor localMonitor =
         SubMonitor.convert(monitor, Messages.DirectoryBundleContainer_0, files.length);
     List bundles = new ArrayList(files.length);
     for (int i = 0; i < files.length; i++) {
       if (localMonitor.isCanceled()) {
         return new IResolvedBundle[0];
       }
       try {
         IResolvedBundle rb = generateBundle(files[i]);
         if (rb != null) {
           bundles.add(rb);
         }
       } catch (CoreException e) {
         // ignore invalid bundles
       }
       localMonitor.worked(1);
     }
     localMonitor.done();
     return (IResolvedBundle[]) bundles.toArray(new IResolvedBundle[bundles.size()]);
   }
   throw new CoreException(
       new Status(
           IStatus.ERROR,
           MDECore.PLUGIN_ID,
           NLS.bind(Messages.DirectoryBundleContainer_1, dir.toString())));
 }
  /**
   * Performs a git clone to a temporary location and then copies the files over top the already
   * generated project. This is because git cannot clone into an existing directory.
   *
   * @param monitor
   * @throws Exception
   */
  protected void cloneAfter(IProgressMonitor monitor) throws Exception {
    SubMonitor sub =
        SubMonitor.convert(monitor, Messages.AbstractNewProjectWizard_CloningFromGitMsg, 100);
    // clone to tmp dir then copy files over top the project!
    File tmpFile = File.createTempFile("delete_me", "tmp"); // $NON-NLS-1$ //$NON-NLS-2$
    File dest = new File(tmpFile.getParent(), "git_clone_tmp"); // $NON-NLS-1$
    GitExecutable.instance()
        .clone(
            selectedTemplate.getLocation(),
            Path.fromOSString(dest.getAbsolutePath()),
            true,
            sub.newChild(85));

    IFileStore tmpClone = EFS.getStore(dest.toURI());
    // Wipe the .git folder before copying? Wipe the .project file before copying?
    IFileStore dotGit = tmpClone.getChild(".git"); // $NON-NLS-1$
    dotGit.delete(EFS.NONE, sub.newChild(2));

    IFileStore dotProject = tmpClone.getChild(IProjectDescription.DESCRIPTION_FILE_NAME);
    if (dotProject.fetchInfo().exists()) {
      dotProject.delete(EFS.NONE, sub.newChild(1));
    }
    // OK, copy the cloned template's contents over
    IFileStore projectStore = EFS.getStore(newProject.getLocationURI());
    tmpClone.copy(projectStore, EFS.OVERWRITE, sub.newChild(9));
    // Now get rid of the temp clone!
    tmpClone.delete(EFS.NONE, sub.newChild(3));
    sub.done();
  }
 private RefactoringStatus validate(IProgressMonitor pm, EObject object) {
   RefactoringStatus refactoringStatus = RefactoringStatus.create(Status.OK_STATUS);
   EValidator.Registry validatorRegistry =
       extensions.getInstance(EValidator.Registry.class, object);
   EPackage epackage = object.eClass().getEPackage();
   EValidator validator = validatorRegistry.getEValidator(epackage);
   BasicDiagnostic diagnostics = new BasicDiagnostic();
   if (pm.isCanceled()) {
     refactoringStatus = RefactoringStatus.create(Status.CANCEL_STATUS);
     pm.done();
   } else {
     SubMonitor sm = SubMonitor.convert(pm, "Validating re-factoring.", IProgressMonitor.UNKNOWN);
     validator.validate(object, diagnostics, Maps.newHashMap());
     Iterator<Diagnostic> validationIterator =
         Iterables.filter(
                 diagnostics.getChildren(),
                 new Predicate<Diagnostic>() {
                   @Override
                   public boolean apply(Diagnostic diagnostic) {
                     if (diagnostic instanceof FeatureBasedDiagnostic) {
                       return FeatureBasedDiagnostic.ERROR
                           == ((FeatureBasedDiagnostic) diagnostic).getSeverity();
                     }
                     return false;
                   }
                 })
             .iterator();
     if (validationIterator.hasNext()) {
       Diagnostic diagnostic = validationIterator.next();
       refactoringStatus = RefactoringStatus.createFatalErrorStatus(diagnostic.getMessage());
     }
     sm.done();
   }
   return refactoringStatus;
 }
  /**
   * Process all metadata files via the metadata reader returned by createMetadataReader
   *
   * @param monitor
   * @param reader
   * @param resources
   */
  private void loadMetadata(IProgressMonitor monitor, T reader, String... resources) {
    SubMonitor subMonitor = SubMonitor.convert(monitor, resources.length);

    for (String resource : resources) {
      URL url = FileLocator.find(this.getBundle(), new Path(resource), null);

      if (url != null) {
        InputStream stream = null;

        try {
          stream = url.openStream();

          reader.loadXML(stream, url.toString());
        } catch (Throwable t) {
          IdeLog.logError(
              CommonEditorPlugin.getDefault(),
              Messages.MetadataLoader_Error_Loading_Metadata + resource,
              t);
        } finally {
          if (stream != null) {
            try {
              stream.close();
            } catch (IOException e) {
            }
          }
        }
      }

      subMonitor.worked(1);
    }

    subMonitor.done();
  }
  /** This method is extremely expensive. */
  @OnEclipseVersionUpgrade("Replace monitor.newChild(1) by monitor.split(1)")
  private boolean isMethodUsedInItsPackage(IMethodBinding methodBinding, MethodDeclaration node) {
    final IPackageBinding methodPackage = methodBinding.getDeclaringClass().getPackage();

    final AtomicBoolean methodIsUsedInPackage = new AtomicBoolean(false);
    final SearchRequestor requestor =
        new SearchRequestor() {
          @Override
          public void acceptSearchMatch(SearchMatch match) {
            methodIsUsedInPackage.set(true);
          }
        };

    final SubMonitor subMonitor = SubMonitor.convert(ctx.getProgressMonitor(), 1);
    final SubMonitor childMonitor = subMonitor.newChild(1);
    try {
      final SearchEngine searchEngine = new SearchEngine();
      searchEngine.search(
          createPattern(methodBinding.getJavaElement(), REFERENCES, R_EXACT_MATCH),
          new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()},
          SearchEngine.createJavaSearchScope(new IJavaElement[] {methodPackage.getJavaElement()}),
          requestor,
          childMonitor);
      return methodIsUsedInPackage.get();
    } catch (CoreException e) {
      throw new UnhandledException(node, e);
    } finally {
      childMonitor.done();
    }
  }
  @Override
  public List<Object> computeContext(
      IInteractionContext context, IAdaptable input, IProgressMonitor monitor) {
    if (delegates == null || delegates.isEmpty()) {
      return Collections.emptyList();
    }
    List<Object> objects = new ArrayList<Object>();

    SubMonitor progress = SubMonitor.convert(monitor);
    int workPerDelegate = 1000;
    progress.beginTask(
        Messages.CompoundContextComputationStrategy_Computing_Context_Task_Label,
        delegates.size() * workPerDelegate);
    try {
      for (ContextComputationStrategy delegate : delegates) {
        if (progress.isCanceled()) {
          break;
        }
        objects.addAll(delegate.computeContext(context, input, progress.newChild(workPerDelegate)));
      }
    } finally {
      progress.done();
    }

    return objects;
  }
Beispiel #12
0
  private void doBuildFiles(
      List<IBuildParticipant> participants, Collection<IFile> files, IProgressMonitor monitor)
      throws CoreException {
    if (CollectionsUtil.isEmpty(files)) {
      return;
    }

    SubMonitor sub = SubMonitor.convert(monitor, 15 * files.size());
    for (IFile file : files) {
      BuildContext context = new BuildContext(file);
      sub.worked(1);

      IBuildParticipantManager manager = getBuildParticipantManager();
      if (manager == null) {
        return;
      }
      List<IBuildParticipant> filteredParticipants =
          manager.filterParticipants(participants, context.getContentType());
      sub.worked(2);

      buildFile(context, filteredParticipants, sub.newChild(12));

      // stop building if canceled
      if (sub.isCanceled()) {
        break;
      }
    }
    sub.done();
  }
Beispiel #13
0
 /**
  * Run a refresh synchronously. FIXME Should this even be visible to callers? We should pick up
  * file events via watcher to refresh whenever we really need to. This should become default
  * visibility.
  *
  * @param monitor
  * @return
  */
 public IStatus refresh(IProgressMonitor monitor) {
   SubMonitor sub = SubMonitor.convert(monitor, 100);
   try {
     return refresh(true, null, sub.newChild(100));
   } finally {
     sub.done();
   }
 }
Beispiel #14
0
 private void notifyParticipants(IProgressMonitor monitor) {
   SubMonitor sub =
       SubMonitor.convert(monitor, "Notifying build participants", fParticipants.length);
   for (int i = 0; i < fParticipants.length; i++) {
     fParticipants[i].aboutToBuild(fRubyProject);
     sub.worked(1);
   }
   sub.done();
 }
  @Override
  public RefactoringStatus checkInitialConditions(final IProgressMonitor monitor)
      throws CoreException {
    final SubMonitor progress = SubMonitor.convert(monitor, 6);
    try {
      if (fSelectionRegion != null) {
        fSourceUnit.connect(progress.newChild(1));
        try {
          final AbstractDocument document = fSourceUnit.getDocument(monitor);

          final IRModelInfo modelInfo =
              (IRModelInfo)
                  fSourceUnit.getModelInfo(
                      RModel.TYPE_ID, IRModelManager.MODEL_FILE, progress.newChild(1));
          if (modelInfo != null) {
            final IRegion region = fAdapter.trimToAstRegion(document, fSelectionRegion);
            ISourceStructElement element =
                LTKUtil.getCoveringSourceElement(modelInfo.getSourceElement(), region);
            while (element != null) {
              if (element instanceof IRMethod) {
                fFunction = (IRMethod) element;
                break;
              }
              element = element.getSourceParent();
            }
          }

          if (fFunction != null) {
            final ISourceStructElement source = (ISourceStructElement) fFunction;
            fOperationRegion =
                fAdapter.expandSelectionRegion(document, source.getSourceRange(), fSelectionRegion);
          }
        } finally {
          fSourceUnit.disconnect(progress.newChild(1));
        }
      }

      if (fFunction == null) {
        return RefactoringStatus.createFatalErrorStatus(
            Messages.FunctionToS4Method_error_InvalidSelection_message);
      }
      final RefactoringStatus result = new RefactoringStatus();
      fAdapter.checkInitialForModification(result, fElementSet);
      progress.worked(1);

      if (result.hasFatalError()) {
        return result;
      }

      checkFunction(result);
      progress.worked(2);
      return result;
    } finally {
      progress.done();
    }
  }
Beispiel #16
0
 private void buildEnding(List<IBuildParticipant> participants, IProgressMonitor monitor) {
   if (participants == null) {
     return;
   }
   SubMonitor sub = SubMonitor.convert(monitor, participants.size());
   for (IBuildParticipant participant : participants) {
     participant.buildEnding(sub.newChild(1));
   }
   sub.done();
 }
  @Override
  public RefactoringStatus checkInitialConditions(final IProgressMonitor monitor)
      throws CoreException {
    final SubMonitor progress = SubMonitor.convert(monitor, 6);
    RAstNode rootNode = null;
    try {
      if (fSelectionRegion != null) {
        fSourceUnit.connect(progress.newChild(1));
        try {
          final AbstractDocument document = fSourceUnit.getDocument(monitor);
          final RHeuristicTokenScanner scanner = fAdapter.getScanner(fSourceUnit);

          final IRModelInfo modelInfo =
              (IRModelInfo)
                  fSourceUnit.getModelInfo(
                      RModel.TYPE_ID, IRModelManager.MODEL_FILE, progress.newChild(1));
          if (modelInfo != null) {
            final IRegion region = fAdapter.trimToAstRegion(document, fSelectionRegion, scanner);
            final AstInfo ast = modelInfo.getAst();
            if (ast != null) {
              rootNode =
                  (RAstNode)
                      AstSelection.search(
                              ast.root,
                              region.getOffset(),
                              region.getOffset() + region.getLength(),
                              AstSelection.MODE_COVERING_SAME_LAST)
                          .getCovering();
            }
          }
        } finally {
          fSourceUnit.disconnect(progress.newChild(1));
        }
      }

      if (rootNode == null) {
        return RefactoringStatus.createFatalErrorStatus(
            Messages.ExtractTemp_error_InvalidSelection_message);
      }
      final RefactoringStatus result = new RefactoringStatus();
      fAdapter.checkInitialToModify(result, fElementSet);
      progress.worked(1);

      if (result.hasFatalError()) {
        return result;
      }

      searchVariables(rootNode, result);
      progress.worked(2);
      return result;
    } finally {
      progress.done();
    }
  }
Beispiel #18
0
 private void buildStarting(
     List<IBuildParticipant> participants, int kind, IProgressMonitor monitor) {
   if (CollectionsUtil.isEmpty(participants)) {
     return;
   }
   SubMonitor sub = SubMonitor.convert(monitor, participants.size());
   for (IBuildParticipant participant : participants) {
     participant.buildStarting(getProjectHandle(), kind, sub.newChild(1));
   }
   sub.done();
 }
Beispiel #19
0
  private void deleteFile(
      BuildContext context, List<IBuildParticipant> participants, IProgressMonitor monitor) {
    if (CollectionsUtil.isEmpty(participants)) {
      return;
    }

    SubMonitor sub = SubMonitor.convert(monitor, participants.size());
    for (IBuildParticipant participant : participants) {
      participant.deleteFile(context, sub.newChild(1));
    }
    sub.done();
  }
 @Override
 public RefactoringStatus checkFinalConditions(final IProgressMonitor monitor)
     throws CoreException {
   final SubMonitor progress =
       SubMonitor.convert(monitor, RefactoringMessages.Common_FinalCheck_label, 100);
   try {
     final RefactoringStatus status = checkFunctionName(fFunctionName);
     fAdapter.checkFinalForModification(status, fElementSet, progress.newChild(2));
     return status;
   } finally {
     progress.done();
   }
 }
 public IStatus getArtifacts(IArtifactRequest[] requests, IProgressMonitor monitor) {
   SubMonitor subMonitor = SubMonitor.convert(monitor, requests.length);
   try {
     MultiStatus overallStatus =
         new MultiStatus(TestActivator.PI_PROV_TESTS, IStatus.OK, null, null);
     for (int i = 0; i < requests.length; i++) {
       overallStatus.add(getArtifact((ArtifactRequest) requests[i], subMonitor.newChild(1)));
     }
     return (monitor.isCanceled() ? Status.CANCEL_STATUS : overallStatus);
   } finally {
     subMonitor.done();
   }
 }
 @Override
 protected void execute(final IProgressMonitor monitor)
     throws CoreException, InvocationTargetException, InterruptedException {
   SubMonitor subMonitor = SubMonitor.convert(monitor, getCreateModelProjectMessage(), 2);
   try {
     final IProject project = createProject(subMonitor.newChild(1));
     if (project == null) return;
     enhanceProject(project, subMonitor.newChild(1));
     IFile modelFile = getModelFile(project);
     setResult(modelFile);
   } finally {
     subMonitor.done();
   }
 }
Beispiel #23
0
 private void addMarkers(
     Collection<IProblem> items, String markerType, IFile file, IProgressMonitor monitor)
     throws CoreException {
   if (CollectionsUtil.isEmpty(items)) {
     return;
   }
   SubMonitor sub = SubMonitor.convert(monitor, items.size() * 2);
   for (IProblem item : items) {
     IMarker marker = file.createMarker(markerType);
     sub.worked(1);
     marker.setAttributes(item.createMarkerAttributes());
     sub.worked(1);
   }
   sub.done();
 }
Beispiel #24
0
  private IStatus rebuildIndexCompletely(SubMonitor monitor)
      throws CorruptIndexException, LockObtainFailedException, IOException, CoreException {

    MultiStatus multiStatus = new MultiStatus(TasksIndexCore.ID_PLUGIN, 0, null, null);

    // get indexable tasks from the task list
    final TaskListState taskListState = new TaskListState();
    taskList.run(taskListState, monitor.newChild(0));

    monitor.beginTask(
        Messages.TaskListIndex_task_rebuilding_index, taskListState.indexableTasks.size());
    try {
      IndexWriter writer;
      try {
        writer = createIndexWriter(true);
      } catch (CorruptIndexException e) {
        if (directory instanceof FSDirectory) {
          cleanDirectory(((FSDirectory) directory).getFile());
          writer = createIndexWriter(true);
        } else {
          throw e;
        }
      }
      try {

        for (ITask task : taskListState.indexableTasks) {
          if (taskIsIndexable(task, null)) {
            try {
              TaskData taskData = dataManager.getTaskData(task);
              add(writer, task, taskData);
            } catch (CoreException e) {
              // an individual task data error should not prevent the index from updating
              multiStatus.add(e.getStatus());
            }
          }
          monitor.worked(1);
        }
        synchronized (this) {
          rebuildIndex = false;
        }
      } finally {
        writer.close();
      }
    } finally {
      monitor.done();
    }
    return multiStatus;
  }
Beispiel #25
0
  private void buildFiles(
      List<IBuildParticipant> participants, Collection<IFile> files, IProgressMonitor monitor)
      throws CoreException {
    if (CollectionsUtil.isEmpty(participants) || CollectionsUtil.isEmpty(files)) {
      return;
    }
    SubMonitor sub = SubMonitor.convert(monitor, 100);

    // Filter
    files = filterFiles(files, sub.newChild(10));

    // Then build
    doBuildFiles(participants, files, sub.newChild(90));

    sub.done();
  }
 @Override
 public RefactoringStatus checkInitialConditions(IProgressMonitor pm)
     throws CoreException, OperationCanceledException {
   RefactoringStatus refactoringStatus = RefactoringStatus.create(Status.OK_STATUS);
   SubMonitor sm =
       SubMonitor.convert(
           pm,
           new StringBuffer("Checking initial conditions for ")
               .append(context.getLabel())
               .toString(),
           10);
   EObject element = context.getSourceElement();
   EObject container = EcoreUtil.getRootContainer(element);
   refactoringStatus =
       sm.isCanceled() ? RefactoringStatus.create(Status.CANCEL_STATUS) : validate(sm, container);
   sm.done();
   return refactoringStatus;
 }
Beispiel #27
0
  private void maintainIndex(IProgressMonitor m) throws CoreException {
    final int WORK_PER_SEGMENT = 1000;
    SubMonitor monitor = SubMonitor.convert(m, 2 * WORK_PER_SEGMENT);
    try {
      try {
        if (!rebuildIndex) {
          try {
            IndexReader reader = IndexReader.open(directory, false);
            reader.close();
          } catch (CorruptIndexException e) {
            rebuildIndex = true;
          }
        }

        if (rebuildIndex) {
          synchronized (reindexQueue) {
            reindexQueue.clear();
          }

          IStatus status = rebuildIndexCompletely(monitor.newChild(WORK_PER_SEGMENT));
          if (!status.isOK()) {
            StatusHandler.log(status);
          }
        } else {
          monitor.worked(WORK_PER_SEGMENT);
        }

        // index any tasks that have been changed
        indexQueuedTasks(monitor.newChild(WORK_PER_SEGMENT));

        // prevent new searches from reading the now-stale index
        closeIndexReader();
      } catch (IOException e) {
        throw new CoreException(
            new Status(
                IStatus.ERROR,
                TasksIndexCore.ID_PLUGIN,
                "Unexpected exception: " + e.getMessage(),
                e)); //$NON-NLS-1$
      }
    } finally {
      monitor.done();
    }
  }
 private IStatus computeAllRemediations(IProgressMonitor monitor) {
   SubMonitor sub = SubMonitor.convert(monitor, remedyConfigs.length);
   sub.setTaskName(Messages.RemediationOperation_ProfileChangeRequestProgress);
   List<Remedy> tmpRemedies = new ArrayList<Remedy>(remedyConfigs.length);
   try {
     for (int i = 0; i < remedyConfigs.length; i++) {
       sub.subTask((i + 1) + " / " + remedyConfigs.length); // $NON-NLS-1$
       if (sub.isCanceled()) return Status.CANCEL_STATUS;
       Remedy remedy =
           computeRemedy(remedyConfigs[i], sub.newChild(1, SubMonitor.SUPPRESS_ALL_LABELS));
       if (remedy != null) {
         tmpRemedies.add(remedy);
       }
     }
   } finally {
     sub.done();
   }
   remedies = tmpRemedies;
   return getResolutionResult();
 }
 /** {@inheritDoc} */
 @Override
 public void run(final IMarker[] markers, final IProgressMonitor monitor) {
   if (markers == null) {
     return;
   }
   final ResourceSet set = ScaResourceFactoryUtil.createResourceSet();
   final Collection<Resource> editedResources = new HashSet<Resource>();
   final SubMonitor subMonitor = SubMonitor.convert(monitor, "Adding event port.", 100);
   try {
     final SubMonitor markerLoopMonitor =
         subMonitor.newChild(70).setWorkRemaining(markers.length); // SUPPRESS
     // CHECKSTYLE
     // MagicNumber
     for (final IMarker marker : markers) {
       final String uri = marker.getAttribute(EValidator.URI_ATTRIBUTE, null);
       if (uri != null) {
         final EObject obj = set.getEObject(URI.createURI(uri), true);
         if (obj instanceof SoftPkg) {
           final SoftPkg spd = (SoftPkg) obj;
           try {
             editedResources.addAll(addEventPort(spd));
           } catch (final CoreException e) {
             StatusManager.getManager()
                 .handle(
                     new Status(
                         e.getStatus().getSeverity(),
                         ComponentUiPlugin.PLUGIN_ID,
                         e.getLocalizedMessage(),
                         e),
                     StatusManager.SHOW | StatusManager.LOG);
             return;
           }
         }
       }
       markerLoopMonitor.worked(1);
     }
     save(editedResources, subMonitor.newChild(30));
   } finally {
     subMonitor.done();
   }
 }
  public IS2ProjectValidationStatus validate(IUrlLocation location, IProgressMonitor monitor) {
    if (!accept(location)) {
      throw new IllegalArgumentException(
          "ScmAccessValidator.validate() was called for a location that is not an SCM location.");
    }

    IScmLocation scmLocation = (IScmLocation) location;
    String scmUrl = scmLocation.getUrl();
    IAuthData authData = AuthFacade.getAuthService().select(scmUrl);
    IStatus status = validateAuthData(authData);
    if (status.isOK()) {
      IScmAccessData scmData = new ScmAccessData(scmUrl, scmLocation.getBranch(), "HEAD", authData);

      IScmAccessValidator validator = getValidator(scmData);
      log.debug("Validating SCM access to {} with {}", scmData.getRepositoryUrl(), validator);

      if (validator == null) {
        status =
            new Status(
                IStatus.ERROR,
                S2ProjectValidationPlugin.PLUGIN_ID,
                "SCM provider is not available for " + scmData.getRepositoryUrl());
        monitor.worked(1);
      } else {
        SubMonitor subprogress = SubMonitor.convert(monitor, 1);
        status = validator.validate(scmData, subprogress);
        subprogress.done();
      }
    } else {
      monitor.worked(1);
    }

    if (status != null && status.getException() != null) {
      log.debug(
          "Validated SCM access to " + scmUrl + " with result " + status, status.getException());
    } else {
      log.debug("Validated SCM access to {} with result {}", scmUrl, status);
    }

    return wrapStatus(status, scmLocation);
  }