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 21 matching lines...) Expand all Loading... | |
32 * @constructor | 32 * @constructor |
33 * @param {!WebInspector.IsolatedFileSystemManager} isolatedFileSystemManager | 33 * @param {!WebInspector.IsolatedFileSystemManager} isolatedFileSystemManager |
34 * @param {!WebInspector.Workspace} workspace | 34 * @param {!WebInspector.Workspace} workspace |
35 */ | 35 */ |
36 WebInspector.FileSystemWorkspaceBinding = function(isolatedFileSystemManager, wo rkspace) | 36 WebInspector.FileSystemWorkspaceBinding = function(isolatedFileSystemManager, wo rkspace) |
37 { | 37 { |
38 this._isolatedFileSystemManager = isolatedFileSystemManager; | 38 this._isolatedFileSystemManager = isolatedFileSystemManager; |
39 this._workspace = workspace; | 39 this._workspace = workspace; |
40 this._isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFileSy stemManager.Events.FileSystemAdded, this._fileSystemAdded, this); | 40 this._isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFileSy stemManager.Events.FileSystemAdded, this._fileSystemAdded, this); |
41 this._isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFileSy stemManager.Events.FileSystemRemoved, this._fileSystemRemoved, this); | 41 this._isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFileSy stemManager.Events.FileSystemRemoved, this._fileSystemRemoved, this); |
42 this._isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFileSy stemManager.Events.FileSystemFilesChanged, this._fileSystemFilesChanged, this); | |
42 /** @type {!Map.<string, !WebInspector.FileSystemWorkspaceBinding.FileSystem >} */ | 43 /** @type {!Map.<string, !WebInspector.FileSystemWorkspaceBinding.FileSystem >} */ |
43 this._boundFileSystems = new Map(); | 44 this._boundFileSystems = new Map(); |
44 | 45 |
45 /** @type {!Object.<number, function(!Array.<string>)>} */ | 46 /** @type {!Object.<number, function(!Array.<string>)>} */ |
46 this._callbacks = {}; | 47 this._callbacks = {}; |
47 /** @type {!Object.<number, !WebInspector.Progress>} */ | 48 /** @type {!Object.<number, !WebInspector.Progress>} */ |
48 this._progresses = {}; | 49 this._progresses = {}; |
49 | 50 |
50 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event s.IndexingTotalWorkCalculated, this._onIndexingTotalWorkCalculated, this); | 51 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event s.IndexingTotalWorkCalculated, this._onIndexingTotalWorkCalculated, this); |
51 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event s.IndexingWorked, this._onIndexingWorked, this); | 52 InspectorFrontendHost.events.addEventListener(InspectorFrontendHostAPI.Event s.IndexingWorked, this._onIndexingWorked, this); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 */ | 92 */ |
92 _fileSystemRemoved: function(event) | 93 _fileSystemRemoved: function(event) |
93 { | 94 { |
94 var fileSystem = /** @type {!WebInspector.IsolatedFileSystem} */ (event. data); | 95 var fileSystem = /** @type {!WebInspector.IsolatedFileSystem} */ (event. data); |
95 var boundFileSystem = this._boundFileSystems.get(fileSystem.normalizedPa th()); | 96 var boundFileSystem = this._boundFileSystems.get(fileSystem.normalizedPa th()); |
96 boundFileSystem.dispose(); | 97 boundFileSystem.dispose(); |
97 this._boundFileSystems.remove(fileSystem.normalizedPath()); | 98 this._boundFileSystems.remove(fileSystem.normalizedPath()); |
98 }, | 99 }, |
99 | 100 |
100 /** | 101 /** |
102 * @param {!WebInspector.Event} event | |
103 */ | |
104 _fileSystemFilesChanged: function(event) | |
105 { | |
106 var paths = /** @type {!Array<string>} */ (event.data); | |
107 for (var path of paths) { | |
108 var normalizedPath = WebInspector.IsolatedFileSystem.normalizePath(p ath); | |
109 for (var key of this._boundFileSystems.keys()) { | |
110 if (!normalizedPath.startsWith(key)) | |
111 continue; | |
112 this._boundFileSystems.get(key)._fileChanged(normalizedPath.subs tr(key.length + 1)); | |
113 } | |
114 } | |
115 }, | |
116 | |
117 /** | |
101 * @param {string} projectId | 118 * @param {string} projectId |
102 * @return {string} | 119 * @return {string} |
103 */ | 120 */ |
104 fileSystemPath: function(projectId) | 121 fileSystemPath: function(projectId) |
105 { | 122 { |
106 var fileSystemPath = projectId.substr("filesystem:".length); | 123 var fileSystemPath = projectId.substr("filesystem:".length); |
107 var normalizedPath = WebInspector.IsolatedFileSystem.normalizePath(fileS ystemPath); | 124 var normalizedPath = WebInspector.IsolatedFileSystem.normalizePath(fileS ystemPath); |
108 return projectId.substr("filesystem:".length); | 125 return projectId.substr("filesystem:".length); |
109 }, | 126 }, |
110 | 127 |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
226 { | 243 { |
227 WebInspector.Object.call(this); | 244 WebInspector.Object.call(this); |
228 this._fileSystemWorkspaceBinding = fileSystemWorkspaceBinding; | 245 this._fileSystemWorkspaceBinding = fileSystemWorkspaceBinding; |
229 this._fileSystem = isolatedFileSystem; | 246 this._fileSystem = isolatedFileSystem; |
230 this._fileSystemBaseURL = "file://" + this._fileSystem.normalizedPath() + "/ "; | 247 this._fileSystemBaseURL = "file://" + this._fileSystem.normalizedPath() + "/ "; |
231 this._fileSystemProjectURL = "filesystem:" + this._fileSystem.normalizedPath (); | 248 this._fileSystemProjectURL = "filesystem:" + this._fileSystem.normalizedPath (); |
232 this._workspace = workspace; | 249 this._workspace = workspace; |
233 | 250 |
234 this._projectId = WebInspector.FileSystemWorkspaceBinding.projectId(this._fi leSystem.path()); | 251 this._projectId = WebInspector.FileSystemWorkspaceBinding.projectId(this._fi leSystem.path()); |
235 console.assert(!this._workspace.project(this._projectId)); | 252 console.assert(!this._workspace.project(this._projectId)); |
236 this._workspace.addProject(this._projectId, this); | 253 this._project = this._workspace.addProject(this._projectId, this); |
237 this.populate(); | 254 this.populate(); |
238 } | 255 } |
239 | 256 |
240 WebInspector.FileSystemWorkspaceBinding.FileSystem.prototype = { | 257 WebInspector.FileSystemWorkspaceBinding.FileSystem.prototype = { |
241 /** | 258 /** |
242 * @override | 259 * @override |
243 * @return {string} | 260 * @return {string} |
244 */ | 261 */ |
245 type: function() | 262 type: function() |
246 { | 263 { |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
610 }, | 627 }, |
611 | 628 |
612 /** | 629 /** |
613 * @param {string} path | 630 * @param {string} path |
614 */ | 631 */ |
615 _removeFile: function(path) | 632 _removeFile: function(path) |
616 { | 633 { |
617 this.dispatchEventToListeners(WebInspector.ProjectDelegate.Events.FileRe moved, path); | 634 this.dispatchEventToListeners(WebInspector.ProjectDelegate.Events.FileRe moved, path); |
618 }, | 635 }, |
619 | 636 |
637 /** | |
638 * @param {string} path | |
639 */ | |
640 _fileChanged: function(path) | |
641 { | |
642 var uiSourceCode = this._project.uiSourceCode(path); | |
643 if (!uiSourceCode) { | |
644 this._addFile(path); | |
645 return; | |
646 } | |
647 this.dispatchEventToListeners(WebInspector.ProjectDelegate.Events.FileCh anged, path); | |
dgozman
2015/11/05 01:13:50
If you already have uiSourceCode here, why issue a
| |
648 }, | |
649 | |
620 dispose: function() | 650 dispose: function() |
621 { | 651 { |
622 this._workspace.removeProject(this._projectId); | 652 this._workspace.removeProject(this._projectId); |
623 }, | 653 }, |
624 | 654 |
625 __proto__: WebInspector.Object.prototype | 655 __proto__: WebInspector.Object.prototype |
626 } | 656 } |
OLD | NEW |