| 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 28 matching lines...) Expand all Loading... |
| 39 this._workspace = workspace; | 39 this._workspace = workspace; |
| 40 this._eventListeners = [ | 40 this._eventListeners = [ |
| 41 this._isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFi
leSystemManager.Events.FileSystemAdded, this._onFileSystemAdded, this), | 41 this._isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFi
leSystemManager.Events.FileSystemAdded, this._onFileSystemAdded, this), |
| 42 this._isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFi
leSystemManager.Events.FileSystemRemoved, this._onFileSystemRemoved, this), | 42 this._isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFi
leSystemManager.Events.FileSystemRemoved, this._onFileSystemRemoved, this), |
| 43 this._isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFi
leSystemManager.Events.FileSystemFilesChanged, this._fileSystemFilesChanged, thi
s) | 43 this._isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFi
leSystemManager.Events.FileSystemFilesChanged, this._fileSystemFilesChanged, thi
s) |
| 44 ]; | 44 ]; |
| 45 /** @type {!Map.<string, !WebInspector.FileSystemWorkspaceBinding.FileSystem
>} */ | 45 /** @type {!Map.<string, !WebInspector.FileSystemWorkspaceBinding.FileSystem
>} */ |
| 46 this._boundFileSystems = new Map(); | 46 this._boundFileSystems = new Map(); |
| 47 this._isolatedFileSystemManager.waitForFileSystems() | 47 this._isolatedFileSystemManager.waitForFileSystems() |
| 48 .then(this._onFileSystemsLoaded.bind(this)); | 48 .then(this._onFileSystemsLoaded.bind(this)); |
| 49 } | 49 }; |
| 50 | 50 |
| 51 WebInspector.FileSystemWorkspaceBinding._styleSheetExtensions = new Set(["css",
"scss", "sass", "less"]); | 51 WebInspector.FileSystemWorkspaceBinding._styleSheetExtensions = new Set(["css",
"scss", "sass", "less"]); |
| 52 WebInspector.FileSystemWorkspaceBinding._documentExtensions = new Set(["htm", "h
tml", "asp", "aspx", "phtml", "jsp"]); | 52 WebInspector.FileSystemWorkspaceBinding._documentExtensions = new Set(["htm", "h
tml", "asp", "aspx", "phtml", "jsp"]); |
| 53 WebInspector.FileSystemWorkspaceBinding._scriptExtensions = new Set(["asp", "asp
x", "c", "cc", "cljs", "coffee", "cpp", "cs", "dart", "java", "js", "jsp", "jsx"
, "h", "m", "mm", "py", "sh", "ts", "tsx", "ls"]); | 53 WebInspector.FileSystemWorkspaceBinding._scriptExtensions = new Set(["asp", "asp
x", "c", "cc", "cljs", "coffee", "cpp", "cs", "dart", "java", "js", "jsp", "jsx"
, "h", "m", "mm", "py", "sh", "ts", "tsx", "ls"]); |
| 54 | 54 |
| 55 WebInspector.FileSystemWorkspaceBinding._imageExtensions = WebInspector.Isolated
FileSystem.ImageExtensions; | 55 WebInspector.FileSystemWorkspaceBinding._imageExtensions = WebInspector.Isolated
FileSystem.ImageExtensions; |
| 56 | 56 |
| 57 /** | 57 /** |
| 58 * @param {string} fileSystemPath | 58 * @param {string} fileSystemPath |
| 59 * @return {string} | 59 * @return {string} |
| 60 */ | 60 */ |
| 61 WebInspector.FileSystemWorkspaceBinding.projectId = function(fileSystemPath) | 61 WebInspector.FileSystemWorkspaceBinding.projectId = function(fileSystemPath) |
| 62 { | 62 { |
| 63 return fileSystemPath; | 63 return fileSystemPath; |
| 64 } | 64 }; |
| 65 | 65 |
| 66 /** | 66 /** |
| 67 * @param {!WebInspector.UISourceCode} uiSourceCode | 67 * @param {!WebInspector.UISourceCode} uiSourceCode |
| 68 * @return {!Array<string>} | 68 * @return {!Array<string>} |
| 69 */ | 69 */ |
| 70 WebInspector.FileSystemWorkspaceBinding.relativePath = function(uiSourceCode) | 70 WebInspector.FileSystemWorkspaceBinding.relativePath = function(uiSourceCode) |
| 71 { | 71 { |
| 72 var baseURL = /** @type {!WebInspector.FileSystemWorkspaceBinding.FileSystem
}*/(uiSourceCode.project())._fileSystemBaseURL; | 72 var baseURL = /** @type {!WebInspector.FileSystemWorkspaceBinding.FileSystem
}*/(uiSourceCode.project())._fileSystemBaseURL; |
| 73 return uiSourceCode.url().substring(baseURL.length).split("/"); | 73 return uiSourceCode.url().substring(baseURL.length).split("/"); |
| 74 } | 74 }; |
| 75 | 75 |
| 76 /** | 76 /** |
| 77 * @param {!WebInspector.Project} project | 77 * @param {!WebInspector.Project} project |
| 78 * @param {string} relativePath | 78 * @param {string} relativePath |
| 79 * @return {string} | 79 * @return {string} |
| 80 */ | 80 */ |
| 81 WebInspector.FileSystemWorkspaceBinding.completeURL = function(project, relative
Path) | 81 WebInspector.FileSystemWorkspaceBinding.completeURL = function(project, relative
Path) |
| 82 { | 82 { |
| 83 var fsProject = /** @type {!WebInspector.FileSystemWorkspaceBinding.FileSyst
em}*/(project); | 83 var fsProject = /** @type {!WebInspector.FileSystemWorkspaceBinding.FileSyst
em}*/(project); |
| 84 return fsProject._fileSystemBaseURL + relativePath; | 84 return fsProject._fileSystemBaseURL + relativePath; |
| 85 } | 85 }; |
| 86 | 86 |
| 87 /** | 87 /** |
| 88 * @param {string} extension | 88 * @param {string} extension |
| 89 * @return {!WebInspector.ResourceType} | 89 * @return {!WebInspector.ResourceType} |
| 90 */ | 90 */ |
| 91 WebInspector.FileSystemWorkspaceBinding._contentTypeForExtension = function(exte
nsion) | 91 WebInspector.FileSystemWorkspaceBinding._contentTypeForExtension = function(exte
nsion) |
| 92 { | 92 { |
| 93 if (WebInspector.FileSystemWorkspaceBinding._styleSheetExtensions.has(extens
ion)) | 93 if (WebInspector.FileSystemWorkspaceBinding._styleSheetExtensions.has(extens
ion)) |
| 94 return WebInspector.resourceTypes.Stylesheet; | 94 return WebInspector.resourceTypes.Stylesheet; |
| 95 if (WebInspector.FileSystemWorkspaceBinding._documentExtensions.has(extensio
n)) | 95 if (WebInspector.FileSystemWorkspaceBinding._documentExtensions.has(extensio
n)) |
| 96 return WebInspector.resourceTypes.Document; | 96 return WebInspector.resourceTypes.Document; |
| 97 if (WebInspector.FileSystemWorkspaceBinding._imageExtensions.has(extension)) | 97 if (WebInspector.FileSystemWorkspaceBinding._imageExtensions.has(extension)) |
| 98 return WebInspector.resourceTypes.Image; | 98 return WebInspector.resourceTypes.Image; |
| 99 if (WebInspector.FileSystemWorkspaceBinding._scriptExtensions.has(extension)
) | 99 if (WebInspector.FileSystemWorkspaceBinding._scriptExtensions.has(extension)
) |
| 100 return WebInspector.resourceTypes.Script; | 100 return WebInspector.resourceTypes.Script; |
| 101 return WebInspector.resourceTypes.Other; | 101 return WebInspector.resourceTypes.Other; |
| 102 } | 102 }; |
| 103 | 103 |
| 104 WebInspector.FileSystemWorkspaceBinding.prototype = { | 104 WebInspector.FileSystemWorkspaceBinding.prototype = { |
| 105 /** | 105 /** |
| 106 * @return {!WebInspector.IsolatedFileSystemManager} | 106 * @return {!WebInspector.IsolatedFileSystemManager} |
| 107 */ | 107 */ |
| 108 fileSystemManager: function() | 108 fileSystemManager: function() |
| 109 { | 109 { |
| 110 return this._isolatedFileSystemManager; | 110 return this._isolatedFileSystemManager; |
| 111 }, | 111 }, |
| 112 | 112 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 }, | 164 }, |
| 165 | 165 |
| 166 dispose: function() | 166 dispose: function() |
| 167 { | 167 { |
| 168 WebInspector.EventTarget.removeEventListeners(this._eventListeners); | 168 WebInspector.EventTarget.removeEventListeners(this._eventListeners); |
| 169 for (var fileSystem of this._boundFileSystems.values()) { | 169 for (var fileSystem of this._boundFileSystems.values()) { |
| 170 fileSystem.dispose(); | 170 fileSystem.dispose(); |
| 171 this._boundFileSystems.remove(fileSystem._fileSystem.path()); | 171 this._boundFileSystems.remove(fileSystem._fileSystem.path()); |
| 172 } | 172 } |
| 173 } | 173 } |
| 174 } | 174 }; |
| 175 | 175 |
| 176 /** | 176 /** |
| 177 * @param {string} projectId | 177 * @param {string} projectId |
| 178 * @return {string} | 178 * @return {string} |
| 179 */ | 179 */ |
| 180 WebInspector.FileSystemWorkspaceBinding.fileSystemPath = function(projectId) | 180 WebInspector.FileSystemWorkspaceBinding.fileSystemPath = function(projectId) |
| 181 { | 181 { |
| 182 return projectId; | 182 return projectId; |
| 183 } | 183 }; |
| 184 | 184 |
| 185 /** | 185 /** |
| 186 * @constructor | 186 * @constructor |
| 187 * @extends {WebInspector.ProjectStore} | 187 * @extends {WebInspector.ProjectStore} |
| 188 * @implements {WebInspector.Project} | 188 * @implements {WebInspector.Project} |
| 189 * @param {!WebInspector.FileSystemWorkspaceBinding} fileSystemWorkspaceBinding | 189 * @param {!WebInspector.FileSystemWorkspaceBinding} fileSystemWorkspaceBinding |
| 190 * @param {!WebInspector.IsolatedFileSystem} isolatedFileSystem | 190 * @param {!WebInspector.IsolatedFileSystem} isolatedFileSystem |
| 191 * @param {!WebInspector.Workspace} workspace | 191 * @param {!WebInspector.Workspace} workspace |
| 192 */ | 192 */ |
| 193 WebInspector.FileSystemWorkspaceBinding.FileSystem = function(fileSystemWorkspac
eBinding, isolatedFileSystem, workspace) | 193 WebInspector.FileSystemWorkspaceBinding.FileSystem = function(fileSystemWorkspac
eBinding, isolatedFileSystem, workspace) |
| 194 { | 194 { |
| 195 this._fileSystemWorkspaceBinding = fileSystemWorkspaceBinding; | 195 this._fileSystemWorkspaceBinding = fileSystemWorkspaceBinding; |
| 196 this._fileSystem = isolatedFileSystem; | 196 this._fileSystem = isolatedFileSystem; |
| 197 this._fileSystemBaseURL = this._fileSystem.path() + "/"; | 197 this._fileSystemBaseURL = this._fileSystem.path() + "/"; |
| 198 this._fileSystemPath = this._fileSystem.path(); | 198 this._fileSystemPath = this._fileSystem.path(); |
| 199 | 199 |
| 200 var id = WebInspector.FileSystemWorkspaceBinding.projectId(this._fileSystemP
ath); | 200 var id = WebInspector.FileSystemWorkspaceBinding.projectId(this._fileSystemP
ath); |
| 201 console.assert(!workspace.project(id)); | 201 console.assert(!workspace.project(id)); |
| 202 | 202 |
| 203 var displayName = this._fileSystemPath.substr(this._fileSystemPath.lastIndex
Of("/") + 1); | 203 var displayName = this._fileSystemPath.substr(this._fileSystemPath.lastIndex
Of("/") + 1); |
| 204 WebInspector.ProjectStore.call(this, workspace, id, WebInspector.projectType
s.FileSystem, displayName); | 204 WebInspector.ProjectStore.call(this, workspace, id, WebInspector.projectType
s.FileSystem, displayName); |
| 205 | 205 |
| 206 workspace.addProject(this); | 206 workspace.addProject(this); |
| 207 this.populate(); | 207 this.populate(); |
| 208 } | 208 }; |
| 209 | 209 |
| 210 WebInspector.FileSystemWorkspaceBinding._metadata = Symbol("FileSystemWorkspaceB
inding.Metadata"); | 210 WebInspector.FileSystemWorkspaceBinding._metadata = Symbol("FileSystemWorkspaceB
inding.Metadata"); |
| 211 | 211 |
| 212 WebInspector.FileSystemWorkspaceBinding.FileSystem.prototype = { | 212 WebInspector.FileSystemWorkspaceBinding.FileSystem.prototype = { |
| 213 /** | 213 /** |
| 214 * @return {string} | 214 * @return {string} |
| 215 */ | 215 */ |
| 216 fileSystemPath: function() | 216 fileSystemPath: function() |
| 217 { | 217 { |
| 218 return this._fileSystemPath; | 218 return this._fileSystemPath; |
| (...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 564 uiSourceCode[WebInspector.FileSystemWorkspaceBinding._metadata] = null; | 564 uiSourceCode[WebInspector.FileSystemWorkspaceBinding._metadata] = null; |
| 565 uiSourceCode.checkContentUpdated(); | 565 uiSourceCode.checkContentUpdated(); |
| 566 }, | 566 }, |
| 567 | 567 |
| 568 dispose: function() | 568 dispose: function() |
| 569 { | 569 { |
| 570 this.removeProject(); | 570 this.removeProject(); |
| 571 }, | 571 }, |
| 572 | 572 |
| 573 __proto__: WebInspector.ProjectStore.prototype | 573 __proto__: WebInspector.ProjectStore.prototype |
| 574 } | 574 }; |
| OLD | NEW |