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

Unified Diff: Source/devtools/front_end/sources/SourcesSearchScope.js

Issue 376163002: DevTools: Search across files should work for file:folderName queries. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 | « Source/devtools/front_end/sdk/Workspace.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/sources/SourcesSearchScope.js
diff --git a/Source/devtools/front_end/sources/SourcesSearchScope.js b/Source/devtools/front_end/sources/SourcesSearchScope.js
index a8f01f1ef211e8e587cf16373aaad03bdf8d7980..d4940cf310170ae1817fa7d3333e9c62a0f9d010 100644
--- a/Source/devtools/front_end/sources/SourcesSearchScope.js
+++ b/Source/devtools/front_end/sources/SourcesSearchScope.js
@@ -112,27 +112,53 @@ WebInspector.SourcesSearchScope.prototype = {
var findMatchingFilesProgress = projectProgress.createSubProgress();
var searchContentProgress = projectProgress.createSubProgress();
var barrierCallback = barrier.createCallback();
- var callback = this._processMatchingFilesForProject.bind(this, this._searchId, project, searchContentProgress, barrierCallback);
- project.findFilesMatchingSearchRequest(searchConfig, findMatchingFilesProgress, callback);
+ var filesMathingFileQuery = this._projectFilesMatchingFileQuery(project, searchConfig);
+ var callback = this._processMatchingFilesForProject.bind(this, this._searchId, project, filesMathingFileQuery, searchContentProgress, barrierCallback);
+ project.findFilesMatchingSearchRequest(searchConfig, filesMathingFileQuery, findMatchingFilesProgress, callback);
}
barrier.callWhenDone(this._searchFinishedCallback.bind(this, true));
},
/**
+ * @param {!WebInspector.Project} project
+ * @param {!WebInspector.ProjectSearchConfig} searchConfig
+ * @param {boolean=} dirtyOnly
+ * @return {!Array.<string>}
+ */
+ _projectFilesMatchingFileQuery: function(project, searchConfig, dirtyOnly)
+ {
+ var result = [];
+ var uiSourceCodes = project.uiSourceCodes();
+ for (var i = 0; i < uiSourceCodes.length; ++i) {
+ var uiSourceCode = uiSourceCodes[i];
+ if (dirtyOnly && !uiSourceCode.isDirty())
+ continue;
+ if (this._searchConfig.filePathMatchesFileQuery(uiSourceCode.fullDisplayName()))
+ result.push(uiSourceCode.path());
+ }
+ result = result.sort(String.naturalOrderComparator);
+ return result;
+ },
+
+ /**
* @param {number} searchId
* @param {!WebInspector.Project} project
+ * @param {!Array.<string>} filesMathingFileQuery
* @param {!WebInspector.Progress} progress
* @param {function()} callback
* @param {!Array.<string>} files
*/
- _processMatchingFilesForProject: function(searchId, project, progress, callback, files)
+ _processMatchingFilesForProject: function(searchId, project, filesMathingFileQuery, progress, callback, files)
{
if (searchId !== this._searchId) {
this._searchFinishedCallback(false);
return;
}
- addDirtyFiles.call(this);
+ files = files.sort(String.naturalOrderComparator);
+ files = files.intersectOrdered(filesMathingFileQuery, String.naturalOrderComparator);
+ var dirtyFiles = this._projectFilesMatchingFileQuery(project, this._searchConfig, true);
+ files = files.mergeOrdered(dirtyFiles);
if (!files.length) {
progress.done();
@@ -150,22 +176,6 @@ WebInspector.SourcesSearchScope.prototype = {
scheduleSearchInNextFileOrFinish.call(this);
/**
- * @this {WebInspector.SourcesSearchScope}
- */
- function addDirtyFiles()
- {
- var matchingFiles = StringSet.fromArray(files);
- var uiSourceCodes = project.uiSourceCodes();
- for (var i = 0; i < uiSourceCodes.length; ++i) {
- if (!uiSourceCodes[i].isDirty())
- continue;
- var path = uiSourceCodes[i].path();
- if (!matchingFiles.contains(path) && this._searchConfig.filePathMatchesFileQuery(path))
- files.push(path);
- }
- }
-
- /**
* @param {string} path
* @this {WebInspector.SourcesSearchScope}
*/
« no previous file with comments | « Source/devtools/front_end/sdk/Workspace.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698