Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(718)

Unified Diff: editor/tools/plugins/com.google.dart.tools.deploy/src/com/google/dart/tools/ui/omni/elements/TypeProvider.java

Issue 10510012: Searchbox proposals go async (and some cosmetic fixes). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « editor/tools/plugins/com.google.dart.tools.deploy/src/com/google/dart/tools/ui/omni/OmniElement.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: editor/tools/plugins/com.google.dart.tools.deploy/src/com/google/dart/tools/ui/omni/elements/TypeProvider.java
===================================================================
--- editor/tools/plugins/com.google.dart.tools.deploy/src/com/google/dart/tools/ui/omni/elements/TypeProvider.java (revision 8261)
+++ editor/tools/plugins/com.google.dart.tools.deploy/src/com/google/dart/tools/ui/omni/elements/TypeProvider.java (working copy)
@@ -20,6 +20,7 @@
import com.google.dart.tools.core.search.SearchEngineFactory;
import com.google.dart.tools.core.search.SearchException;
import com.google.dart.tools.core.search.SearchFilter;
+import com.google.dart.tools.core.search.SearchListener;
import com.google.dart.tools.core.search.SearchMatch;
import com.google.dart.tools.core.search.SearchPatternFactory;
import com.google.dart.tools.core.search.SearchScope;
@@ -35,7 +36,6 @@
import org.eclipse.ui.dialogs.SearchPattern;
import java.util.ArrayList;
-import java.util.List;
/**
* Provider for type elements.
@@ -61,6 +61,12 @@
//TODO (pquitslund): support additional scopes
private final SearchScope searchScope = SearchScopeFactory.createWorkspaceScope();
+ private final ArrayList<OmniElement> results = new ArrayList<OmniElement>();
+
+ protected boolean searchComplete;
+
+ private boolean searchStarted;
+
public TypeProvider(IProgressMonitor progressMonitor) {
this.progressMonitor = progressMonitor;
}
@@ -97,17 +103,7 @@
}
try {
- SearchEngine engine = SearchEngineFactory.createSearchEngine((WorkingCopyOwner) null);
- List<SearchMatch> matches = engine.searchTypeDeclarations(getSearchScope(), searchPattern,
- IGNORE_FILTER, progressMonitor);
- List<OmniElement> results = new ArrayList<OmniElement>(matches.size());
- for (SearchMatch match : matches) {
- DartElement element = match.getElement();
- if (element instanceof Type) {
- results.add(new TypeElement(TypeProvider.this, (Type) element));
- }
- }
- return results.toArray(new OmniElement[results.size()]);
+ return doSearch(searchPattern, pattern);
} catch (SearchException e) {
DartToolsPlugin.log(e);
}
@@ -124,6 +120,40 @@
return OmniBoxMessages.OmniBox_Types;
}
+ /**
+ * Check if search is complete.
+ */
+ public boolean isSearchComplete() {
+ return searchComplete;
+ }
+
+ private OmniElement[] doSearch(com.google.dart.tools.core.search.SearchPattern searchPattern,
+ final String filterText) throws SearchException {
+
+ if (!searchStarted) {
+ searchStarted = true;
+ SearchEngine engine = SearchEngineFactory.createSearchEngine((WorkingCopyOwner) null);
+ engine.searchTypeDeclarations(getSearchScope(), searchPattern, IGNORE_FILTER,
+ new SearchListener() {
+
+ @Override
+ public void matchFound(SearchMatch match) {
+ DartElement element = match.getElement();
+ if (element instanceof Type) {
+ results.add(new TypeElement(TypeProvider.this, (Type) element));
+ }
+ }
+
+ @Override
+ public void searchComplete() {
+ searchComplete = true;
+ }
+ }, progressMonitor);
+ }
+
+ return results.toArray(new OmniElement[results.size()]);
+ }
+
private SearchScope getSearchScope() {
return searchScope;
}
« no previous file with comments | « editor/tools/plugins/com.google.dart.tools.deploy/src/com/google/dart/tools/ui/omni/OmniElement.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698