Index: third_party/WebKit/Source/devtools/front_end/bindings/FileSystemWorkspaceBinding.js |
diff --git a/third_party/WebKit/Source/devtools/front_end/bindings/FileSystemWorkspaceBinding.js b/third_party/WebKit/Source/devtools/front_end/bindings/FileSystemWorkspaceBinding.js |
index e827132b4ad9754666fd3e310557735f2cdb7ecd..d5abd2f689a0ebf639f53ae70a38dde166bb3e8a 100644 |
--- a/third_party/WebKit/Source/devtools/front_end/bindings/FileSystemWorkspaceBinding.js |
+++ b/third_party/WebKit/Source/devtools/front_end/bindings/FileSystemWorkspaceBinding.js |
@@ -27,557 +27,521 @@ |
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
*/ |
- |
/** |
- * @constructor |
- * @param {!WebInspector.IsolatedFileSystemManager} isolatedFileSystemManager |
- * @param {!WebInspector.Workspace} workspace |
+ * @unrestricted |
*/ |
-WebInspector.FileSystemWorkspaceBinding = function(isolatedFileSystemManager, workspace) |
-{ |
+WebInspector.FileSystemWorkspaceBinding = class { |
+ /** |
+ * @param {!WebInspector.IsolatedFileSystemManager} isolatedFileSystemManager |
+ * @param {!WebInspector.Workspace} workspace |
+ */ |
+ constructor(isolatedFileSystemManager, workspace) { |
this._isolatedFileSystemManager = isolatedFileSystemManager; |
this._workspace = workspace; |
this._eventListeners = [ |
- this._isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFileSystemManager.Events.FileSystemAdded, this._onFileSystemAdded, this), |
- this._isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFileSystemManager.Events.FileSystemRemoved, this._onFileSystemRemoved, this), |
- this._isolatedFileSystemManager.addEventListener(WebInspector.IsolatedFileSystemManager.Events.FileSystemFilesChanged, this._fileSystemFilesChanged, this) |
+ this._isolatedFileSystemManager.addEventListener( |
+ WebInspector.IsolatedFileSystemManager.Events.FileSystemAdded, this._onFileSystemAdded, this), |
+ this._isolatedFileSystemManager.addEventListener( |
+ WebInspector.IsolatedFileSystemManager.Events.FileSystemRemoved, this._onFileSystemRemoved, this), |
+ this._isolatedFileSystemManager.addEventListener( |
+ WebInspector.IsolatedFileSystemManager.Events.FileSystemFilesChanged, this._fileSystemFilesChanged, this) |
]; |
/** @type {!Map.<string, !WebInspector.FileSystemWorkspaceBinding.FileSystem>} */ |
this._boundFileSystems = new Map(); |
- this._isolatedFileSystemManager.waitForFileSystems() |
- .then(this._onFileSystemsLoaded.bind(this)); |
-}; |
- |
-WebInspector.FileSystemWorkspaceBinding._styleSheetExtensions = new Set(["css", "scss", "sass", "less"]); |
-WebInspector.FileSystemWorkspaceBinding._documentExtensions = new Set(["htm", "html", "asp", "aspx", "phtml", "jsp"]); |
-WebInspector.FileSystemWorkspaceBinding._scriptExtensions = new Set(["asp", "aspx", "c", "cc", "cljs", "coffee", "cpp", "cs", "dart", "java", "js", "jsp", "jsx", "h", "m", "mm", "py", "sh", "ts", "tsx", "ls"]); |
- |
-WebInspector.FileSystemWorkspaceBinding._imageExtensions = WebInspector.IsolatedFileSystem.ImageExtensions; |
- |
-/** |
- * @param {string} fileSystemPath |
- * @return {string} |
- */ |
-WebInspector.FileSystemWorkspaceBinding.projectId = function(fileSystemPath) |
-{ |
+ this._isolatedFileSystemManager.waitForFileSystems().then(this._onFileSystemsLoaded.bind(this)); |
+ } |
+ |
+ /** |
+ * @param {string} fileSystemPath |
+ * @return {string} |
+ */ |
+ static projectId(fileSystemPath) { |
return fileSystemPath; |
-}; |
- |
-/** |
- * @param {!WebInspector.UISourceCode} uiSourceCode |
- * @return {!Array<string>} |
- */ |
-WebInspector.FileSystemWorkspaceBinding.relativePath = function(uiSourceCode) |
-{ |
- var baseURL = /** @type {!WebInspector.FileSystemWorkspaceBinding.FileSystem}*/(uiSourceCode.project())._fileSystemBaseURL; |
- return uiSourceCode.url().substring(baseURL.length).split("/"); |
-}; |
- |
-/** |
- * @param {!WebInspector.Project} project |
- * @param {string} relativePath |
- * @return {string} |
- */ |
-WebInspector.FileSystemWorkspaceBinding.completeURL = function(project, relativePath) |
-{ |
- var fsProject = /** @type {!WebInspector.FileSystemWorkspaceBinding.FileSystem}*/(project); |
+ } |
+ |
+ /** |
+ * @param {!WebInspector.UISourceCode} uiSourceCode |
+ * @return {!Array<string>} |
+ */ |
+ static relativePath(uiSourceCode) { |
+ var baseURL = |
+ /** @type {!WebInspector.FileSystemWorkspaceBinding.FileSystem}*/ (uiSourceCode.project())._fileSystemBaseURL; |
+ return uiSourceCode.url().substring(baseURL.length).split('/'); |
+ } |
+ |
+ /** |
+ * @param {!WebInspector.Project} project |
+ * @param {string} relativePath |
+ * @return {string} |
+ */ |
+ static completeURL(project, relativePath) { |
+ var fsProject = /** @type {!WebInspector.FileSystemWorkspaceBinding.FileSystem}*/ (project); |
return fsProject._fileSystemBaseURL + relativePath; |
-}; |
+ } |
-/** |
- * @param {string} extension |
- * @return {!WebInspector.ResourceType} |
- */ |
-WebInspector.FileSystemWorkspaceBinding._contentTypeForExtension = function(extension) |
-{ |
+ /** |
+ * @param {string} extension |
+ * @return {!WebInspector.ResourceType} |
+ */ |
+ static _contentTypeForExtension(extension) { |
if (WebInspector.FileSystemWorkspaceBinding._styleSheetExtensions.has(extension)) |
- return WebInspector.resourceTypes.Stylesheet; |
+ return WebInspector.resourceTypes.Stylesheet; |
if (WebInspector.FileSystemWorkspaceBinding._documentExtensions.has(extension)) |
- return WebInspector.resourceTypes.Document; |
+ return WebInspector.resourceTypes.Document; |
if (WebInspector.FileSystemWorkspaceBinding._imageExtensions.has(extension)) |
- return WebInspector.resourceTypes.Image; |
+ return WebInspector.resourceTypes.Image; |
if (WebInspector.FileSystemWorkspaceBinding._scriptExtensions.has(extension)) |
- return WebInspector.resourceTypes.Script; |
+ return WebInspector.resourceTypes.Script; |
return WebInspector.resourceTypes.Other; |
-}; |
- |
-WebInspector.FileSystemWorkspaceBinding.prototype = { |
- /** |
- * @return {!WebInspector.IsolatedFileSystemManager} |
- */ |
- fileSystemManager: function() |
- { |
- return this._isolatedFileSystemManager; |
- }, |
- |
- /** |
- * @param {!Array<!WebInspector.IsolatedFileSystem>} fileSystems |
- */ |
- _onFileSystemsLoaded: function(fileSystems) |
- { |
- for (var fileSystem of fileSystems) |
- this._addFileSystem(fileSystem); |
- }, |
+ } |
- /** |
- * @param {!WebInspector.Event} event |
- */ |
- _onFileSystemAdded: function(event) |
- { |
- var fileSystem = /** @type {!WebInspector.IsolatedFileSystem} */ (event.data); |
- this._addFileSystem(fileSystem); |
- }, |
- |
- /** |
- * @param {!WebInspector.IsolatedFileSystem} fileSystem |
- */ |
- _addFileSystem: function(fileSystem) |
- { |
- var boundFileSystem = new WebInspector.FileSystemWorkspaceBinding.FileSystem(this, fileSystem, this._workspace); |
- this._boundFileSystems.set(fileSystem.path(), boundFileSystem); |
- }, |
- |
- /** |
- * @param {!WebInspector.Event} event |
- */ |
- _onFileSystemRemoved: function(event) |
- { |
- var fileSystem = /** @type {!WebInspector.IsolatedFileSystem} */ (event.data); |
- var boundFileSystem = this._boundFileSystems.get(fileSystem.path()); |
- boundFileSystem.dispose(); |
- this._boundFileSystems.remove(fileSystem.path()); |
- }, |
+ /** |
+ * @param {string} projectId |
+ * @return {string} |
+ */ |
+ static fileSystemPath(projectId) { |
+ return projectId; |
+ } |
+ |
+ /** |
+ * @return {!WebInspector.IsolatedFileSystemManager} |
+ */ |
+ fileSystemManager() { |
+ return this._isolatedFileSystemManager; |
+ } |
+ |
+ /** |
+ * @param {!Array<!WebInspector.IsolatedFileSystem>} fileSystems |
+ */ |
+ _onFileSystemsLoaded(fileSystems) { |
+ for (var fileSystem of fileSystems) |
+ this._addFileSystem(fileSystem); |
+ } |
+ |
+ /** |
+ * @param {!WebInspector.Event} event |
+ */ |
+ _onFileSystemAdded(event) { |
+ var fileSystem = /** @type {!WebInspector.IsolatedFileSystem} */ (event.data); |
+ this._addFileSystem(fileSystem); |
+ } |
+ |
+ /** |
+ * @param {!WebInspector.IsolatedFileSystem} fileSystem |
+ */ |
+ _addFileSystem(fileSystem) { |
+ var boundFileSystem = new WebInspector.FileSystemWorkspaceBinding.FileSystem(this, fileSystem, this._workspace); |
+ this._boundFileSystems.set(fileSystem.path(), boundFileSystem); |
+ } |
+ |
+ /** |
+ * @param {!WebInspector.Event} event |
+ */ |
+ _onFileSystemRemoved(event) { |
+ var fileSystem = /** @type {!WebInspector.IsolatedFileSystem} */ (event.data); |
+ var boundFileSystem = this._boundFileSystems.get(fileSystem.path()); |
+ boundFileSystem.dispose(); |
+ this._boundFileSystems.remove(fileSystem.path()); |
+ } |
+ |
+ /** |
+ * @param {!WebInspector.Event} event |
+ */ |
+ _fileSystemFilesChanged(event) { |
+ var paths = /** @type {!Array<string>} */ (event.data); |
+ for (var path of paths) { |
+ for (var key of this._boundFileSystems.keys()) { |
+ if (!path.startsWith(key)) |
+ continue; |
+ this._boundFileSystems.get(key)._fileChanged(path); |
+ } |
+ } |
+ } |
- /** |
- * @param {!WebInspector.Event} event |
- */ |
- _fileSystemFilesChanged: function(event) |
- { |
- var paths = /** @type {!Array<string>} */ (event.data); |
- for (var path of paths) { |
- for (var key of this._boundFileSystems.keys()) { |
- if (!path.startsWith(key)) |
- continue; |
- this._boundFileSystems.get(key)._fileChanged(path); |
- } |
- } |
- }, |
- |
- dispose: function() |
- { |
- WebInspector.EventTarget.removeEventListeners(this._eventListeners); |
- for (var fileSystem of this._boundFileSystems.values()) { |
- fileSystem.dispose(); |
- this._boundFileSystems.remove(fileSystem._fileSystem.path()); |
- } |
+ dispose() { |
+ WebInspector.EventTarget.removeEventListeners(this._eventListeners); |
+ for (var fileSystem of this._boundFileSystems.values()) { |
+ fileSystem.dispose(); |
+ this._boundFileSystems.remove(fileSystem._fileSystem.path()); |
} |
+ } |
}; |
-/** |
- * @param {string} projectId |
- * @return {string} |
- */ |
-WebInspector.FileSystemWorkspaceBinding.fileSystemPath = function(projectId) |
-{ |
- return projectId; |
-}; |
+WebInspector.FileSystemWorkspaceBinding._styleSheetExtensions = new Set(['css', 'scss', 'sass', 'less']); |
+WebInspector.FileSystemWorkspaceBinding._documentExtensions = new Set(['htm', 'html', 'asp', 'aspx', 'phtml', 'jsp']); |
+WebInspector.FileSystemWorkspaceBinding._scriptExtensions = new Set([ |
+ 'asp', 'aspx', 'c', 'cc', 'cljs', 'coffee', 'cpp', 'cs', 'dart', 'java', 'js', |
+ 'jsp', 'jsx', 'h', 'm', 'mm', 'py', 'sh', 'ts', 'tsx', 'ls' |
+]); |
+ |
+WebInspector.FileSystemWorkspaceBinding._imageExtensions = WebInspector.IsolatedFileSystem.ImageExtensions; |
+ |
/** |
- * @constructor |
- * @extends {WebInspector.ProjectStore} |
* @implements {WebInspector.Project} |
- * @param {!WebInspector.FileSystemWorkspaceBinding} fileSystemWorkspaceBinding |
- * @param {!WebInspector.IsolatedFileSystem} isolatedFileSystem |
- * @param {!WebInspector.Workspace} workspace |
+ * @unrestricted |
*/ |
-WebInspector.FileSystemWorkspaceBinding.FileSystem = function(fileSystemWorkspaceBinding, isolatedFileSystem, workspace) |
-{ |
+WebInspector.FileSystemWorkspaceBinding.FileSystem = class extends WebInspector.ProjectStore { |
+ /** |
+ * @param {!WebInspector.FileSystemWorkspaceBinding} fileSystemWorkspaceBinding |
+ * @param {!WebInspector.IsolatedFileSystem} isolatedFileSystem |
+ * @param {!WebInspector.Workspace} workspace |
+ */ |
+ constructor(fileSystemWorkspaceBinding, isolatedFileSystem, workspace) { |
var fileSystemPath = isolatedFileSystem.path(); |
var id = WebInspector.FileSystemWorkspaceBinding.projectId(fileSystemPath); |
console.assert(!workspace.project(id)); |
- var displayName = fileSystemPath.substr(fileSystemPath.lastIndexOf("/") + 1); |
+ var displayName = fileSystemPath.substr(fileSystemPath.lastIndexOf('/') + 1); |
- WebInspector.ProjectStore.call(this, workspace, id, WebInspector.projectTypes.FileSystem, displayName); |
+ super(workspace, id, WebInspector.projectTypes.FileSystem, displayName); |
this._fileSystem = isolatedFileSystem; |
- this._fileSystemBaseURL = this._fileSystem.path() + "/"; |
+ this._fileSystemBaseURL = this._fileSystem.path() + '/'; |
this._fileSystemWorkspaceBinding = fileSystemWorkspaceBinding; |
this._fileSystemPath = fileSystemPath; |
workspace.addProject(this); |
this.populate(); |
-}; |
- |
-WebInspector.FileSystemWorkspaceBinding._metadata = Symbol("FileSystemWorkspaceBinding.Metadata"); |
- |
-WebInspector.FileSystemWorkspaceBinding.FileSystem.prototype = { |
- /** |
- * @return {string} |
- */ |
- fileSystemPath: function() |
- { |
- return this._fileSystemPath; |
- }, |
- |
- /** |
- * @return {!Array<string>} |
- */ |
- gitFolders: function() |
- { |
- return this._fileSystem.gitFolders().map(folder => this._fileSystemPath + "/" + folder); |
- }, |
- |
- /** |
- * @param {!WebInspector.UISourceCode} uiSourceCode |
- * @return {string} |
- */ |
- _filePathForUISourceCode: function(uiSourceCode) |
- { |
- return uiSourceCode.url().substring(this._fileSystemPath.length); |
- }, |
+ } |
+ |
+ /** |
+ * @return {string} |
+ */ |
+ fileSystemPath() { |
+ return this._fileSystemPath; |
+ } |
+ |
+ /** |
+ * @return {!Array<string>} |
+ */ |
+ gitFolders() { |
+ return this._fileSystem.gitFolders().map(folder => this._fileSystemPath + '/' + folder); |
+ } |
+ |
+ /** |
+ * @param {!WebInspector.UISourceCode} uiSourceCode |
+ * @return {string} |
+ */ |
+ _filePathForUISourceCode(uiSourceCode) { |
+ return uiSourceCode.url().substring(this._fileSystemPath.length); |
+ } |
+ |
+ /** |
+ * @override |
+ * @param {!WebInspector.UISourceCode} uiSourceCode |
+ * @return {!Promise<?WebInspector.UISourceCodeMetadata>} |
+ */ |
+ requestMetadata(uiSourceCode) { |
+ if (uiSourceCode[WebInspector.FileSystemWorkspaceBinding._metadata]) |
+ return uiSourceCode[WebInspector.FileSystemWorkspaceBinding._metadata]; |
+ var relativePath = this._filePathForUISourceCode(uiSourceCode); |
+ var promise = this._fileSystem.getMetadata(relativePath).then(onMetadata); |
+ uiSourceCode[WebInspector.FileSystemWorkspaceBinding._metadata] = promise; |
+ return promise; |
/** |
- * @override |
- * @param {!WebInspector.UISourceCode} uiSourceCode |
- * @return {!Promise<?WebInspector.UISourceCodeMetadata>} |
+ * @param {?{modificationTime: !Date, size: number}} metadata |
+ * @return {?WebInspector.UISourceCodeMetadata} |
*/ |
- requestMetadata: function(uiSourceCode) |
- { |
- if (uiSourceCode[WebInspector.FileSystemWorkspaceBinding._metadata]) |
- return uiSourceCode[WebInspector.FileSystemWorkspaceBinding._metadata]; |
- var relativePath = this._filePathForUISourceCode(uiSourceCode); |
- var promise = this._fileSystem.getMetadata(relativePath).then(onMetadata); |
- uiSourceCode[WebInspector.FileSystemWorkspaceBinding._metadata] = promise; |
- return promise; |
- |
- /** |
- * @param {?{modificationTime: !Date, size: number}} metadata |
- * @return {?WebInspector.UISourceCodeMetadata} |
- */ |
- function onMetadata(metadata) |
- { |
- if (!metadata) |
- return null; |
- return new WebInspector.UISourceCodeMetadata(metadata.modificationTime, metadata.size); |
- } |
- }, |
+ function onMetadata(metadata) { |
+ if (!metadata) |
+ return null; |
+ return new WebInspector.UISourceCodeMetadata(metadata.modificationTime, metadata.size); |
+ } |
+ } |
- /** |
- * @override |
- * @param {!WebInspector.UISourceCode} uiSourceCode |
- * @param {function(?string)} callback |
- */ |
- requestFileContent: function(uiSourceCode, callback) |
- { |
- var filePath = this._filePathForUISourceCode(uiSourceCode); |
- var isImage = WebInspector.FileSystemWorkspaceBinding._imageExtensions.has(WebInspector.ParsedURL.extractExtension(filePath)); |
- |
- this._fileSystem.requestFileContent(filePath, isImage ? base64CallbackWrapper : callback); |
- |
- /** |
- * @param {?string} result |
- */ |
- function base64CallbackWrapper(result) |
- { |
- if (!result) { |
- callback(result); |
- return; |
- } |
- var index = result.indexOf(","); |
- callback(result.substring(index + 1)); |
- } |
- }, |
+ /** |
+ * @override |
+ * @param {!WebInspector.UISourceCode} uiSourceCode |
+ * @param {function(?string)} callback |
+ */ |
+ requestFileContent(uiSourceCode, callback) { |
+ var filePath = this._filePathForUISourceCode(uiSourceCode); |
+ var isImage = |
+ WebInspector.FileSystemWorkspaceBinding._imageExtensions.has(WebInspector.ParsedURL.extractExtension(filePath)); |
- /** |
- * @override |
- * @return {boolean} |
- */ |
- canSetFileContent: function() |
- { |
- return true; |
- }, |
+ this._fileSystem.requestFileContent(filePath, isImage ? base64CallbackWrapper : callback); |
/** |
- * @override |
- * @param {!WebInspector.UISourceCode} uiSourceCode |
- * @param {string} newContent |
- * @param {function(?string)} callback |
+ * @param {?string} result |
*/ |
- setFileContent: function(uiSourceCode, newContent, callback) |
- { |
- var filePath = this._filePathForUISourceCode(uiSourceCode); |
- this._fileSystem.setFileContent(filePath, newContent, callback.bind(this, "")); |
- }, |
- |
- /** |
- * @override |
- * @return {boolean} |
- */ |
- canRename: function() |
- { |
- return true; |
- }, |
- |
- /** |
- * @override |
- * @param {!WebInspector.UISourceCode} uiSourceCode |
- * @param {string} newName |
- * @param {function(boolean, string=, string=, !WebInspector.ResourceType=)} callback |
- */ |
- rename: function(uiSourceCode, newName, callback) |
- { |
- if (newName === uiSourceCode.name()) { |
- callback(true, uiSourceCode.name(), uiSourceCode.url(), uiSourceCode.contentType()); |
- return; |
- } |
- |
- var filePath = this._filePathForUISourceCode(uiSourceCode); |
- this._fileSystem.renameFile(filePath, newName, innerCallback.bind(this)); |
- |
- /** |
- * @param {boolean} success |
- * @param {string=} newName |
- * @this {WebInspector.FileSystemWorkspaceBinding.FileSystem} |
- */ |
- function innerCallback(success, newName) |
- { |
- if (!success || !newName) { |
- callback(false, newName); |
- return; |
- } |
- console.assert(newName); |
- var slash = filePath.lastIndexOf("/"); |
- var parentPath = filePath.substring(0, slash); |
- filePath = parentPath + "/" + newName; |
- filePath = filePath.substr(1); |
- var extension = this._extensionForPath(newName); |
- var newURL = this._fileSystemBaseURL + filePath; |
- var newContentType = WebInspector.FileSystemWorkspaceBinding._contentTypeForExtension(extension); |
- this.renameUISourceCode(uiSourceCode, newName); |
- callback(true, newName, newURL, newContentType); |
- } |
- }, |
+ function base64CallbackWrapper(result) { |
+ if (!result) { |
+ callback(result); |
+ return; |
+ } |
+ var index = result.indexOf(','); |
+ callback(result.substring(index + 1)); |
+ } |
+ } |
+ |
+ /** |
+ * @override |
+ * @return {boolean} |
+ */ |
+ canSetFileContent() { |
+ return true; |
+ } |
+ |
+ /** |
+ * @override |
+ * @param {!WebInspector.UISourceCode} uiSourceCode |
+ * @param {string} newContent |
+ * @param {function(?string)} callback |
+ */ |
+ setFileContent(uiSourceCode, newContent, callback) { |
+ var filePath = this._filePathForUISourceCode(uiSourceCode); |
+ this._fileSystem.setFileContent(filePath, newContent, callback.bind(this, '')); |
+ } |
+ |
+ /** |
+ * @override |
+ * @return {boolean} |
+ */ |
+ canRename() { |
+ return true; |
+ } |
+ |
+ /** |
+ * @override |
+ * @param {!WebInspector.UISourceCode} uiSourceCode |
+ * @param {string} newName |
+ * @param {function(boolean, string=, string=, !WebInspector.ResourceType=)} callback |
+ */ |
+ rename(uiSourceCode, newName, callback) { |
+ if (newName === uiSourceCode.name()) { |
+ callback(true, uiSourceCode.name(), uiSourceCode.url(), uiSourceCode.contentType()); |
+ return; |
+ } |
- /** |
- * @override |
- * @param {!WebInspector.UISourceCode} uiSourceCode |
- * @param {string} query |
- * @param {boolean} caseSensitive |
- * @param {boolean} isRegex |
- * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} callback |
- */ |
- searchInFileContent: function(uiSourceCode, query, caseSensitive, isRegex, callback) |
- { |
- var filePath = this._filePathForUISourceCode(uiSourceCode); |
- this._fileSystem.requestFileContent(filePath, contentCallback); |
- |
- /** |
- * @param {?string} content |
- */ |
- function contentCallback(content) |
- { |
- var result = []; |
- if (content !== null) |
- result = WebInspector.ContentProvider.performSearchInContent(content, query, caseSensitive, isRegex); |
- callback(result); |
- } |
- }, |
+ var filePath = this._filePathForUISourceCode(uiSourceCode); |
+ this._fileSystem.renameFile(filePath, newName, innerCallback.bind(this)); |
/** |
- * @override |
- * @param {!WebInspector.ProjectSearchConfig} searchConfig |
- * @param {!Array.<string>} filesMathingFileQuery |
- * @param {!WebInspector.Progress} progress |
- * @param {function(!Array.<string>)} callback |
+ * @param {boolean} success |
+ * @param {string=} newName |
+ * @this {WebInspector.FileSystemWorkspaceBinding.FileSystem} |
*/ |
- findFilesMatchingSearchRequest: function(searchConfig, filesMathingFileQuery, progress, callback) |
- { |
- var result = filesMathingFileQuery; |
- var queriesToRun = searchConfig.queries().slice(); |
- if (!queriesToRun.length) |
- queriesToRun.push(""); |
- progress.setTotalWork(queriesToRun.length); |
- searchNextQuery.call(this); |
- |
- /** |
- * @this {WebInspector.FileSystemWorkspaceBinding.FileSystem} |
- */ |
- function searchNextQuery() |
- { |
- if (!queriesToRun.length) { |
- progress.done(); |
- callback(result); |
- return; |
- } |
- var query = queriesToRun.shift(); |
- this._fileSystem.searchInPath(searchConfig.isRegex() ? "" : query, progress, innerCallback.bind(this)); |
- } |
- |
- /** |
- * @param {!Array.<string>} files |
- * @this {WebInspector.FileSystemWorkspaceBinding.FileSystem} |
- */ |
- function innerCallback(files) |
- { |
- files = files.sort(); |
- progress.worked(1); |
- result = result.intersectOrdered(files, String.naturalOrderComparator); |
- searchNextQuery.call(this); |
- } |
- }, |
- |
- /** |
- * @override |
- * @param {!WebInspector.Progress} progress |
- */ |
- indexContent: function(progress) |
- { |
- this._fileSystem.indexContent(progress); |
- }, |
+ function innerCallback(success, newName) { |
+ if (!success || !newName) { |
+ callback(false, newName); |
+ return; |
+ } |
+ console.assert(newName); |
+ var slash = filePath.lastIndexOf('/'); |
+ var parentPath = filePath.substring(0, slash); |
+ filePath = parentPath + '/' + newName; |
+ filePath = filePath.substr(1); |
+ var extension = this._extensionForPath(newName); |
+ var newURL = this._fileSystemBaseURL + filePath; |
+ var newContentType = WebInspector.FileSystemWorkspaceBinding._contentTypeForExtension(extension); |
+ this.renameUISourceCode(uiSourceCode, newName); |
+ callback(true, newName, newURL, newContentType); |
+ } |
+ } |
+ |
+ /** |
+ * @override |
+ * @param {!WebInspector.UISourceCode} uiSourceCode |
+ * @param {string} query |
+ * @param {boolean} caseSensitive |
+ * @param {boolean} isRegex |
+ * @param {function(!Array.<!WebInspector.ContentProvider.SearchMatch>)} callback |
+ */ |
+ searchInFileContent(uiSourceCode, query, caseSensitive, isRegex, callback) { |
+ var filePath = this._filePathForUISourceCode(uiSourceCode); |
+ this._fileSystem.requestFileContent(filePath, contentCallback); |
/** |
- * @param {string} path |
- * @return {string} |
+ * @param {?string} content |
*/ |
- _extensionForPath: function(path) |
- { |
- var extensionIndex = path.lastIndexOf("."); |
- if (extensionIndex === -1) |
- return ""; |
- return path.substring(extensionIndex + 1).toLowerCase(); |
- }, |
- |
- populate: function() |
- { |
- var chunkSize = 1000; |
- var filePaths = this._fileSystem.filePaths(); |
- reportFileChunk.call(this, 0); |
- |
- /** |
- * @param {number} from |
- * @this {WebInspector.FileSystemWorkspaceBinding.FileSystem} |
- */ |
- function reportFileChunk(from) |
- { |
- var to = Math.min(from + chunkSize, filePaths.length); |
- for (var i = from; i < to; ++i) |
- this._addFile(filePaths[i]); |
- if (to < filePaths.length) |
- setTimeout(reportFileChunk.bind(this, to), 100); |
- } |
- }, |
+ function contentCallback(content) { |
+ var result = []; |
+ if (content !== null) |
+ result = WebInspector.ContentProvider.performSearchInContent(content, query, caseSensitive, isRegex); |
+ callback(result); |
+ } |
+ } |
+ |
+ /** |
+ * @override |
+ * @param {!WebInspector.ProjectSearchConfig} searchConfig |
+ * @param {!Array.<string>} filesMathingFileQuery |
+ * @param {!WebInspector.Progress} progress |
+ * @param {function(!Array.<string>)} callback |
+ */ |
+ findFilesMatchingSearchRequest(searchConfig, filesMathingFileQuery, progress, callback) { |
+ var result = filesMathingFileQuery; |
+ var queriesToRun = searchConfig.queries().slice(); |
+ if (!queriesToRun.length) |
+ queriesToRun.push(''); |
+ progress.setTotalWork(queriesToRun.length); |
+ searchNextQuery.call(this); |
/** |
- * @override |
- * @param {string} url |
+ * @this {WebInspector.FileSystemWorkspaceBinding.FileSystem} |
*/ |
- excludeFolder: function(url) |
- { |
- var relativeFolder = url.substring(this._fileSystemBaseURL.length); |
- if (!relativeFolder.startsWith("/")) |
- relativeFolder = "/" + relativeFolder; |
- if (!relativeFolder.endsWith("/")) |
- relativeFolder += "/"; |
- this._fileSystem.addExcludedFolder(relativeFolder); |
- |
- var uiSourceCodes = this.uiSourceCodes().slice(); |
- for (var i = 0; i < uiSourceCodes.length; ++i) { |
- var uiSourceCode = uiSourceCodes[i]; |
- if (uiSourceCode.url().startsWith(url)) |
- this.removeUISourceCode(uiSourceCode.url()); |
- } |
- }, |
+ function searchNextQuery() { |
+ if (!queriesToRun.length) { |
+ progress.done(); |
+ callback(result); |
+ return; |
+ } |
+ var query = queriesToRun.shift(); |
+ this._fileSystem.searchInPath(searchConfig.isRegex() ? '' : query, progress, innerCallback.bind(this)); |
+ } |
/** |
- * @override |
- * @param {string} path |
- * @param {?string} name |
- * @param {string} content |
- * @param {function(?WebInspector.UISourceCode)} callback |
+ * @param {!Array.<string>} files |
+ * @this {WebInspector.FileSystemWorkspaceBinding.FileSystem} |
*/ |
- createFile: function(path, name, content, callback) |
- { |
- this._fileSystem.createFile(path, name, innerCallback.bind(this)); |
- var createFilePath; |
- |
- /** |
- * @param {?string} filePath |
- * @this {WebInspector.FileSystemWorkspaceBinding.FileSystem} |
- */ |
- function innerCallback(filePath) |
- { |
- if (!filePath) { |
- callback(null); |
- return; |
- } |
- createFilePath = filePath; |
- if (!content) { |
- contentSet.call(this); |
- return; |
- } |
- this._fileSystem.setFileContent(filePath, content, contentSet.bind(this)); |
- } |
- |
- /** |
- * @this {WebInspector.FileSystemWorkspaceBinding.FileSystem} |
- */ |
- function contentSet() |
- { |
- callback(this._addFile(createFilePath)); |
- } |
- }, |
+ function innerCallback(files) { |
+ files = files.sort(); |
+ progress.worked(1); |
+ result = result.intersectOrdered(files, String.naturalOrderComparator); |
+ searchNextQuery.call(this); |
+ } |
+ } |
+ |
+ /** |
+ * @override |
+ * @param {!WebInspector.Progress} progress |
+ */ |
+ indexContent(progress) { |
+ this._fileSystem.indexContent(progress); |
+ } |
+ |
+ /** |
+ * @param {string} path |
+ * @return {string} |
+ */ |
+ _extensionForPath(path) { |
+ var extensionIndex = path.lastIndexOf('.'); |
+ if (extensionIndex === -1) |
+ return ''; |
+ return path.substring(extensionIndex + 1).toLowerCase(); |
+ } |
+ |
+ populate() { |
+ var chunkSize = 1000; |
+ var filePaths = this._fileSystem.filePaths(); |
+ reportFileChunk.call(this, 0); |
/** |
- * @override |
- * @param {string} path |
+ * @param {number} from |
+ * @this {WebInspector.FileSystemWorkspaceBinding.FileSystem} |
*/ |
- deleteFile: function(path) |
- { |
- this._fileSystem.deleteFile(path); |
- this.removeUISourceCode(path); |
- }, |
+ function reportFileChunk(from) { |
+ var to = Math.min(from + chunkSize, filePaths.length); |
+ for (var i = from; i < to; ++i) |
+ this._addFile(filePaths[i]); |
+ if (to < filePaths.length) |
+ setTimeout(reportFileChunk.bind(this, to), 100); |
+ } |
+ } |
+ |
+ /** |
+ * @override |
+ * @param {string} url |
+ */ |
+ excludeFolder(url) { |
+ var relativeFolder = url.substring(this._fileSystemBaseURL.length); |
+ if (!relativeFolder.startsWith('/')) |
+ relativeFolder = '/' + relativeFolder; |
+ if (!relativeFolder.endsWith('/')) |
+ relativeFolder += '/'; |
+ this._fileSystem.addExcludedFolder(relativeFolder); |
+ |
+ var uiSourceCodes = this.uiSourceCodes().slice(); |
+ for (var i = 0; i < uiSourceCodes.length; ++i) { |
+ var uiSourceCode = uiSourceCodes[i]; |
+ if (uiSourceCode.url().startsWith(url)) |
+ this.removeUISourceCode(uiSourceCode.url()); |
+ } |
+ } |
+ |
+ /** |
+ * @override |
+ * @param {string} path |
+ * @param {?string} name |
+ * @param {string} content |
+ * @param {function(?WebInspector.UISourceCode)} callback |
+ */ |
+ createFile(path, name, content, callback) { |
+ this._fileSystem.createFile(path, name, innerCallback.bind(this)); |
+ var createFilePath; |
/** |
- * @override |
+ * @param {?string} filePath |
+ * @this {WebInspector.FileSystemWorkspaceBinding.FileSystem} |
*/ |
- remove: function() |
- { |
- this._fileSystemWorkspaceBinding._isolatedFileSystemManager.removeFileSystem(this._fileSystem); |
- }, |
+ function innerCallback(filePath) { |
+ if (!filePath) { |
+ callback(null); |
+ return; |
+ } |
+ createFilePath = filePath; |
+ if (!content) { |
+ contentSet.call(this); |
+ return; |
+ } |
+ this._fileSystem.setFileContent(filePath, content, contentSet.bind(this)); |
+ } |
/** |
- * @param {string} filePath |
- * @return {!WebInspector.UISourceCode} |
+ * @this {WebInspector.FileSystemWorkspaceBinding.FileSystem} |
*/ |
- _addFile: function(filePath) |
- { |
- var extension = this._extensionForPath(filePath); |
- var contentType = WebInspector.FileSystemWorkspaceBinding._contentTypeForExtension(extension); |
- |
- var uiSourceCode = this.createUISourceCode(this._fileSystemBaseURL + filePath, contentType); |
- this.addUISourceCode(uiSourceCode); |
- return uiSourceCode; |
- }, |
+ function contentSet() { |
+ callback(this._addFile(createFilePath)); |
+ } |
+ } |
+ |
+ /** |
+ * @override |
+ * @param {string} path |
+ */ |
+ deleteFile(path) { |
+ this._fileSystem.deleteFile(path); |
+ this.removeUISourceCode(path); |
+ } |
+ |
+ /** |
+ * @override |
+ */ |
+ remove() { |
+ this._fileSystemWorkspaceBinding._isolatedFileSystemManager.removeFileSystem(this._fileSystem); |
+ } |
+ |
+ /** |
+ * @param {string} filePath |
+ * @return {!WebInspector.UISourceCode} |
+ */ |
+ _addFile(filePath) { |
+ var extension = this._extensionForPath(filePath); |
+ var contentType = WebInspector.FileSystemWorkspaceBinding._contentTypeForExtension(extension); |
+ |
+ var uiSourceCode = this.createUISourceCode(this._fileSystemBaseURL + filePath, contentType); |
+ this.addUISourceCode(uiSourceCode); |
+ return uiSourceCode; |
+ } |
+ |
+ /** |
+ * @param {string} path |
+ */ |
+ _fileChanged(path) { |
+ var uiSourceCode = this.uiSourceCodeForURL(path); |
+ if (!uiSourceCode) { |
+ var contentType = WebInspector.FileSystemWorkspaceBinding._contentTypeForExtension(this._extensionForPath(path)); |
+ this.addUISourceCode(this.createUISourceCode(path, contentType)); |
+ return; |
+ } |
+ uiSourceCode[WebInspector.FileSystemWorkspaceBinding._metadata] = null; |
+ uiSourceCode.checkContentUpdated(); |
+ } |
- /** |
- * @param {string} path |
- */ |
- _fileChanged: function(path) |
- { |
- var uiSourceCode = this.uiSourceCodeForURL(path); |
- if (!uiSourceCode) { |
- var contentType = WebInspector.FileSystemWorkspaceBinding._contentTypeForExtension(this._extensionForPath(path)); |
- this.addUISourceCode(this.createUISourceCode(path, contentType)); |
- return; |
- } |
- uiSourceCode[WebInspector.FileSystemWorkspaceBinding._metadata] = null; |
- uiSourceCode.checkContentUpdated(); |
- }, |
- |
- dispose: function() |
- { |
- this.removeProject(); |
- }, |
- |
- __proto__: WebInspector.ProjectStore.prototype |
+ dispose() { |
+ this.removeProject(); |
+ } |
}; |
+ |
+WebInspector.FileSystemWorkspaceBinding._metadata = Symbol('FileSystemWorkspaceBinding.Metadata'); |