[hg] main-silver: #223301:go to file providers should have prior...

  • From: Tomas Zezula < >
  • To: ,
  • Subject: [hg] main-silver: #223301:go to file providers should have prior...
  • Date: Thu, 06 Dec 2012 11:30:25 -0800

changeset 1c4d3d7ddb93 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/1c4d3d7ddb93
description:
        #223301:go to file providers should have priority over default 
QuerySupport-based one

diffstat:

 jumpto/src/org/netbeans/modules/jumpto/file/FileSearchAction.java |  86 
+++++----
 1 files changed, 47 insertions(+), 39 deletions(-)

diffs (125 lines):

diff --git 
a/jumpto/src/org/netbeans/modules/jumpto/file/FileSearchAction.java 
b/jumpto/src/org/netbeans/modules/jumpto/file/FileSearchAction.java
--- a/jumpto/src/org/netbeans/modules/jumpto/file/FileSearchAction.java
+++ b/jumpto/src/org/netbeans/modules/jumpto/file/FileSearchAction.java
@@ -66,6 +66,7 @@
 import java.util.Collections;
 import java.util.Enumeration;
 import java.util.HashSet;
+import java.util.LinkedHashSet;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Set;
@@ -533,7 +534,6 @@
         }
 
         private List<? extends FileDescriptor> getFileNames() {
-            final Collection<FileObject> roots = new 
ArrayList<FileObject>(QuerySupport.findRoots((Project) null, null, 
Collections.<String>emptyList(), Collections.<String>emptyList()));
             try {
                 String searchField;
                 String indexQueryText;
@@ -557,10 +557,53 @@
                         indexQueryText = text;
                         break;
                 }
+
+                ArrayList<FileDescriptor> files = new 
ArrayList<FileDescriptor>();
+                
+                // handled by providers and should be excluded from other 
searches
+                final Set<FileObject> excludes = new HashSet<FileObject>();
+                final Project[] projects = 
OpenProjects.getDefault().getOpenProjects();
+                final List<FileObject> sgRoots = new 
LinkedList<FileObject>();
+                for (Project p : projects) {
+                    for (SourceGroup group : 
ProjectUtils.getSources(p).getSourceGroups(Sources.TYPE_GENERIC)) {
+                        sgRoots.add(group.getRootFolder());
+                    }
+                }
+                final SearchType jumpToSearchType = 
toJumpToSearchType(searchType);
+
                 long st = System.currentTimeMillis();
+                //Ask GTF providers
+                final FileProvider.Context ctx = 
FileProviderAccessor.getInstance().createContext(text, jumpToSearchType, 
lineNr, currentProject);
+                final FileProvider.Result fpR = 
FileProviderAccessor.getInstance().createResult(files,new String[1], ctx);
+                for (FileProvider provider : getProviders()) {
+                    currentProvider = provider;
+                    try {
+                        for (FileObject root : sgRoots) {
+                            if (excludes.contains(root)) {
+                                continue;
+                            }
+                            FileProviderAccessor.getInstance().setRoot(ctx, 
root);
+                            boolean recognized = provider.computeFiles(ctx, 
fpR);
+                            if (recognized) {
+                                excludes.add(root);
+                            }
+                        }
+                    } finally {
+                        currentProvider = null;
+                        if (isCanceled) {
+                            return files;
+                        }
+                    }
+                }
+                long et = System.currentTimeMillis();
+                LOGGER.log(Level.FINE, "Providers Search: {0}ms", (et-st));
+                    
+                final Set<FileObject> roots = new 
LinkedHashSet<FileObject>(QuerySupport.findRoots((Project) null, null, 
Collections.<String>emptyList(), Collections.<String>emptyList()));
+                roots.removeAll(excludes);
+                
+                // indexing-based search
                 QuerySupport q = QuerySupport.forRoots(FileIndexer.ID, 
FileIndexer.VERSION, roots.toArray(new FileObject [roots.size()]));
                 Collection<? extends IndexResult> results = 
q.query(searchField, indexQueryText, searchType);
-                ArrayList<FileDescriptor> files = new 
ArrayList<FileDescriptor>();
                 for(IndexResult r : results) {
                     FileObject file = r.getFile();
                     if (file == null || !file.isValid()) {
@@ -583,48 +626,13 @@
                                 project, currentProject, preferred
                     });
                 }
-                long et = System.currentTimeMillis();
+                excludes.addAll(roots);
+                et = System.currentTimeMillis();
                 LOGGER.log(Level.FINE, "Indexed Search: {0}ms", (et-st));
                 if (isCanceled) {
                     return files;
                 }
 
-                st = System.currentTimeMillis();
-                final Set<FileObject> excludes = new 
HashSet<FileObject>(roots);
-                final Project[] projects = 
OpenProjects.getDefault().getOpenProjects();
-                final List<FileObject> sgRoots = new 
LinkedList<FileObject>();
-                for (Project p : projects) {
-                    for (SourceGroup group: 
ProjectUtils.getSources(p).getSourceGroups(Sources.TYPE_GENERIC)) {
-                        sgRoots.add(group.getRootFolder());
-                    }
-                }
-                //Ask GTF providers
-                final SearchType jumpToSearchType = 
toJumpToSearchType(searchType);
-                final FileProvider.Context ctx = 
FileProviderAccessor.getInstance().createContext(text, jumpToSearchType, 
lineNr, currentProject);
-                final FileProvider.Result fpR = 
FileProviderAccessor.getInstance().createResult(files,new String[1], ctx);
-                for (FileProvider provider : getProviders()) {
-                    currentProvider = provider;
-                    try {
-                        for (FileObject root : sgRoots) {
-                            if (excludes.contains(root)) {
-                                continue;
-                            }
-                            FileProviderAccessor.getInstance().setRoot(ctx, 
root);
-                            boolean recognized = provider.computeFiles(ctx, 
fpR);
-                            if (recognized) {
-                                excludes.add(root);
-                            }
-                        }
-                    } finally {
-                        currentProvider = null;
-                        if (isCanceled) {
-                            return files;
-                        }
-                    }
-                }
-                et = System.currentTimeMillis();
-                LOGGER.log(Level.FINE, "Providers Search: {0}ms", (et-st));
-
                 //PENDING Now we have to search folders which not included 
in Search API
                 st = System.currentTimeMillis();
                 Collection <FileObject> allFolders = new 
HashSet<FileObject>();

[hg] main-silver: #223301:go to file providers should have prior...

Tomas Zezula 12/06/2012

Project Features

About this Project

Editor was started in November 2009, is owned by Martin Ryzl, and has 188 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20150226.965aeb8). © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close