Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 WebInspector.FileSystemWorkspaceBinding._imageExtensions = WebInspector.Isolated FileSystem.ImageExtensions; | 59 WebInspector.FileSystemWorkspaceBinding._imageExtensions = WebInspector.Isolated FileSystem.ImageExtensions; |
| 60 | 60 |
| 61 WebInspector.FileSystemWorkspaceBinding._lastRequestId = 0; | 61 WebInspector.FileSystemWorkspaceBinding._lastRequestId = 0; |
| 62 | 62 |
| 63 /** | 63 /** |
| 64 * @param {string} fileSystemPath | 64 * @param {string} fileSystemPath |
| 65 * @return {string} | 65 * @return {string} |
| 66 */ | 66 */ |
| 67 WebInspector.FileSystemWorkspaceBinding.projectId = function(fileSystemPath) | 67 WebInspector.FileSystemWorkspaceBinding.projectId = function(fileSystemPath) |
| 68 { | 68 { |
| 69 return "filesystem:" + fileSystemPath; | 69 return "file://" + fileSystemPath; |
| 70 } | 70 } |
| 71 | 71 |
| 72 /** | 72 /** |
| 73 * @param {!WebInspector.UISourceCode} uiSourceCode | |
| 74 * @return {!Array<string>} | |
| 75 */ | |
| 76 WebInspector.FileSystemWorkspaceBinding.relativePath = function(uiSourceCode) | |
| 77 { | |
| 78 var baseURL = /** @type {!WebInspector.FileSystemWorkspaceBinding.FileSystem }*/(uiSourceCode.project())._fileSystemBaseURL; | |
|
dgozman
2015/12/16 07:58:30
assert project type?
pfeldman
2015/12/16 18:02:18
It crashes otherwise.
| |
| 79 return uiSourceCode.path().substring(baseURL.length).split("/"); | |
| 80 } | |
| 81 | |
| 82 /** | |
| 73 * @param {string} extension | 83 * @param {string} extension |
| 74 * @return {!WebInspector.ResourceType} | 84 * @return {!WebInspector.ResourceType} |
| 75 */ | 85 */ |
| 76 WebInspector.FileSystemWorkspaceBinding._contentTypeForExtension = function(exte nsion) | 86 WebInspector.FileSystemWorkspaceBinding._contentTypeForExtension = function(exte nsion) |
| 77 { | 87 { |
| 78 if (WebInspector.FileSystemWorkspaceBinding._styleSheetExtensions.has(extens ion)) | 88 if (WebInspector.FileSystemWorkspaceBinding._styleSheetExtensions.has(extens ion)) |
| 79 return WebInspector.resourceTypes.Stylesheet; | 89 return WebInspector.resourceTypes.Stylesheet; |
| 80 if (WebInspector.FileSystemWorkspaceBinding._documentExtensions.has(extensio n)) | 90 if (WebInspector.FileSystemWorkspaceBinding._documentExtensions.has(extensio n)) |
| 81 return WebInspector.resourceTypes.Document; | 91 return WebInspector.resourceTypes.Document; |
| 82 if (WebInspector.FileSystemWorkspaceBinding._imageExtensions.has(extension)) | 92 if (WebInspector.FileSystemWorkspaceBinding._imageExtensions.has(extension)) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 129 } | 139 } |
| 130 } | 140 } |
| 131 }, | 141 }, |
| 132 | 142 |
| 133 /** | 143 /** |
| 134 * @param {string} projectId | 144 * @param {string} projectId |
| 135 * @return {string} | 145 * @return {string} |
| 136 */ | 146 */ |
| 137 fileSystemPath: function(projectId) | 147 fileSystemPath: function(projectId) |
| 138 { | 148 { |
| 139 var fileSystemPath = projectId.substr("filesystem:".length); | 149 return projectId.substr("file://".length); |
| 140 var normalizedPath = WebInspector.IsolatedFileSystem.normalizePath(fileS ystemPath); | |
| 141 return projectId.substr("filesystem:".length); | |
| 142 }, | 150 }, |
| 143 | 151 |
| 144 /** | 152 /** |
| 145 * @return {number} | 153 * @return {number} |
| 146 */ | 154 */ |
| 147 _nextId: function() | 155 _nextId: function() |
| 148 { | 156 { |
| 149 return ++WebInspector.FileSystemWorkspaceBinding._lastRequestId; | 157 return ++WebInspector.FileSystemWorkspaceBinding._lastRequestId; |
| 150 }, | 158 }, |
| 151 | 159 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 253 * @implements {WebInspector.Project} | 261 * @implements {WebInspector.Project} |
| 254 * @param {!WebInspector.FileSystemWorkspaceBinding} fileSystemWorkspaceBinding | 262 * @param {!WebInspector.FileSystemWorkspaceBinding} fileSystemWorkspaceBinding |
| 255 * @param {!WebInspector.IsolatedFileSystem} isolatedFileSystem | 263 * @param {!WebInspector.IsolatedFileSystem} isolatedFileSystem |
| 256 * @param {!WebInspector.Workspace} workspace | 264 * @param {!WebInspector.Workspace} workspace |
| 257 */ | 265 */ |
| 258 WebInspector.FileSystemWorkspaceBinding.FileSystem = function(fileSystemWorkspac eBinding, isolatedFileSystem, workspace) | 266 WebInspector.FileSystemWorkspaceBinding.FileSystem = function(fileSystemWorkspac eBinding, isolatedFileSystem, workspace) |
| 259 { | 267 { |
| 260 this._fileSystemWorkspaceBinding = fileSystemWorkspaceBinding; | 268 this._fileSystemWorkspaceBinding = fileSystemWorkspaceBinding; |
| 261 this._fileSystem = isolatedFileSystem; | 269 this._fileSystem = isolatedFileSystem; |
| 262 this._fileSystemBaseURL = "file://" + this._fileSystem.normalizedPath() + "/ "; | 270 this._fileSystemBaseURL = "file://" + this._fileSystem.normalizedPath() + "/ "; |
| 271 this._fileSystemPath = this._fileSystem.path(); | |
| 263 | 272 |
| 264 var id = WebInspector.FileSystemWorkspaceBinding.projectId(this._fileSystem. path()); | 273 var id = WebInspector.FileSystemWorkspaceBinding.projectId(this._fileSystemP ath); |
| 265 console.assert(!workspace.project(id)); | 274 console.assert(!workspace.project(id)); |
| 266 | 275 |
| 267 var url = "filesystem:" + this._fileSystem.normalizedPath(); | |
| 268 var normalizedPath = isolatedFileSystem.normalizedPath(); | 276 var normalizedPath = isolatedFileSystem.normalizedPath(); |
| 269 var displayName = normalizedPath.substr(normalizedPath.lastIndexOf("/") + 1) ; | 277 var displayName = normalizedPath.substr(normalizedPath.lastIndexOf("/") + 1) ; |
| 270 | 278 |
| 271 WebInspector.ProjectStore.call(this, workspace, id, WebInspector.projectType s.FileSystem, url, displayName); | 279 WebInspector.ProjectStore.call(this, workspace, id, WebInspector.projectType s.FileSystem, displayName); |
| 272 | 280 |
| 273 workspace.addProject(this); | 281 workspace.addProject(this); |
| 274 this.populate(); | 282 this.populate(); |
| 275 } | 283 } |
| 276 | 284 |
| 277 WebInspector.FileSystemWorkspaceBinding.FileSystem.prototype = { | 285 WebInspector.FileSystemWorkspaceBinding.FileSystem.prototype = { |
| 278 /** | 286 /** |
| 279 * @return {string} | 287 * @return {string} |
| 280 */ | 288 */ |
| 281 fileSystemPath: function() | 289 fileSystemPath: function() |
| 282 { | 290 { |
| 283 return this._fileSystem.path(); | 291 return this._fileSystemPath; |
| 284 }, | 292 }, |
| 285 | 293 |
| 286 /** | 294 /** |
| 287 * @param {!WebInspector.UISourceCode} uiSourceCode | 295 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 288 * @return {string} | 296 * @return {string} |
| 289 */ | 297 */ |
| 290 _filePathForUISourceCode: function(uiSourceCode) | 298 _filePathForUISourceCode: function(uiSourceCode) |
| 291 { | 299 { |
| 292 return "/" + uiSourceCode.path(); | 300 return uiSourceCode.path().substring(("file:// " + this._fileSystemPath) .length); |
| 293 }, | 301 }, |
| 294 | 302 |
| 295 /** | 303 /** |
| 296 * @override | 304 * @override |
| 297 * @param {!WebInspector.UISourceCode} uiSourceCode | 305 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 298 * @param {function(?string)} callback | 306 * @param {function(?string)} callback |
| 299 */ | 307 */ |
| 300 requestFileContent: function(uiSourceCode, callback) | 308 requestFileContent: function(uiSourceCode, callback) |
| 301 { | 309 { |
| 302 var filePath = this._filePathForUISourceCode(uiSourceCode); | 310 var filePath = this._filePathForUISourceCode(uiSourceCode); |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 456 } | 464 } |
| 457 }, | 465 }, |
| 458 | 466 |
| 459 /** | 467 /** |
| 460 * @param {string} query | 468 * @param {string} query |
| 461 * @param {!WebInspector.Progress} progress | 469 * @param {!WebInspector.Progress} progress |
| 462 * @param {function(!Array.<string>)} callback | 470 * @param {function(!Array.<string>)} callback |
| 463 */ | 471 */ |
| 464 _searchInPath: function(query, progress, callback) | 472 _searchInPath: function(query, progress, callback) |
| 465 { | 473 { |
| 466 var requestId = this._fileSystemWorkspaceBinding.registerCallback(innerC allback.bind(this)); | 474 var requestId = this._fileSystemWorkspaceBinding.registerCallback(innerC allback); |
| 467 InspectorFrontendHost.searchInPath(requestId, this._fileSystem.path(), q uery); | 475 InspectorFrontendHost.searchInPath(requestId, this._fileSystem.path(), q uery); |
| 468 | 476 |
| 469 /** | 477 /** |
| 470 * @param {!Array.<string>} files | 478 * @param {!Array.<string>} files |
| 471 * @this {WebInspector.FileSystemWorkspaceBinding.FileSystem} | |
| 472 */ | 479 */ |
| 473 function innerCallback(files) | 480 function innerCallback(files) |
| 474 { | 481 { |
| 475 /** | 482 /** |
| 476 * @param {string} fullPath | 483 * @param {string} fullPath |
| 477 * @this {WebInspector.FileSystemWorkspaceBinding.FileSystem} | 484 * @return {string} |
| 478 */ | 485 */ |
| 479 function trimAndNormalizeFileSystemPath(fullPath) | 486 function trimAndNormalizeFileSystemPath(fullPath) |
| 480 { | 487 { |
| 481 var trimmedPath = fullPath.substr(this._fileSystem.path().length + 1); | 488 fullPath = "file://" + fullPath; |
| 482 if (WebInspector.isWin()) | 489 if (WebInspector.isWin()) |
| 483 trimmedPath = trimmedPath.replace(/\\/g, "/"); | 490 fullPath = fullPath.replace(/\\/g, "/"); |
| 484 return trimmedPath; | 491 return fullPath; |
| 485 } | 492 } |
| 486 | 493 |
| 487 files = files.map(trimAndNormalizeFileSystemPath.bind(this)); | 494 files = files.map(trimAndNormalizeFileSystemPath); |
| 488 progress.worked(1); | 495 progress.worked(1); |
| 489 callback(files); | 496 callback(files); |
| 490 } | 497 } |
| 491 }, | 498 }, |
| 492 | 499 |
| 493 /** | 500 /** |
| 494 * @override | 501 * @override |
| 495 * @param {!WebInspector.Progress} progress | 502 * @param {!WebInspector.Progress} progress |
| 496 */ | 503 */ |
| 497 indexContent: function(progress) | 504 indexContent: function(progress) |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 527 { | 534 { |
| 528 this._fileSystem.requestFilesRecursive(path, this._addFile.bind(this), c allback); | 535 this._fileSystem.requestFilesRecursive(path, this._addFile.bind(this), c allback); |
| 529 }, | 536 }, |
| 530 | 537 |
| 531 /** | 538 /** |
| 532 * @override | 539 * @override |
| 533 * @param {string} path | 540 * @param {string} path |
| 534 */ | 541 */ |
| 535 excludeFolder: function(path) | 542 excludeFolder: function(path) |
| 536 { | 543 { |
| 537 this._fileSystem.addExcludedFolder(path); | 544 var relativeFolder = path.substring("file://".length + this._fileSystemP ath.length); |
| 545 this._fileSystem.addExcludedFolder(relativeFolder); | |
| 546 | |
| 538 var uiSourceCodes = this.uiSourceCodes().slice(); | 547 var uiSourceCodes = this.uiSourceCodes().slice(); |
| 539 for (var i = 0; i < uiSourceCodes.length; ++i) { | 548 for (var i = 0; i < uiSourceCodes.length; ++i) { |
| 540 var uiSourceCode = uiSourceCodes[i]; | 549 var uiSourceCode = uiSourceCodes[i]; |
| 541 if (uiSourceCode.path().startsWith(path.substr(1))) | 550 if (uiSourceCode.path().startsWith(path)) |
| 542 this.removeUISourceCode(uiSourceCode.path()); | 551 this.removeUISourceCode(uiSourceCode.path()); |
| 543 } | 552 } |
| 544 }, | 553 }, |
| 545 | 554 |
| 546 /** | 555 /** |
| 547 * @override | 556 * @override |
| 548 * @param {string} path | 557 * @param {string} path |
| 549 * @param {?string} name | 558 * @param {?string} name |
| 550 * @param {string} content | 559 * @param {string} content |
| 551 * @param {function(?WebInspector.UISourceCode)} callback | 560 * @param {function(?WebInspector.UISourceCode)} callback |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 602 | 611 |
| 603 /** | 612 /** |
| 604 * @param {string} filePath | 613 * @param {string} filePath |
| 605 * @return {!WebInspector.UISourceCode} | 614 * @return {!WebInspector.UISourceCode} |
| 606 */ | 615 */ |
| 607 _addFile: function(filePath) | 616 _addFile: function(filePath) |
| 608 { | 617 { |
| 609 if (!filePath) | 618 if (!filePath) |
| 610 console.assert(false); | 619 console.assert(false); |
| 611 | 620 |
| 612 var slash = filePath.lastIndexOf("/"); | 621 var extension = this._extensionForPath(filePath); |
| 613 var parentPath = filePath.substring(0, slash); | |
| 614 var name = filePath.substring(slash + 1); | |
| 615 | |
| 616 var extension = this._extensionForPath(name); | |
| 617 var contentType = WebInspector.FileSystemWorkspaceBinding._contentTypeFo rExtension(extension); | 622 var contentType = WebInspector.FileSystemWorkspaceBinding._contentTypeFo rExtension(extension); |
| 618 | 623 |
| 619 var uiSourceCode = this.createUISourceCode(parentPath, name, this._fileS ystemBaseURL + filePath, contentType); | 624 var uiSourceCode = this.createUISourceCode(this._fileSystemBaseURL + fil ePath, contentType); |
| 620 this.addUISourceCode(uiSourceCode); | 625 this.addUISourceCode(uiSourceCode); |
| 621 return uiSourceCode; | 626 return uiSourceCode; |
| 622 }, | 627 }, |
| 623 | 628 |
| 624 /** | 629 /** |
| 625 * @param {string} path | 630 * @param {string} path |
| 626 */ | 631 */ |
| 627 _fileChanged: function(path) | 632 _fileChanged: function(path) |
| 628 { | 633 { |
| 629 var uiSourceCode = this.uiSourceCode(path); | 634 var uiSourceCode = this.uiSourceCode(path); |
| 630 if (!uiSourceCode) { | 635 if (!uiSourceCode) { |
| 631 this._addFile(path); | 636 this._addFile(path); |
| 632 return; | 637 return; |
| 633 } | 638 } |
| 634 uiSourceCode.checkContentUpdated(); | 639 uiSourceCode.checkContentUpdated(); |
| 635 }, | 640 }, |
| 636 | 641 |
| 637 dispose: function() | 642 dispose: function() |
| 638 { | 643 { |
| 639 this.removeProject(); | 644 this.removeProject(); |
| 640 }, | 645 }, |
| 641 | 646 |
| 642 __proto__: WebInspector.ProjectStore.prototype | 647 __proto__: WebInspector.ProjectStore.prototype |
| 643 } | 648 } |
| OLD | NEW |