use of org.eclipse.search.ui.text.AbstractTextSearchResult in project eclipse.platform.text by eclipse.
the class RemoveMatchAction method run.
@Override
public void run() {
Match match = fPage.getCurrentMatch();
AbstractTextSearchResult result = fPage.getInput();
if (match != null && result != null)
result.removeMatch(match);
}
use of org.eclipse.search.ui.text.AbstractTextSearchResult in project eclipse.platform.text by eclipse.
the class PositionTracker method queryRemoved.
@Override
public void queryRemoved(ISearchQuery query) {
ISearchResult result = query.getSearchResult();
if (result instanceof AbstractTextSearchResult) {
untrackAll((AbstractTextSearchResult) result);
result.removeListener(this);
}
}
use of org.eclipse.search.ui.text.AbstractTextSearchResult 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.AbstractTextSearchResult in project eclipse.platform.text by eclipse.
the class PositionTracker method getCurrentPosition.
public Position getCurrentPosition(Match match) {
Position pos = fMatchesToPositions.get(match);
if (pos == null)
return pos;
AbstractTextSearchResult result = fMatchesToSearchResults.get(match);
if (match.getBaseUnit() == Match.UNIT_LINE && result != null) {
ITextFileBuffer fb = getTrackedFileBuffer(result, match.getElement());
if (fb != null) {
IDocument doc = fb.getDocument();
try {
pos = convertToLinePosition(pos, doc);
} catch (BadLocationException e) {
}
}
}
return pos;
}
use of org.eclipse.search.ui.text.AbstractTextSearchResult 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);
}
}
}
}
}
Aggregations