| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 /** | 30 /** |
| 31 * @interface | 31 * @interface |
| 32 */ | 32 */ |
| 33 WebInspector.ProjectSearchConfig = function() {}; | 33 Workspace.ProjectSearchConfig = function() {}; |
| 34 | 34 |
| 35 WebInspector.ProjectSearchConfig.prototype = { | 35 Workspace.ProjectSearchConfig.prototype = { |
| 36 /** | 36 /** |
| 37 * @return {string} | 37 * @return {string} |
| 38 */ | 38 */ |
| 39 query: function() {}, | 39 query: function() {}, |
| 40 | 40 |
| 41 /** | 41 /** |
| 42 * @return {boolean} | 42 * @return {boolean} |
| 43 */ | 43 */ |
| 44 ignoreCase: function() {}, | 44 ignoreCase: function() {}, |
| 45 | 45 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 56 /** | 56 /** |
| 57 * @param {string} filePath | 57 * @param {string} filePath |
| 58 * @return {boolean} | 58 * @return {boolean} |
| 59 */ | 59 */ |
| 60 filePathMatchesFileQuery: function(filePath) {} | 60 filePathMatchesFileQuery: function(filePath) {} |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 /** | 63 /** |
| 64 * @interface | 64 * @interface |
| 65 */ | 65 */ |
| 66 WebInspector.Project = function() {}; | 66 Workspace.Project = function() {}; |
| 67 | 67 |
| 68 /** | 68 /** |
| 69 * @param {!WebInspector.Project} project | 69 * @param {!Workspace.Project} project |
| 70 * @return {boolean} | 70 * @return {boolean} |
| 71 */ | 71 */ |
| 72 WebInspector.Project.isServiceProject = function(project) { | 72 Workspace.Project.isServiceProject = function(project) { |
| 73 return project.type() === WebInspector.projectTypes.Debugger || | 73 return project.type() === Workspace.projectTypes.Debugger || |
| 74 project.type() === WebInspector.projectTypes.Formatter || project.type() =
== WebInspector.projectTypes.Service; | 74 project.type() === Workspace.projectTypes.Formatter || project.type() ===
Workspace.projectTypes.Service; |
| 75 }; | 75 }; |
| 76 | 76 |
| 77 WebInspector.Project.prototype = { | 77 Workspace.Project.prototype = { |
| 78 /** | 78 /** |
| 79 * @return {!WebInspector.Workspace} | 79 * @return {!Workspace.Workspace} |
| 80 */ | 80 */ |
| 81 workspace: function() {}, | 81 workspace: function() {}, |
| 82 | 82 |
| 83 /** | 83 /** |
| 84 * @return {string} | 84 * @return {string} |
| 85 */ | 85 */ |
| 86 id: function() {}, | 86 id: function() {}, |
| 87 | 87 |
| 88 /** | 88 /** |
| 89 * @return {string} | 89 * @return {string} |
| 90 */ | 90 */ |
| 91 type: function() {}, | 91 type: function() {}, |
| 92 | 92 |
| 93 /** | 93 /** |
| 94 * @return {string} | 94 * @return {string} |
| 95 */ | 95 */ |
| 96 displayName: function() {}, | 96 displayName: function() {}, |
| 97 | 97 |
| 98 /** | 98 /** |
| 99 * @param {!WebInspector.UISourceCode} uiSourceCode | 99 * @param {!Workspace.UISourceCode} uiSourceCode |
| 100 * @return {!Promise<?WebInspector.UISourceCodeMetadata>} | 100 * @return {!Promise<?Workspace.UISourceCodeMetadata>} |
| 101 */ | 101 */ |
| 102 requestMetadata: function(uiSourceCode) {}, | 102 requestMetadata: function(uiSourceCode) {}, |
| 103 | 103 |
| 104 /** | 104 /** |
| 105 * @param {!WebInspector.UISourceCode} uiSourceCode | 105 * @param {!Workspace.UISourceCode} uiSourceCode |
| 106 * @param {function(?string)} callback | 106 * @param {function(?string)} callback |
| 107 */ | 107 */ |
| 108 requestFileContent: function(uiSourceCode, callback) {}, | 108 requestFileContent: function(uiSourceCode, callback) {}, |
| 109 | 109 |
| 110 /** | 110 /** |
| 111 * @return {boolean} | 111 * @return {boolean} |
| 112 */ | 112 */ |
| 113 canSetFileContent: function() {}, | 113 canSetFileContent: function() {}, |
| 114 | 114 |
| 115 /** | 115 /** |
| 116 * @param {!WebInspector.UISourceCode} uiSourceCode | 116 * @param {!Workspace.UISourceCode} uiSourceCode |
| 117 * @param {string} newContent | 117 * @param {string} newContent |
| 118 * @param {function(?string)} callback | 118 * @param {function(?string)} callback |
| 119 */ | 119 */ |
| 120 setFileContent: function(uiSourceCode, newContent, callback) {}, | 120 setFileContent: function(uiSourceCode, newContent, callback) {}, |
| 121 | 121 |
| 122 /** | 122 /** |
| 123 * @return {boolean} | 123 * @return {boolean} |
| 124 */ | 124 */ |
| 125 canRename: function() {}, | 125 canRename: function() {}, |
| 126 | 126 |
| 127 /** | 127 /** |
| 128 * @param {!WebInspector.UISourceCode} uiSourceCode | 128 * @param {!Workspace.UISourceCode} uiSourceCode |
| 129 * @param {string} newName | 129 * @param {string} newName |
| 130 * @param {function(boolean, string=, string=, !WebInspector.ResourceType=)} c
allback | 130 * @param {function(boolean, string=, string=, !Common.ResourceType=)} callbac
k |
| 131 */ | 131 */ |
| 132 rename: function(uiSourceCode, newName, callback) {}, | 132 rename: function(uiSourceCode, newName, callback) {}, |
| 133 | 133 |
| 134 /** | 134 /** |
| 135 * @param {string} path | 135 * @param {string} path |
| 136 */ | 136 */ |
| 137 excludeFolder: function(path) {}, | 137 excludeFolder: function(path) {}, |
| 138 | 138 |
| 139 /** | 139 /** |
| 140 * @param {string} path | 140 * @param {string} path |
| 141 * @param {?string} name | 141 * @param {?string} name |
| 142 * @param {string} content | 142 * @param {string} content |
| 143 * @param {function(?WebInspector.UISourceCode)} callback | 143 * @param {function(?Workspace.UISourceCode)} callback |
| 144 */ | 144 */ |
| 145 createFile: function(path, name, content, callback) {}, | 145 createFile: function(path, name, content, callback) {}, |
| 146 | 146 |
| 147 /** | 147 /** |
| 148 * @param {string} path | 148 * @param {string} path |
| 149 */ | 149 */ |
| 150 deleteFile: function(path) {}, | 150 deleteFile: function(path) {}, |
| 151 | 151 |
| 152 remove: function() {}, | 152 remove: function() {}, |
| 153 | 153 |
| 154 /** | 154 /** |
| 155 * @param {!WebInspector.UISourceCode} uiSourceCode | 155 * @param {!Workspace.UISourceCode} uiSourceCode |
| 156 * @param {string} query | 156 * @param {string} query |
| 157 * @param {boolean} caseSensitive | 157 * @param {boolean} caseSensitive |
| 158 * @param {boolean} isRegex | 158 * @param {boolean} isRegex |
| 159 * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} callb
ack | 159 * @param {function(!Array.<!Common.ContentProvider.SearchMatch>)} callback |
| 160 */ | 160 */ |
| 161 searchInFileContent: function(uiSourceCode, query, caseSensitive, isRegex, cal
lback) {}, | 161 searchInFileContent: function(uiSourceCode, query, caseSensitive, isRegex, cal
lback) {}, |
| 162 | 162 |
| 163 /** | 163 /** |
| 164 * @param {!WebInspector.ProjectSearchConfig} searchConfig | 164 * @param {!Workspace.ProjectSearchConfig} searchConfig |
| 165 * @param {!Array.<string>} filesMathingFileQuery | 165 * @param {!Array.<string>} filesMathingFileQuery |
| 166 * @param {!WebInspector.Progress} progress | 166 * @param {!Common.Progress} progress |
| 167 * @param {function(!Array.<string>)} callback | 167 * @param {function(!Array.<string>)} callback |
| 168 */ | 168 */ |
| 169 findFilesMatchingSearchRequest: function(searchConfig, filesMathingFileQuery,
progress, callback) {}, | 169 findFilesMatchingSearchRequest: function(searchConfig, filesMathingFileQuery,
progress, callback) {}, |
| 170 | 170 |
| 171 /** | 171 /** |
| 172 * @param {!WebInspector.Progress} progress | 172 * @param {!Common.Progress} progress |
| 173 */ | 173 */ |
| 174 indexContent: function(progress) {}, | 174 indexContent: function(progress) {}, |
| 175 | 175 |
| 176 /** | 176 /** |
| 177 * @param {string} url | 177 * @param {string} url |
| 178 * @return {?WebInspector.UISourceCode} | 178 * @return {?Workspace.UISourceCode} |
| 179 */ | 179 */ |
| 180 uiSourceCodeForURL: function(url) {}, | 180 uiSourceCodeForURL: function(url) {}, |
| 181 | 181 |
| 182 /** | 182 /** |
| 183 * @return {!Array.<!WebInspector.UISourceCode>} | 183 * @return {!Array.<!Workspace.UISourceCode>} |
| 184 */ | 184 */ |
| 185 uiSourceCodes: function() {} | 185 uiSourceCodes: function() {} |
| 186 }; | 186 }; |
| 187 | 187 |
| 188 /** | 188 /** |
| 189 * @enum {string} | 189 * @enum {string} |
| 190 */ | 190 */ |
| 191 WebInspector.projectTypes = { | 191 Workspace.projectTypes = { |
| 192 Debugger: 'debugger', | 192 Debugger: 'debugger', |
| 193 Formatter: 'formatter', | 193 Formatter: 'formatter', |
| 194 Network: 'network', | 194 Network: 'network', |
| 195 Snippets: 'snippets', | 195 Snippets: 'snippets', |
| 196 FileSystem: 'filesystem', | 196 FileSystem: 'filesystem', |
| 197 ContentScripts: 'contentscripts', | 197 ContentScripts: 'contentscripts', |
| 198 Service: 'service' | 198 Service: 'service' |
| 199 }; | 199 }; |
| 200 | 200 |
| 201 /** | 201 /** |
| 202 * @unrestricted | 202 * @unrestricted |
| 203 */ | 203 */ |
| 204 WebInspector.ProjectStore = class { | 204 Workspace.ProjectStore = class { |
| 205 /** | 205 /** |
| 206 * @param {!WebInspector.Workspace} workspace | 206 * @param {!Workspace.Workspace} workspace |
| 207 * @param {string} id | 207 * @param {string} id |
| 208 * @param {!WebInspector.projectTypes} type | 208 * @param {!Workspace.projectTypes} type |
| 209 * @param {string} displayName | 209 * @param {string} displayName |
| 210 */ | 210 */ |
| 211 constructor(workspace, id, type, displayName) { | 211 constructor(workspace, id, type, displayName) { |
| 212 this._workspace = workspace; | 212 this._workspace = workspace; |
| 213 this._id = id; | 213 this._id = id; |
| 214 this._type = type; | 214 this._type = type; |
| 215 this._displayName = displayName; | 215 this._displayName = displayName; |
| 216 | 216 |
| 217 /** @type {!Map.<string, !{uiSourceCode: !WebInspector.UISourceCode, index:
number}>} */ | 217 /** @type {!Map.<string, !{uiSourceCode: !Workspace.UISourceCode, index: num
ber}>} */ |
| 218 this._uiSourceCodesMap = new Map(); | 218 this._uiSourceCodesMap = new Map(); |
| 219 /** @type {!Array.<!WebInspector.UISourceCode>} */ | 219 /** @type {!Array.<!Workspace.UISourceCode>} */ |
| 220 this._uiSourceCodesList = []; | 220 this._uiSourceCodesList = []; |
| 221 | 221 |
| 222 this._project = /** @type {!WebInspector.Project} */ (this); | 222 this._project = /** @type {!Workspace.Project} */ (this); |
| 223 } | 223 } |
| 224 | 224 |
| 225 /** | 225 /** |
| 226 * @return {string} | 226 * @return {string} |
| 227 */ | 227 */ |
| 228 id() { | 228 id() { |
| 229 return this._id; | 229 return this._id; |
| 230 } | 230 } |
| 231 | 231 |
| 232 /** | 232 /** |
| 233 * @return {string} | 233 * @return {string} |
| 234 */ | 234 */ |
| 235 type() { | 235 type() { |
| 236 return this._type; | 236 return this._type; |
| 237 } | 237 } |
| 238 | 238 |
| 239 /** | 239 /** |
| 240 * @return {string} | 240 * @return {string} |
| 241 */ | 241 */ |
| 242 displayName() { | 242 displayName() { |
| 243 return this._displayName; | 243 return this._displayName; |
| 244 } | 244 } |
| 245 | 245 |
| 246 /** | 246 /** |
| 247 * @return {!WebInspector.Workspace} | 247 * @return {!Workspace.Workspace} |
| 248 */ | 248 */ |
| 249 workspace() { | 249 workspace() { |
| 250 return this._workspace; | 250 return this._workspace; |
| 251 } | 251 } |
| 252 | 252 |
| 253 /** | 253 /** |
| 254 * @param {string} url | 254 * @param {string} url |
| 255 * @param {!WebInspector.ResourceType} contentType | 255 * @param {!Common.ResourceType} contentType |
| 256 * @return {!WebInspector.UISourceCode} | 256 * @return {!Workspace.UISourceCode} |
| 257 */ | 257 */ |
| 258 createUISourceCode(url, contentType) { | 258 createUISourceCode(url, contentType) { |
| 259 return new WebInspector.UISourceCode(this._project, url, contentType); | 259 return new Workspace.UISourceCode(this._project, url, contentType); |
| 260 } | 260 } |
| 261 | 261 |
| 262 /** | 262 /** |
| 263 * @param {!WebInspector.UISourceCode} uiSourceCode | 263 * @param {!Workspace.UISourceCode} uiSourceCode |
| 264 * @param {boolean=} replace | 264 * @param {boolean=} replace |
| 265 * @return {boolean} | 265 * @return {boolean} |
| 266 */ | 266 */ |
| 267 addUISourceCode(uiSourceCode, replace) { | 267 addUISourceCode(uiSourceCode, replace) { |
| 268 var url = uiSourceCode.url(); | 268 var url = uiSourceCode.url(); |
| 269 if (this.uiSourceCodeForURL(url)) { | 269 if (this.uiSourceCodeForURL(url)) { |
| 270 if (replace) | 270 if (replace) |
| 271 this.removeUISourceCode(url); | 271 this.removeUISourceCode(url); |
| 272 else | 272 else |
| 273 return false; | 273 return false; |
| 274 } | 274 } |
| 275 this._uiSourceCodesMap.set(url, {uiSourceCode: uiSourceCode, index: this._ui
SourceCodesList.length}); | 275 this._uiSourceCodesMap.set(url, {uiSourceCode: uiSourceCode, index: this._ui
SourceCodesList.length}); |
| 276 this._uiSourceCodesList.push(uiSourceCode); | 276 this._uiSourceCodesList.push(uiSourceCode); |
| 277 this._workspace.dispatchEventToListeners(WebInspector.Workspace.Events.UISou
rceCodeAdded, uiSourceCode); | 277 this._workspace.dispatchEventToListeners(Workspace.Workspace.Events.UISource
CodeAdded, uiSourceCode); |
| 278 return true; | 278 return true; |
| 279 } | 279 } |
| 280 | 280 |
| 281 /** | 281 /** |
| 282 * @param {string} url | 282 * @param {string} url |
| 283 */ | 283 */ |
| 284 removeUISourceCode(url) { | 284 removeUISourceCode(url) { |
| 285 var uiSourceCode = this.uiSourceCodeForURL(url); | 285 var uiSourceCode = this.uiSourceCodeForURL(url); |
| 286 if (!uiSourceCode) | 286 if (!uiSourceCode) |
| 287 return; | 287 return; |
| 288 | 288 |
| 289 var entry = this._uiSourceCodesMap.get(url); | 289 var entry = this._uiSourceCodesMap.get(url); |
| 290 var movedUISourceCode = this._uiSourceCodesList[this._uiSourceCodesList.leng
th - 1]; | 290 var movedUISourceCode = this._uiSourceCodesList[this._uiSourceCodesList.leng
th - 1]; |
| 291 this._uiSourceCodesList[entry.index] = movedUISourceCode; | 291 this._uiSourceCodesList[entry.index] = movedUISourceCode; |
| 292 var movedEntry = this._uiSourceCodesMap.get(movedUISourceCode.url()); | 292 var movedEntry = this._uiSourceCodesMap.get(movedUISourceCode.url()); |
| 293 movedEntry.index = entry.index; | 293 movedEntry.index = entry.index; |
| 294 this._uiSourceCodesList.splice(this._uiSourceCodesList.length - 1, 1); | 294 this._uiSourceCodesList.splice(this._uiSourceCodesList.length - 1, 1); |
| 295 this._uiSourceCodesMap.delete(url); | 295 this._uiSourceCodesMap.delete(url); |
| 296 this._workspace.dispatchEventToListeners(WebInspector.Workspace.Events.UISou
rceCodeRemoved, entry.uiSourceCode); | 296 this._workspace.dispatchEventToListeners(Workspace.Workspace.Events.UISource
CodeRemoved, entry.uiSourceCode); |
| 297 } | 297 } |
| 298 | 298 |
| 299 removeProject() { | 299 removeProject() { |
| 300 this._workspace._removeProject(this._project); | 300 this._workspace._removeProject(this._project); |
| 301 this._uiSourceCodesMap = new Map(); | 301 this._uiSourceCodesMap = new Map(); |
| 302 this._uiSourceCodesList = []; | 302 this._uiSourceCodesList = []; |
| 303 } | 303 } |
| 304 | 304 |
| 305 /** | 305 /** |
| 306 * @param {string} url | 306 * @param {string} url |
| 307 * @return {?WebInspector.UISourceCode} | 307 * @return {?Workspace.UISourceCode} |
| 308 */ | 308 */ |
| 309 uiSourceCodeForURL(url) { | 309 uiSourceCodeForURL(url) { |
| 310 var entry = this._uiSourceCodesMap.get(url); | 310 var entry = this._uiSourceCodesMap.get(url); |
| 311 return entry ? entry.uiSourceCode : null; | 311 return entry ? entry.uiSourceCode : null; |
| 312 } | 312 } |
| 313 | 313 |
| 314 /** | 314 /** |
| 315 * @return {!Array.<!WebInspector.UISourceCode>} | 315 * @return {!Array.<!Workspace.UISourceCode>} |
| 316 */ | 316 */ |
| 317 uiSourceCodes() { | 317 uiSourceCodes() { |
| 318 return this._uiSourceCodesList; | 318 return this._uiSourceCodesList; |
| 319 } | 319 } |
| 320 | 320 |
| 321 /** | 321 /** |
| 322 * @param {!WebInspector.UISourceCode} uiSourceCode | 322 * @param {!Workspace.UISourceCode} uiSourceCode |
| 323 * @param {string} newName | 323 * @param {string} newName |
| 324 */ | 324 */ |
| 325 renameUISourceCode(uiSourceCode, newName) { | 325 renameUISourceCode(uiSourceCode, newName) { |
| 326 var oldPath = uiSourceCode.url(); | 326 var oldPath = uiSourceCode.url(); |
| 327 var newPath = uiSourceCode.parentURL() ? uiSourceCode.parentURL() + '/' + ne
wName : newName; | 327 var newPath = uiSourceCode.parentURL() ? uiSourceCode.parentURL() + '/' + ne
wName : newName; |
| 328 var value = | 328 var value = |
| 329 /** @type {!{uiSourceCode: !WebInspector.UISourceCode, index: number}} *
/ (this._uiSourceCodesMap.get(oldPath)); | 329 /** @type {!{uiSourceCode: !Workspace.UISourceCode, index: number}} */ (
this._uiSourceCodesMap.get(oldPath)); |
| 330 this._uiSourceCodesMap.set(newPath, value); | 330 this._uiSourceCodesMap.set(newPath, value); |
| 331 this._uiSourceCodesMap.delete(oldPath); | 331 this._uiSourceCodesMap.delete(oldPath); |
| 332 } | 332 } |
| 333 }; | 333 }; |
| 334 | 334 |
| 335 /** | 335 /** |
| 336 * @unrestricted | 336 * @unrestricted |
| 337 */ | 337 */ |
| 338 WebInspector.Workspace = class extends WebInspector.Object { | 338 Workspace.Workspace = class extends Common.Object { |
| 339 constructor() { | 339 constructor() { |
| 340 super(); | 340 super(); |
| 341 /** @type {!Map<string, !WebInspector.Project>} */ | 341 /** @type {!Map<string, !Workspace.Project>} */ |
| 342 this._projects = new Map(); | 342 this._projects = new Map(); |
| 343 this._hasResourceContentTrackingExtensions = false; | 343 this._hasResourceContentTrackingExtensions = false; |
| 344 } | 344 } |
| 345 | 345 |
| 346 /** | 346 /** |
| 347 * @param {string} projectId | 347 * @param {string} projectId |
| 348 * @param {string} url | 348 * @param {string} url |
| 349 * @return {?WebInspector.UISourceCode} | 349 * @return {?Workspace.UISourceCode} |
| 350 */ | 350 */ |
| 351 uiSourceCode(projectId, url) { | 351 uiSourceCode(projectId, url) { |
| 352 var project = this._projects.get(projectId); | 352 var project = this._projects.get(projectId); |
| 353 return project ? project.uiSourceCodeForURL(url) : null; | 353 return project ? project.uiSourceCodeForURL(url) : null; |
| 354 } | 354 } |
| 355 | 355 |
| 356 /** | 356 /** |
| 357 * @param {string} url | 357 * @param {string} url |
| 358 * @return {?WebInspector.UISourceCode} | 358 * @return {?Workspace.UISourceCode} |
| 359 */ | 359 */ |
| 360 uiSourceCodeForURL(url) { | 360 uiSourceCodeForURL(url) { |
| 361 for (var project of this._projects.values()) { | 361 for (var project of this._projects.values()) { |
| 362 var uiSourceCode = project.uiSourceCodeForURL(url); | 362 var uiSourceCode = project.uiSourceCodeForURL(url); |
| 363 if (uiSourceCode) | 363 if (uiSourceCode) |
| 364 return uiSourceCode; | 364 return uiSourceCode; |
| 365 } | 365 } |
| 366 return null; | 366 return null; |
| 367 } | 367 } |
| 368 | 368 |
| 369 /** | 369 /** |
| 370 * @param {string} type | 370 * @param {string} type |
| 371 * @return {!Array.<!WebInspector.UISourceCode>} | 371 * @return {!Array.<!Workspace.UISourceCode>} |
| 372 */ | 372 */ |
| 373 uiSourceCodesForProjectType(type) { | 373 uiSourceCodesForProjectType(type) { |
| 374 var result = []; | 374 var result = []; |
| 375 for (var project of this._projects.values()) { | 375 for (var project of this._projects.values()) { |
| 376 if (project.type() === type) | 376 if (project.type() === type) |
| 377 result = result.concat(project.uiSourceCodes()); | 377 result = result.concat(project.uiSourceCodes()); |
| 378 } | 378 } |
| 379 return result; | 379 return result; |
| 380 } | 380 } |
| 381 | 381 |
| 382 /** | 382 /** |
| 383 * @param {!WebInspector.Project} project | 383 * @param {!Workspace.Project} project |
| 384 */ | 384 */ |
| 385 addProject(project) { | 385 addProject(project) { |
| 386 console.assert(!this._projects.has(project.id()), `A project with id ${proje
ct.id()} already exists!`); | 386 console.assert(!this._projects.has(project.id()), `A project with id ${proje
ct.id()} already exists!`); |
| 387 this._projects.set(project.id(), project); | 387 this._projects.set(project.id(), project); |
| 388 this.dispatchEventToListeners(WebInspector.Workspace.Events.ProjectAdded, pr
oject); | 388 this.dispatchEventToListeners(Workspace.Workspace.Events.ProjectAdded, proje
ct); |
| 389 } | 389 } |
| 390 | 390 |
| 391 /** | 391 /** |
| 392 * @param {!WebInspector.Project} project | 392 * @param {!Workspace.Project} project |
| 393 */ | 393 */ |
| 394 _removeProject(project) { | 394 _removeProject(project) { |
| 395 this._projects.delete(project.id()); | 395 this._projects.delete(project.id()); |
| 396 this.dispatchEventToListeners(WebInspector.Workspace.Events.ProjectRemoved,
project); | 396 this.dispatchEventToListeners(Workspace.Workspace.Events.ProjectRemoved, pro
ject); |
| 397 } | 397 } |
| 398 | 398 |
| 399 /** | 399 /** |
| 400 * @param {string} projectId | 400 * @param {string} projectId |
| 401 * @return {?WebInspector.Project} | 401 * @return {?Workspace.Project} |
| 402 */ | 402 */ |
| 403 project(projectId) { | 403 project(projectId) { |
| 404 return this._projects.get(projectId) || null; | 404 return this._projects.get(projectId) || null; |
| 405 } | 405 } |
| 406 | 406 |
| 407 /** | 407 /** |
| 408 * @return {!Array.<!WebInspector.Project>} | 408 * @return {!Array.<!Workspace.Project>} |
| 409 */ | 409 */ |
| 410 projects() { | 410 projects() { |
| 411 return this._projects.valuesArray(); | 411 return this._projects.valuesArray(); |
| 412 } | 412 } |
| 413 | 413 |
| 414 /** | 414 /** |
| 415 * @param {string} type | 415 * @param {string} type |
| 416 * @return {!Array.<!WebInspector.Project>} | 416 * @return {!Array.<!Workspace.Project>} |
| 417 */ | 417 */ |
| 418 projectsForType(type) { | 418 projectsForType(type) { |
| 419 function filterByType(project) { | 419 function filterByType(project) { |
| 420 return project.type() === type; | 420 return project.type() === type; |
| 421 } | 421 } |
| 422 return this.projects().filter(filterByType); | 422 return this.projects().filter(filterByType); |
| 423 } | 423 } |
| 424 | 424 |
| 425 /** | 425 /** |
| 426 * @return {!Array.<!WebInspector.UISourceCode>} | 426 * @return {!Array.<!Workspace.UISourceCode>} |
| 427 */ | 427 */ |
| 428 uiSourceCodes() { | 428 uiSourceCodes() { |
| 429 var result = []; | 429 var result = []; |
| 430 for (var project of this._projects.values()) | 430 for (var project of this._projects.values()) |
| 431 result = result.concat(project.uiSourceCodes()); | 431 result = result.concat(project.uiSourceCodes()); |
| 432 return result; | 432 return result; |
| 433 } | 433 } |
| 434 | 434 |
| 435 /** | 435 /** |
| 436 * @param {boolean} hasExtensions | 436 * @param {boolean} hasExtensions |
| 437 */ | 437 */ |
| 438 setHasResourceContentTrackingExtensions(hasExtensions) { | 438 setHasResourceContentTrackingExtensions(hasExtensions) { |
| 439 this._hasResourceContentTrackingExtensions = hasExtensions; | 439 this._hasResourceContentTrackingExtensions = hasExtensions; |
| 440 } | 440 } |
| 441 | 441 |
| 442 /** | 442 /** |
| 443 * @return {boolean} | 443 * @return {boolean} |
| 444 */ | 444 */ |
| 445 hasResourceContentTrackingExtensions() { | 445 hasResourceContentTrackingExtensions() { |
| 446 return this._hasResourceContentTrackingExtensions; | 446 return this._hasResourceContentTrackingExtensions; |
| 447 } | 447 } |
| 448 }; | 448 }; |
| 449 | 449 |
| 450 /** @enum {symbol} */ | 450 /** @enum {symbol} */ |
| 451 WebInspector.Workspace.Events = { | 451 Workspace.Workspace.Events = { |
| 452 UISourceCodeAdded: Symbol('UISourceCodeAdded'), | 452 UISourceCodeAdded: Symbol('UISourceCodeAdded'), |
| 453 UISourceCodeRemoved: Symbol('UISourceCodeRemoved'), | 453 UISourceCodeRemoved: Symbol('UISourceCodeRemoved'), |
| 454 WorkingCopyChanged: Symbol('WorkingCopyChanged'), | 454 WorkingCopyChanged: Symbol('WorkingCopyChanged'), |
| 455 WorkingCopyCommitted: Symbol('WorkingCopyCommitted'), | 455 WorkingCopyCommitted: Symbol('WorkingCopyCommitted'), |
| 456 WorkingCopyCommittedByUser: Symbol('WorkingCopyCommittedByUser'), | 456 WorkingCopyCommittedByUser: Symbol('WorkingCopyCommittedByUser'), |
| 457 ProjectAdded: Symbol('ProjectAdded'), | 457 ProjectAdded: Symbol('ProjectAdded'), |
| 458 ProjectRemoved: Symbol('ProjectRemoved') | 458 ProjectRemoved: Symbol('ProjectRemoved') |
| 459 }; | 459 }; |
| 460 | 460 |
| 461 /** | 461 /** |
| 462 * @type {!WebInspector.Workspace} | 462 * @type {!Workspace.Workspace} |
| 463 */ | 463 */ |
| 464 WebInspector.workspace; | 464 Workspace.workspace; |
| OLD | NEW |