OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * | 10 * |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
108 * @param {function()} callback | 108 * @param {function()} callback |
109 * @param {!Array.<string>} files | 109 * @param {!Array.<string>} files |
110 */ | 110 */ |
111 _processMatchingFilesForProject: function(searchId, project, progress, callb ack, files) | 111 _processMatchingFilesForProject: function(searchId, project, progress, callb ack, files) |
112 { | 112 { |
113 if (searchId !== this._searchId) { | 113 if (searchId !== this._searchId) { |
114 this._searchFinishedCallback(false); | 114 this._searchFinishedCallback(false); |
115 return; | 115 return; |
116 } | 116 } |
117 | 117 |
118 addDirtyFiles(); | |
119 | |
118 if (!files.length) { | 120 if (!files.length) { |
119 progress.done(); | 121 progress.done(); |
120 callback(); | 122 callback(); |
121 return; | 123 return; |
122 } | 124 } |
123 | 125 |
124 progress.setTotalWork(files.length); | 126 progress.setTotalWork(files.length); |
125 | 127 |
126 var fileIndex = 0; | 128 var fileIndex = 0; |
127 var maxFileContentRequests = 20; | 129 var maxFileContentRequests = 20; |
128 var callbacksLeft = 0; | 130 var callbacksLeft = 0; |
129 | 131 |
130 for (var i = 0; i < maxFileContentRequests && i < files.length; ++i) | 132 for (var i = 0; i < maxFileContentRequests && i < files.length; ++i) |
131 scheduleSearchInNextFileOrFinish.call(this); | 133 scheduleSearchInNextFileOrFinish.call(this); |
132 | 134 |
135 function addDirtyFiles() | |
136 { | |
137 var matchingFiles = new StringSet(); | |
138 files.forEach(matchingFiles.put.bind(matchingFiles)); | |
pfeldman
2014/03/31 19:20:51
While you are here, could you rename StringSet's p
apavlov
2014/04/01 07:26:00
Done.
| |
139 | |
140 project.uiSourceCodes().filter(dirtySourceCodeFilter).forEach(append FilePath); | |
pfeldman
2014/03/31 19:20:51
my 8 lines against your 20
var uiSourceCodes = pr
apavlov
2014/04/01 07:26:00
Accepted!
| |
141 | |
142 /** | |
143 * @param {!WebInspector.UISourceCode} uiSourceCode | |
144 */ | |
145 function dirtySourceCodeFilter(uiSourceCode) | |
146 { | |
147 return uiSourceCode.isDirty(); | |
148 } | |
149 | |
150 /** | |
151 * @param {!WebInspector.UISourceCode} uiSourceCode | |
152 */ | |
153 function appendFilePath(uiSourceCode) | |
154 { | |
155 var path = uiSourceCode.path(); | |
156 if (!matchingFiles.contains(path)) | |
157 files.push(path); | |
158 } | |
159 } | |
160 | |
133 /** | 161 /** |
134 * @param {!string} path | 162 * @param {!string} path |
135 * @this {WebInspector.SourcesSearchScope} | 163 * @this {WebInspector.SourcesSearchScope} |
136 */ | 164 */ |
137 function searchInNextFile(path) | 165 function searchInNextFile(path) |
138 { | 166 { |
139 var uiSourceCode = project.uiSourceCode(path); | 167 var uiSourceCode = project.uiSourceCode(path); |
140 if (!uiSourceCode) { | 168 if (!uiSourceCode) { |
141 --callbacksLeft; | 169 --callbacksLeft; |
142 progress.worked(1); | 170 progress.worked(1); |
143 scheduleSearchInNextFileOrFinish.call(this); | 171 scheduleSearchInNextFileOrFinish.call(this); |
144 return; | 172 return; |
145 } | 173 } |
146 uiSourceCode.requestContent(contentLoaded.bind(this, path)); | 174 if (uiSourceCode.isDirty()) |
175 contentLoaded.call(this, uiSourceCode.path(), uiSourceCode.worki ngCopy()); | |
176 else | |
177 uiSourceCode.checkContentUpdated(contentUpdated.bind(this, uiSou rceCode)); | |
147 } | 178 } |
148 | 179 |
149 /** | 180 /** |
181 * @param {!WebInspector.UISourceCode} uiSourceCode | |
182 * @this {WebInspector.SourcesSearchScope} | |
183 */ | |
184 function contentUpdated(uiSourceCode) | |
185 { | |
186 uiSourceCode.requestContent(contentLoaded.bind(this, uiSourceCode.pa th())); | |
pfeldman
2014/03/31 19:20:51
... and when do we start using promises once again
apavlov
2014/04/01 07:26:00
Uhm... We've never used them... and will not, I pr
| |
187 } | |
188 | |
189 /** | |
150 * @this {WebInspector.SourcesSearchScope} | 190 * @this {WebInspector.SourcesSearchScope} |
151 */ | 191 */ |
152 function scheduleSearchInNextFileOrFinish() | 192 function scheduleSearchInNextFileOrFinish() |
153 { | 193 { |
154 if (fileIndex >= files.length) { | 194 if (fileIndex >= files.length) { |
155 if (!callbacksLeft) { | 195 if (!callbacksLeft) { |
156 progress.done(); | 196 progress.done(); |
157 callback(); | 197 callback(); |
158 return; | 198 return; |
159 } | 199 } |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
208 | 248 |
209 /** | 249 /** |
210 * @param {!WebInspector.SearchConfig} searchConfig | 250 * @param {!WebInspector.SearchConfig} searchConfig |
211 * @return {!WebInspector.FileBasedSearchResultsPane} | 251 * @return {!WebInspector.FileBasedSearchResultsPane} |
212 */ | 252 */ |
213 createSearchResultsPane: function(searchConfig) | 253 createSearchResultsPane: function(searchConfig) |
214 { | 254 { |
215 return new WebInspector.FileBasedSearchResultsPane(searchConfig); | 255 return new WebInspector.FileBasedSearchResultsPane(searchConfig); |
216 } | 256 } |
217 } | 257 } |
OLD | NEW |