Ejemplo n.º 1
0
 @Override
 public void acceptSearchMatch(SearchMatch match) throws CoreException {
   if (match.getResource() instanceof IFile && !mFoundFirstMatch) {
     mFoundFirstMatch = true;
     IFile matched_file = (IFile) match.getResource();
     IMarker marker = createMarkerFromSearchMatch(matched_file, match);
     // There should only be one exact match,
     // so we go immediately to that one.
     if (marker != null) {
       switchPerspective();
       openFile(matched_file, marker);
     }
   }
 }
Ejemplo n.º 2
0
  private static boolean existsInNewOccurrences(
      SearchMatch searchResult, SearchResultGroup[] newOccurrences, TextChangeManager manager) {
    SearchResultGroup newGroup = findOccurrenceGroup(searchResult.getResource(), newOccurrences);
    if (newGroup == null) return false;

    IRegion oldEditRange = getCorrespondingEditChangeRange(searchResult, manager);
    if (oldEditRange == null) return false;

    SearchMatch[] newSearchResults = newGroup.getSearchResults();
    int oldRangeOffset = oldEditRange.getOffset();
    for (int i = 0; i < newSearchResults.length; i++) {
      if (newSearchResults[i].getOffset() == oldRangeOffset) return true;
    }
    return false;
  }
 private TextChange canonicalChange(
     CompositeChange composite, Map<IResource, TextChange> changes, SearchMatch match) {
   IResource resource = match.getResource();
   if (resource instanceof IFile) {
     TextChange change = changes.get(resource);
     if (change == null) {
       IFile file = (IFile) resource;
       change = new TextFileChange("Rename", file);
       change.setEdit(new MultiTextEdit());
       changes.put(resource, change);
       composite.add(change);
     }
     return change;
   } else {
     return null;
   }
 }