Search in sources :

Example 26 with AbstractTextSearchResult

use of org.eclipse.search.ui.text.AbstractTextSearchResult in project eclipse.platform.text by eclipse.

the class FileSearchQuery method run.

@Override
public IStatus run(final IProgressMonitor monitor) {
    AbstractTextSearchResult textResult = (AbstractTextSearchResult) getSearchResult();
    textResult.removeAll();
    Pattern searchPattern = getSearchPattern();
    TextSearchResultCollector collector = new TextSearchResultCollector(textResult, isFileNameSearch(), fSearchInBinaries);
    return TextSearchEngine.create().search(fScope, collector, searchPattern, monitor);
}
Also used : Pattern(java.util.regex.Pattern) AbstractTextSearchResult(org.eclipse.search.ui.text.AbstractTextSearchResult)

Example 27 with AbstractTextSearchResult

use of org.eclipse.search.ui.text.AbstractTextSearchResult in project eclipse.platform.text by eclipse.

the class EditorAnnotationManager method searchResultChanged.

@Override
public synchronized void searchResultChanged(SearchResultEvent e) {
    ISearchResult searchResult = e.getSearchResult();
    if (searchResult instanceof AbstractTextSearchResult) {
        AbstractTextSearchResult result = (AbstractTextSearchResult) searchResult;
        if (e instanceof MatchEvent) {
            MatchEvent me = (MatchEvent) e;
            Match[] matchesInEditor = getMatchesInEditor(me.getMatches(), result);
            if (matchesInEditor != null) {
                if (me.getKind() == MatchEvent.ADDED) {
                    addAnnotations(matchesInEditor);
                } else {
                    removeAnnotations(matchesInEditor);
                }
            }
        } else if (e instanceof RemoveAllEvent) {
            removeAnnotations(result);
        } else if (e instanceof FilterUpdateEvent) {
            Match[] matchesInEditor = getMatchesInEditor(((FilterUpdateEvent) e).getUpdatedMatches(), result);
            if (matchesInEditor != null) {
                removeAnnotations(matchesInEditor);
                addAnnotations(matchesInEditor);
            }
        }
    }
}
Also used : ISearchResult(org.eclipse.search.ui.ISearchResult) RemoveAllEvent(org.eclipse.search.ui.text.RemoveAllEvent) MatchEvent(org.eclipse.search.ui.text.MatchEvent) FilterUpdateEvent(org.eclipse.search.ui.text.FilterUpdateEvent) AbstractTextSearchResult(org.eclipse.search.ui.text.AbstractTextSearchResult) Match(org.eclipse.search.ui.text.Match)

Example 28 with AbstractTextSearchResult

use of org.eclipse.search.ui.text.AbstractTextSearchResult in project eclipse.platform.text by eclipse.

the class EditorAnnotationManager method doEditorInputChanged.

public synchronized void doEditorInputChanged() {
    removeAllAnnotations();
    if (fHighlighter != null) {
        fHighlighter.dispose();
        fHighlighter = null;
    }
    for (int i = 0; i < fResults.size(); i++) {
        AbstractTextSearchResult curr = fResults.get(i);
        addAnnotations(curr);
    }
}
Also used : AbstractTextSearchResult(org.eclipse.search.ui.text.AbstractTextSearchResult)

Example 29 with AbstractTextSearchResult

use of org.eclipse.search.ui.text.AbstractTextSearchResult in project eclipse.platform.text by eclipse.

the class PositionTracker method searchResultChanged.

// tracking matches ---------------------------------------------------------------------
@Override
public void searchResultChanged(SearchResultEvent e) {
    if (e instanceof MatchEvent) {
        MatchEvent evt = (MatchEvent) e;
        Match[] matches = evt.getMatches();
        int kind = evt.getKind();
        AbstractTextSearchResult result = (AbstractTextSearchResult) e.getSearchResult();
        for (Match match : matches) {
            ITextFileBuffer fb = getTrackedFileBuffer(result, match.getElement());
            if (fb != null) {
                updateMatch(match, fb, kind, result);
            }
        }
    } else if (e instanceof RemoveAllEvent) {
        RemoveAllEvent evt = (RemoveAllEvent) e;
        ISearchResult result = evt.getSearchResult();
        untrackAll((AbstractTextSearchResult) result);
    }
}
Also used : RemoveAllEvent(org.eclipse.search.ui.text.RemoveAllEvent) ISearchResult(org.eclipse.search.ui.ISearchResult) MatchEvent(org.eclipse.search.ui.text.MatchEvent) ITextFileBuffer(org.eclipse.core.filebuffers.ITextFileBuffer) AbstractTextSearchResult(org.eclipse.search.ui.text.AbstractTextSearchResult) Match(org.eclipse.search.ui.text.Match)

Example 30 with AbstractTextSearchResult

use of org.eclipse.search.ui.text.AbstractTextSearchResult in project eclipse.platform.text by eclipse.

the class LineBasedFileSearch method run.

@Override
public IStatus run(IProgressMonitor monitor) {
    AbstractTextSearchResult textResult = (AbstractTextSearchResult) getSearchResult();
    textResult.removeAll();
    LineBasedTextSearchResultCollector collector = new LineBasedTextSearchResultCollector(textResult);
    Pattern searchPattern = getSearchPattern();
    return TextSearchEngine.create().search(fScope, collector, searchPattern, monitor);
}
Also used : Pattern(java.util.regex.Pattern) AbstractTextSearchResult(org.eclipse.search.ui.text.AbstractTextSearchResult)

Aggregations

AbstractTextSearchResult (org.eclipse.search.ui.text.AbstractTextSearchResult)35 Test (org.junit.Test)20 Match (org.eclipse.search.ui.text.Match)19 ISearchQuery (org.eclipse.search.ui.ISearchQuery)11 IFile (org.eclipse.core.resources.IFile)6 Position (org.eclipse.jface.text.Position)6 Annotation (org.eclipse.jface.text.source.Annotation)5 IAnnotationModel (org.eclipse.jface.text.source.IAnnotationModel)5 ITextEditor (org.eclipse.ui.texteditor.ITextEditor)5 ITextFileBuffer (org.eclipse.core.filebuffers.ITextFileBuffer)4 IDocument (org.eclipse.jface.text.IDocument)4 ISearchResult (org.eclipse.search.ui.ISearchResult)4 MatchEvent (org.eclipse.search.ui.text.MatchEvent)4 ArrayList (java.util.ArrayList)3 Pattern (java.util.regex.Pattern)2 BadLocationException (org.eclipse.jface.text.BadLocationException)2 AbstractTreeViewer (org.eclipse.jface.viewers.AbstractTreeViewer)2 StructuredViewer (org.eclipse.jface.viewers.StructuredViewer)2 ISearchResultListener (org.eclipse.search.ui.ISearchResultListener)2 SearchResultEvent (org.eclipse.search.ui.SearchResultEvent)2