use of org.eclipse.search.ui.text.IEditorMatchAdapter in project eclipse.platform.text by eclipse.
the class EditorAnnotationManager method addAnnotations.
private void addAnnotations(AbstractTextSearchResult result) {
IEditorMatchAdapter matchAdapter = result.getEditorMatchAdapter();
if (matchAdapter == null)
return;
Match[] matches = matchAdapter.computeContainedMatches(result, fEditor);
if (matches == null || matches.length == 0)
return;
addAnnotations(matches);
}
use of org.eclipse.search.ui.text.IEditorMatchAdapter in project eclipse.platform.text by eclipse.
the class EditorAnnotationManager method getMatchesInEditor.
private Match[] getMatchesInEditor(Match[] matches, AbstractTextSearchResult result) {
IEditorMatchAdapter adapter = result.getEditorMatchAdapter();
if (adapter == null) {
return null;
}
// optimize the array-length == 1 case (most common)
if (matches.length == 1) {
return adapter.isShownInEditor(matches[0], fEditor) ? matches : null;
}
// lazy initialization
ArrayList<Match> matchesInEditor = null;
for (Match curr : matches) {
if (adapter.isShownInEditor(curr, fEditor)) {
if (matchesInEditor == null) {
matchesInEditor = new ArrayList<>();
}
matchesInEditor.add(curr);
}
}
if (matchesInEditor != null) {
return matchesInEditor.toArray(new Match[matchesInEditor.size()]);
}
return null;
}
Aggregations