use of org.eclipse.search.ui.text.Match in project eclipse.platform.text by eclipse.
the class EditorAccessHighlighter method handleContentReplaced.
@Override
protected void handleContentReplaced(IFileBuffer buffer) {
if (!(buffer instanceof ITextFileBuffer))
return;
IDocument document = null;
ITextFileBuffer textBuffer = (ITextFileBuffer) buffer;
for (Match match : fMatchesToAnnotations.keySet()) {
document = fEditorAcess.getDocument(match);
if (document != null)
break;
}
if (document != null && document.equals(textBuffer.getDocument())) {
Match[] matches = new Match[fMatchesToAnnotations.keySet().size()];
fMatchesToAnnotations.keySet().toArray(matches);
removeAll();
addHighlights(matches);
}
}
use of org.eclipse.search.ui.text.Match 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.Match in project eclipse.platform.text by eclipse.
the class PositionTracker method dirtyStateChanged.
@Override
public void dirtyStateChanged(IFileBuffer buffer, boolean isDirty) {
if (isDirty)
return;
final int[] trackCount = new int[1];
doForExistingMatchesIn(buffer, new IFileBufferMatchOperation() {
@Override
public void run(ITextFileBuffer textBuffer, Match match) {
trackCount[0]++;
Position pos = fMatchesToPositions.get(match);
if (pos != null) {
if (pos.isDeleted()) {
AbstractTextSearchResult result = fMatchesToSearchResults.get(match);
// might be that the containing element has been removed.
if (result != null) {
result.removeMatch(match);
}
untrackPosition(textBuffer, match);
} else {
if (match.getBaseUnit() == Match.UNIT_LINE) {
try {
pos = convertToLinePosition(pos, textBuffer.getDocument());
} catch (BadLocationException e) {
SearchPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, SearchPlugin.getID(), 0, e.getLocalizedMessage(), e));
}
}
match.setOffset(pos.getOffset());
match.setLength(pos.getLength());
}
}
}
});
}
use of org.eclipse.search.ui.text.Match in project eclipse.platform.text by eclipse.
the class PositionTracker method bufferCreated.
// IFileBufferListener implementation ---------------------------------------------------------------------
@Override
public void bufferCreated(IFileBuffer buffer) {
final int[] trackCount = new int[1];
if (!(buffer instanceof ITextFileBuffer))
return;
IPath location = buffer.getLocation();
if (location == null)
return;
IFile file = FileBuffers.getWorkspaceFileAtLocation(location);
if (file == null)
return;
ISearchQuery[] queries = NewSearchUI.getQueries();
for (ISearchQuery query : queries) {
ISearchResult result = query.getSearchResult();
if (result instanceof AbstractTextSearchResult) {
AbstractTextSearchResult textResult = (AbstractTextSearchResult) result;
IFileMatchAdapter adapter = textResult.getFileMatchAdapter();
if (adapter != null) {
Match[] matches = adapter.computeContainedMatches(textResult, file);
for (Match match : matches) {
trackCount[0]++;
trackPosition((AbstractTextSearchResult) result, (ITextFileBuffer) buffer, match);
}
}
}
}
}
use of org.eclipse.search.ui.text.Match in project eclipse.platform.text by eclipse.
the class FileTreeContentProvider method initialize.
private synchronized void initialize(AbstractTextSearchResult result) {
fResult = result;
fChildrenMap = new HashMap<>();
boolean showLineMatches = !((FileSearchQuery) fResult.getQuery()).isFileNameSearch();
if (result != null) {
Object[] elements = result.getElements();
for (Object element : elements) {
if (showLineMatches) {
Match[] matches = result.getMatches(element);
for (Match match : matches) {
insert(((FileMatch) match).getLineElement(), false);
}
} else {
insert(element, false);
}
}
}
}
Aggregations