use of org.eclipse.search.ui.text.Match in project eclipse.platform.text by eclipse.
the class LineElement method getNumberOfMatches.
public int getNumberOfMatches(AbstractTextSearchResult result) {
int count = 0;
Match[] matches = result.getMatches(fParent);
for (Match match : matches) {
FileMatch curr = (FileMatch) match;
if (curr.getLineElement() == this) {
count++;
}
}
return count;
}
use of org.eclipse.search.ui.text.Match in project eclipse.platform.text by eclipse.
the class ReplaceRefactoring method collectMatches.
private void collectMatches(Object object) throws CoreException {
if (object instanceof LineElement) {
LineElement lineElement = (LineElement) object;
FileMatch[] matches = lineElement.getMatches(fResult);
for (FileMatch fileMatch : matches) {
if (isMatchToBeIncluded(fileMatch)) {
getBucket(fileMatch.getFile()).add(fileMatch);
}
}
} else if (object instanceof IContainer) {
IContainer container = (IContainer) object;
IResource[] members = container.members();
for (IResource member : members) {
collectMatches(member);
}
} else if (object instanceof IFile) {
Match[] matches = fResult.getMatches(object);
if (matches.length > 0) {
Collection<FileMatch> bucket = null;
for (Match match : matches) {
FileMatch fileMatch = (FileMatch) match;
if (isMatchToBeIncluded(fileMatch)) {
if (bucket == null) {
bucket = getBucket((IFile) object);
}
bucket.add(fileMatch);
}
}
}
}
}
use of org.eclipse.search.ui.text.Match in project eclipse.platform.text by eclipse.
the class AnnotationHighlighter method addHighlights.
@Override
public void addHighlights(Match[] matches) {
HashMap<Annotation, Position> map = new HashMap<>(matches.length);
for (Match match : matches) {
int offset = match.getOffset();
int length = match.getLength();
if (offset >= 0 && length >= 0) {
Position position = createPosition(match);
if (position != null) {
Annotation annotation = match.isFiltered() ? new Annotation(SearchPlugin.FILTERED_SEARCH_ANNOTATION_TYPE, true, null) : new Annotation(SearchPlugin.SEARCH_ANNOTATION_TYPE, true, null);
fMatchesToAnnotations.put(match, annotation);
map.put(annotation, position);
}
}
}
addAnnotations(map);
}
use of org.eclipse.search.ui.text.Match in project eclipse.platform.text by eclipse.
the class AnnotationHighlighter method removeHighlights.
@Override
public void removeHighlights(Match[] matches) {
HashSet<Annotation> annotations = new HashSet<>(matches.length);
for (Match match : matches) {
Annotation annotation = fMatchesToAnnotations.remove(match);
if (annotation != null) {
annotations.add(annotation);
}
}
removeAnnotations(annotations);
}
use of org.eclipse.search.ui.text.Match in project eclipse.platform.text by eclipse.
the class EditorAccessHighlighter method removeHighlights.
@Override
public void removeHighlights(Match[] matches) {
Map<IAnnotationModel, HashSet<Annotation>> setsByAnnotationModel = new HashMap<>();
for (Match match : matches) {
Annotation annotation = fMatchesToAnnotations.remove(match);
if (annotation != null) {
Set<Annotation> annotations = getSet(setsByAnnotationModel, match);
if (annotations != null)
annotations.add(annotation);
}
}
for (IAnnotationModel model : setsByAnnotationModel.keySet()) {
Set<Annotation> set = setsByAnnotationModel.get(model);
removeAnnotations(model, set);
}
}
Aggregations