| Index: editor/tools/plugins/com.google.dart.tools.search/src/com/google/dart/tools/search/internal/ui/text/FileSearchResult.java
|
| ===================================================================
|
| --- editor/tools/plugins/com.google.dart.tools.search/src/com/google/dart/tools/search/internal/ui/text/FileSearchResult.java (revision 7355)
|
| +++ editor/tools/plugins/com.google.dart.tools.search/src/com/google/dart/tools/search/internal/ui/text/FileSearchResult.java (working copy)
|
| @@ -1,5 +1,5 @@
|
| /*
|
| - * Copyright (c) 2011, the Dart project authors.
|
| + * Copyright (c) 2012, the Dart project authors.
|
| *
|
| * Licensed under the Eclipse Public License v1.0 (the "License"); you may not use this file except
|
| * in compliance with the License. You may obtain a copy of the License at
|
| @@ -21,13 +21,15 @@
|
| import com.google.dart.tools.search.ui.text.Match;
|
|
|
| import org.eclipse.core.resources.IFile;
|
| -
|
| import org.eclipse.jface.resource.ImageDescriptor;
|
| -
|
| import org.eclipse.ui.IEditorInput;
|
| import org.eclipse.ui.IEditorPart;
|
| import org.eclipse.ui.IFileEditorInput;
|
| +import org.eclipse.ui.ide.FileStoreEditorInput;
|
|
|
| +import java.io.File;
|
| +import java.net.URI;
|
| +import java.util.List;
|
|
|
| public class FileSearchResult extends AbstractTextSearchResult implements IEditorMatchAdapter,
|
| IFileMatchAdapter {
|
| @@ -39,28 +41,64 @@
|
| fQuery = job;
|
| }
|
|
|
| + @Override
|
| + public Match[] computeContainedMatches(AbstractTextSearchResult result, IEditorPart editor) {
|
| + IEditorInput ei = editor.getEditorInput();
|
| + if (ei instanceof IFileEditorInput) {
|
| + IFileEditorInput fi = (IFileEditorInput) ei;
|
| + return getMatches(fi.getFile());
|
| + }
|
| + if (ei instanceof FileStoreEditorInput) {
|
| + FileStoreEditorInput fi = (FileStoreEditorInput) ei;
|
| + return getMatchesForURI(fi.getURI());
|
| + }
|
| + return EMPTY_ARR;
|
| + }
|
| +
|
| + @Override
|
| + public Match[] computeContainedMatches(AbstractTextSearchResult result, IFile file) {
|
| + return getMatches(file);
|
| + }
|
| +
|
| + @Override
|
| + public IEditorMatchAdapter getEditorMatchAdapter() {
|
| + return this;
|
| + }
|
| +
|
| + @Override
|
| + public IFile getFile(Object element) {
|
| + if (element instanceof IFile) {
|
| + return (IFile) element;
|
| + }
|
| + return null;
|
| + }
|
| +
|
| + @Override
|
| + public IFileMatchAdapter getFileMatchAdapter() {
|
| + return this;
|
| + }
|
| +
|
| + @Override
|
| public ImageDescriptor getImageDescriptor() {
|
| return SearchPluginImages.DESC_OBJ_TSEARCH_DPDN;
|
| }
|
|
|
| + @Override
|
| public String getLabel() {
|
| return fQuery.getResultLabel(getMatchCount());
|
| }
|
|
|
| + @Override
|
| + public ISearchQuery getQuery() {
|
| + return fQuery;
|
| + }
|
| +
|
| + @Override
|
| public String getTooltip() {
|
| return getLabel();
|
| }
|
|
|
| - public Match[] computeContainedMatches(AbstractTextSearchResult result, IFile file) {
|
| - return getMatches(file);
|
| - }
|
| -
|
| - public IFile getFile(Object element) {
|
| - if (element instanceof IFile)
|
| - return (IFile) element;
|
| - return null;
|
| - }
|
| -
|
| + @Override
|
| public boolean isShownInEditor(Match match, IEditorPart editor) {
|
| IEditorInput ei = editor.getEditorInput();
|
| if (ei instanceof IFileEditorInput) {
|
| @@ -70,24 +108,23 @@
|
| return false;
|
| }
|
|
|
| - public Match[] computeContainedMatches(AbstractTextSearchResult result, IEditorPart editor) {
|
| - IEditorInput ei = editor.getEditorInput();
|
| - if (ei instanceof IFileEditorInput) {
|
| - IFileEditorInput fi = (IFileEditorInput) ei;
|
| - return getMatches(fi.getFile());
|
| - }
|
| - return EMPTY_ARR;
|
| - }
|
| + //TODO(pquitslund): vet this
|
| + protected Match[] getMatchesForURI(URI uri) {
|
|
|
| - public ISearchQuery getQuery() {
|
| - return fQuery;
|
| - }
|
| + File file = new File(uri);
|
|
|
| - public IFileMatchAdapter getFileMatchAdapter() {
|
| - return this;
|
| + synchronized (fElementsToMatches) {
|
| + for (Object key : fElementsToMatches.keySet()) {
|
| + if (key instanceof File) {
|
| + if (((File) key).getAbsolutePath().equals(file.getAbsolutePath())) {
|
| + List<Match> matches = fElementsToMatches.get(key);
|
| + if (matches != null) {
|
| + return matches.toArray(new Match[matches.size()]);
|
| + }
|
| + }
|
| + }
|
| + }
|
| + return EMPTY_ARRAY;
|
| + }
|
| }
|
| -
|
| - public IEditorMatchAdapter getEditorMatchAdapter() {
|
| - return this;
|
| - }
|
| }
|
|
|