示例#1
0
  @Override
  public SearchResults find(SearchQuery query, ProgressMonitor monitor) {
    myResults = new SearchResults<SNode>();
    SearchScope queryScope = query.getScope();

    monitor.start("Searching applicable nodes", myScripts.size());
    try {
      for (RefactoringScript scriptInstance : myScripts) {
        if (monitor.isCanceled()) {
          break;
        }
        Collection<AbstractMigrationRefactoring> refactorings = scriptInstance.getRefactorings();
        for (AbstractMigrationRefactoring ref : refactorings) {
          if (monitor.isCanceled()) {
            break;
          }
          monitor.step(scriptInstance.getName() + " [" + ref.getAdditionalInfo() + "]");
          Set<SNode> instances =
              FindUsagesFacade.getInstance()
                  .findInstances(
                      queryScope,
                      Collections.singleton(ref.getApplicableConcept()),
                      false,
                      new EmptyProgressMonitor());
          for (SNode instance : instances) {
            try {
              if (ref.isApplicableInstanceNode(instance)) {
                String category =
                    StringUtil.escapeXml(scriptInstance.getName())
                        + " </b>["
                        + StringUtil.escapeXml(ref.getAdditionalInfo())
                        + "]<b>";
                SearchResult<SNode> result = new SearchResult<SNode>(instance, category);
                myMigrationBySearchResult.put(result, ref);
                myResults.getSearchResults().add(result);
              }
            } catch (Throwable th) {
              if (LOG.isEnabledFor(Level.ERROR)) {
                LOG.error("Failed to evaluate script applicability", th);
              }
            }
          }
        }
        monitor.advance(1);
      }
      fireResultsChanged();
      return myResults;
    } finally {
      monitor.done();
    }
  }
 public MigrationRefactoringAdapter(
     SModuleReference languageReference,
     AbstractMigrationRefactoring refactoring,
     SNodeReference migrationReference) {
   myLanguageReference = languageReference;
   myRefactoring = refactoring;
   myIntentionNodeReference = migrationReference;
   myPresentation = refactoring.getName();
 }
 @Override
 public String getPersistentStateKey() {
   return myRefactoring.getClass().getName();
 }
 @Override
 public boolean isApplicable(SNode node, EditorContext editorContext) {
   return myRefactoring.isApplicableInstanceNode(node);
 }
 @Override
 public String getConcept() {
   return myRefactoring.getFqNameOfConceptToSearchInstances();
 }