| 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 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 var fileSystem = /** @type {!Workspace.IsolatedFileSystem} */ (event.data); | 143 var fileSystem = /** @type {!Workspace.IsolatedFileSystem} */ (event.data); |
| 144 var boundFileSystem = this._boundFileSystems.get(fileSystem.path()); | 144 var boundFileSystem = this._boundFileSystems.get(fileSystem.path()); |
| 145 boundFileSystem.dispose(); | 145 boundFileSystem.dispose(); |
| 146 this._boundFileSystems.remove(fileSystem.path()); | 146 this._boundFileSystems.remove(fileSystem.path()); |
| 147 } | 147 } |
| 148 | 148 |
| 149 /** | 149 /** |
| 150 * @param {!Common.Event} event | 150 * @param {!Common.Event} event |
| 151 */ | 151 */ |
| 152 _fileSystemFilesChanged(event) { | 152 _fileSystemFilesChanged(event) { |
| 153 var paths = /** @type {!Array<string>} */ (event.data); | 153 var paths = /** @type {!Workspace.IsolatedFileSystemManager.FilesChangedData
} */ (event.data); |
| 154 for (var path of paths) { | 154 forEachFile.call(this, paths.changed, (path, fileSystem) => fileSystem._file
Changed(path)); |
| 155 for (var key of this._boundFileSystems.keys()) { | 155 forEachFile.call(this, paths.added, (path, fileSystem) => fileSystem._fileCh
anged(path)); |
| 156 if (!path.startsWith(key)) | 156 forEachFile.call(this, paths.removed, (path, fileSystem) => fileSystem.remov
eUISourceCode(path)); |
| 157 continue; | 157 |
| 158 this._boundFileSystems.get(key)._fileChanged(path); | 158 /** |
| 159 * @param {!Array<string>} filePaths |
| 160 * @param {function(string, !Persistence.FileSystemWorkspaceBinding.FileSyst
em)} callback |
| 161 * @this {Persistence.FileSystemWorkspaceBinding} |
| 162 */ |
| 163 function forEachFile(filePaths, callback) { |
| 164 for (var filePath of filePaths) { |
| 165 for (var fileSystemPath of this._boundFileSystems.keys()) { |
| 166 if (!filePath.startsWith(fileSystemPath)) |
| 167 continue; |
| 168 callback(filePath, this._boundFileSystems.get(fileSystemPath)); |
| 169 } |
| 159 } | 170 } |
| 160 } | 171 } |
| 161 } | 172 } |
| 162 | 173 |
| 163 dispose() { | 174 dispose() { |
| 164 Common.EventTarget.removeEventListeners(this._eventListeners); | 175 Common.EventTarget.removeEventListeners(this._eventListeners); |
| 165 for (var fileSystem of this._boundFileSystems.values()) { | 176 for (var fileSystem of this._boundFileSystems.values()) { |
| 166 fileSystem.dispose(); | 177 fileSystem.dispose(); |
| 167 this._boundFileSystems.remove(fileSystem._fileSystem.path()); | 178 this._boundFileSystems.remove(fileSystem._fileSystem.path()); |
| 168 } | 179 } |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 /** | 232 /** |
| 222 * @return {string} | 233 * @return {string} |
| 223 */ | 234 */ |
| 224 fileSystemPath() { | 235 fileSystemPath() { |
| 225 return this._fileSystemPath; | 236 return this._fileSystemPath; |
| 226 } | 237 } |
| 227 | 238 |
| 228 /** | 239 /** |
| 229 * @return {!Array<string>} | 240 * @return {!Array<string>} |
| 230 */ | 241 */ |
| 231 gitFolders() { | 242 initialGitFolders() { |
| 232 return this._fileSystem.gitFolders().map(folder => this._fileSystemPath + '/
' + folder); | 243 return this._fileSystem.initialGitFolders().map(folder => this._fileSystemPa
th + '/' + folder); |
| 233 } | 244 } |
| 234 | 245 |
| 235 /** | 246 /** |
| 236 * @param {!Workspace.UISourceCode} uiSourceCode | 247 * @param {!Workspace.UISourceCode} uiSourceCode |
| 237 * @return {string} | 248 * @return {string} |
| 238 */ | 249 */ |
| 239 _filePathForUISourceCode(uiSourceCode) { | 250 _filePathForUISourceCode(uiSourceCode) { |
| 240 return uiSourceCode.url().substring(this._fileSystemPath.length); | 251 return uiSourceCode.url().substring(this._fileSystemPath.length); |
| 241 } | 252 } |
| 242 | 253 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 450 */ | 461 */ |
| 451 _extensionForPath(path) { | 462 _extensionForPath(path) { |
| 452 var extensionIndex = path.lastIndexOf('.'); | 463 var extensionIndex = path.lastIndexOf('.'); |
| 453 if (extensionIndex === -1) | 464 if (extensionIndex === -1) |
| 454 return ''; | 465 return ''; |
| 455 return path.substring(extensionIndex + 1).toLowerCase(); | 466 return path.substring(extensionIndex + 1).toLowerCase(); |
| 456 } | 467 } |
| 457 | 468 |
| 458 populate() { | 469 populate() { |
| 459 var chunkSize = 1000; | 470 var chunkSize = 1000; |
| 460 var filePaths = this._fileSystem.filePaths(); | 471 var filePaths = this._fileSystem.initialFilePaths(); |
| 461 reportFileChunk.call(this, 0); | 472 reportFileChunk.call(this, 0); |
| 462 | 473 |
| 463 /** | 474 /** |
| 464 * @param {number} from | 475 * @param {number} from |
| 465 * @this {Persistence.FileSystemWorkspaceBinding.FileSystem} | 476 * @this {Persistence.FileSystemWorkspaceBinding.FileSystem} |
| 466 */ | 477 */ |
| 467 function reportFileChunk(from) { | 478 function reportFileChunk(from) { |
| 468 var to = Math.min(from + chunkSize, filePaths.length); | 479 var to = Math.min(from + chunkSize, filePaths.length); |
| 469 for (var i = from; i < to; ++i) | 480 for (var i = from; i < to; ++i) |
| 470 this._addFile(filePaths[i]); | 481 this._addFile(filePaths[i]); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 571 uiSourceCode[Persistence.FileSystemWorkspaceBinding._metadata] = null; | 582 uiSourceCode[Persistence.FileSystemWorkspaceBinding._metadata] = null; |
| 572 uiSourceCode.checkContentUpdated(); | 583 uiSourceCode.checkContentUpdated(); |
| 573 } | 584 } |
| 574 | 585 |
| 575 dispose() { | 586 dispose() { |
| 576 this.removeProject(); | 587 this.removeProject(); |
| 577 } | 588 } |
| 578 }; | 589 }; |
| 579 | 590 |
| 580 Persistence.FileSystemWorkspaceBinding._metadata = Symbol('FileSystemWorkspaceBi
nding.Metadata'); | 591 Persistence.FileSystemWorkspaceBinding._metadata = Symbol('FileSystemWorkspaceBi
nding.Metadata'); |
| OLD | NEW |