Search in sources :

Example 1 with IFileMatchAdapter

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

the class PositionTracker method getTrackedFileBuffer.

private ITextFileBuffer getTrackedFileBuffer(AbstractTextSearchResult result, Object element) {
    IFileMatchAdapter adapter = result.getFileMatchAdapter();
    if (adapter == null)
        return null;
    IFile file = adapter.getFile(element);
    if (file == null)
        return null;
    if (!file.exists())
        return null;
    return FileBuffers.getTextFileBufferManager().getTextFileBuffer(file.getFullPath(), LocationKind.IFILE);
}
Also used : IFile(org.eclipse.core.resources.IFile) IFileMatchAdapter(org.eclipse.search.ui.text.IFileMatchAdapter)

Example 2 with IFileMatchAdapter

use of org.eclipse.search.ui.text.IFileMatchAdapter 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);
                }
            }
        }
    }
}
Also used : ISearchResult(org.eclipse.search.ui.ISearchResult) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) IFileMatchAdapter(org.eclipse.search.ui.text.IFileMatchAdapter) ITextFileBuffer(org.eclipse.core.filebuffers.ITextFileBuffer) AbstractTextSearchResult(org.eclipse.search.ui.text.AbstractTextSearchResult) ISearchQuery(org.eclipse.search.ui.ISearchQuery) Match(org.eclipse.search.ui.text.Match)

Aggregations

IFile (org.eclipse.core.resources.IFile)2 IFileMatchAdapter (org.eclipse.search.ui.text.IFileMatchAdapter)2 ITextFileBuffer (org.eclipse.core.filebuffers.ITextFileBuffer)1 IPath (org.eclipse.core.runtime.IPath)1 ISearchQuery (org.eclipse.search.ui.ISearchQuery)1 ISearchResult (org.eclipse.search.ui.ISearchResult)1 AbstractTextSearchResult (org.eclipse.search.ui.text.AbstractTextSearchResult)1 Match (org.eclipse.search.ui.text.Match)1