From 9c7386d8136a5d39ca98720c31ac209a3db2211e Mon Sep 17 00:00:00 2001 From: Triangle717 Date: Tue, 21 Oct 2014 15:06:59 -0400 Subject: [PATCH 1/2] Remove deprecated file system APIs adobe/brackets#6127 adobe/brackets#8751 --- src/brackets.js | 7 +- src/file/NativeFileError.js | 53 ------ src/file/NativeFileSystem.js | 284 -------------------------------- src/project/FileIndexManager.js | 84 ---------- 4 files changed, 1 insertion(+), 427 deletions(-) delete mode 100644 src/file/NativeFileError.js delete mode 100644 src/file/NativeFileSystem.js delete mode 100644 src/project/FileIndexManager.js diff --git a/src/brackets.js b/src/brackets.js index e0d5e728334..2de59d0448f 100644 --- a/src/brackets.js +++ b/src/brackets.js @@ -45,7 +45,7 @@ define(function (require, exports, module) { require("thirdparty/path-utils/path-utils.min"); require("thirdparty/smart-auto-complete-local/jquery.smart_autocomplete"); - // Load CodeMirror add-ons--these attach themselves to the CodeMirror module + // Load CodeMirror add-ons--these attach themselves to the CodeMirror module require("thirdparty/CodeMirror2/addon/fold/xml-fold"); require("thirdparty/CodeMirror2/addon/edit/matchtags"); require("thirdparty/CodeMirror2/addon/edit/matchbrackets"); @@ -135,11 +135,6 @@ define(function (require, exports, module) { require("extensibility/ExtensionManagerDialog"); require("editor/ImageViewer"); - // Compatibility shims for filesystem API migration - require("project/FileIndexManager"); - require("file/NativeFileSystem"); - require("file/NativeFileError"); - // Compatibility shim for PanelManager to WorkspaceManager migration require("view/PanelManager"); diff --git a/src/file/NativeFileError.js b/src/file/NativeFileError.js deleted file mode 100644 index 4858c15d207..00000000000 --- a/src/file/NativeFileError.js +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - */ - -/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50*/ -/*global define */ - -/** - * @deprecated - * This is a compatibility shim for legacy Brackets APIs that will be removed soon. These - * error codes are *never* returned anymore. Use error codes in FileSystemError instead. - */ -define(function () { - "use strict"; - - /** - * @deprecated - */ - var NativeFileError = {}; - - NativeFileError.NOT_FOUND_ERR = "NotFoundError"; - NativeFileError.SECURITY_ERR = "SecurityError"; - NativeFileError.ABORT_ERR = "AbortError"; - NativeFileError.NOT_READABLE_ERR = "NotReadableError"; - NativeFileError.NO_MODIFICATION_ALLOWED_ERR = "NoModificationAllowedError"; - NativeFileError.INVALID_STATE_ERR = "InvalidStateError"; - NativeFileError.SYNTAX_ERR = "SyntaxError"; - NativeFileError.INVALID_MODIFICATION_ERR = "InvalidModificationError"; - NativeFileError.QUOTA_EXCEEDED_ERR = "QuotaExceededError"; - NativeFileError.TYPE_MISMATCH_ERR = "TypeMismatchError"; - NativeFileError.PATH_EXISTS_ERR = "PathExistsError"; - - return NativeFileError; -}); \ No newline at end of file diff --git a/src/file/NativeFileSystem.js b/src/file/NativeFileSystem.js deleted file mode 100644 index 9aaa1076c88..00000000000 --- a/src/file/NativeFileSystem.js +++ /dev/null @@ -1,284 +0,0 @@ -/* - * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - */ - -/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50*/ -/*global define */ - -/** - * @deprecated - * This is a compatibility shim for legacy Brackets APIs that will be removed soon. - * Use APIs in the FileSystem module instead. - */ -define(function (require, exports, module) { - "use strict"; - - var FileSystem = require("filesystem/FileSystem"), - File = require("filesystem/File"), - Directory = require("filesystem/Directory"), - NativeFileError = require("file/NativeFileError"); - - - function _warn(oldAPI, newAPI) { - console.error("Warning: '" + oldAPI + "' is deprecated. Use '" + newAPI + "' instead"); - } - - - // Shims for static APIs on NativeFileSystem itself - - var NativeFileSystem = { - /** - * @deprecated - * @param {boolean} allowMultipleSelection - * @param {boolean} chooseDirectories - * @param {string} title - * @param {string} initialPath - * @param {Array.} fileTypes - * @param {!function(Array.)} successCallback - * @param {!function(string)} errorCallback - */ - showOpenDialog: function (allowMultipleSelection, - chooseDirectories, - title, - initialPath, - fileTypes, - successCallback, - errorCallback) { - _warn("NativeFileSystem.showOpenDialog()", "FileSystem.showOpenDialog()"); - - FileSystem.showOpenDialog( - allowMultipleSelection, - chooseDirectories, - title, - initialPath, - fileTypes, - function (err, data) { - if (!err) { - successCallback(data); - } else if (errorCallback) { - errorCallback(err); - } - } - ); - }, - - /** - * @deprecated - * @param {string} title - * @param {string} initialPath - * @param {string} proposedNewFilename - * @param {!function(string)} successCallback - * @param {!function(string)} errorCallback - */ - showSaveDialog: function (title, - initialPath, - proposedNewFilename, - successCallback, - errorCallback) { - _warn("NativeFileSystem.showSaveDialog()", "FileSystem.showSaveDialog()"); - - FileSystem.showSaveDialog( - title, - initialPath, - proposedNewFilename, - function (err, data) { - if (!err) { - successCallback(data); - } else if (errorCallback) { - errorCallback(err); - } - } - ); - }, - - /** - * @deprecated - * @param {string} path - * @param {!function(!{ root: !Directory })} successCallback - * @param {!function(string)} errorCallback - */ - requestNativeFileSystem: function (path, successCallback, errorCallback) { - _warn("NativeFileSystem.requestNativeFileSystem()", "FileSystem.resolve()"); - - FileSystem.resolve(path, function (err, entry) { - if (err) { - errorCallback(err); - } else { - var fakeNativeFileSystem = { root: entry }; - successCallback(fakeNativeFileSystem); - } - }); - }, - - /** - * @deprecated - * @param {string} path - * @param {!function(!FileSystemEntry)} successCallback - * @param {!function(string)} errorCallback - */ - resolveNativeFileSystemPath: function (path, successCallback, errorCallback) { - _warn("NativeFileSystem.resolveNativeFileSystemPath()", "FileSystem.resolve()"); - - FileSystem.resolve(path, function (err, entry) { - if (err) { - errorCallback(err); - } else { - successCallback(entry); - } - }); - } - - }; - - - // Shims for constructors - return new File/Directory object instead - - /** - * @deprecated - * @param {string} fullPath - * @return {!File} - */ - NativeFileSystem.FileEntry = function (fullPath) { - _warn("new NativeFileSystem.FileEntry()", "FileSystem.getFileForPath()"); - return FileSystem.getFileForPath(fullPath); - }; - - /** - * @deprecated - * @param {string} fullPath - * @return {!Directory} - */ - NativeFileSystem.DirectoryEntry = function (fullPath) { - _warn("new NativeFileSystem.DirectoryEntry()", "FileSystem.getDirectoryForPath()"); - return FileSystem.getDirectoryForPath(fullPath); - }; - - - // Shims for members of File/Directory - monkey-patch the prototype to make them available - // without polluting the new filesystem code - - /** - * @deprecated - * @param {!function()} callback - */ - File.prototype.createWriter = function (callback) { - _warn("File.createWriter()", "File.write()"); - - var file = this; - - // Return fake FileWriter object - // (Unlike the original impl, we don't read the file's old contents first) - callback({ - write: function (data) { - var fileWriter = this; - - if (fileWriter.onwritestart) { - fileWriter.onwritestart(); - } - - file.write(data, function (err) { - if (err) { - if (fileWriter.onerror) { - fileWriter.onerror(err); - } - } else { - if (fileWriter.onwrite) { - fileWriter.onwrite(); - } - if (fileWriter.onwriteend) { - fileWriter.onwriteend(); - } - } - }); - } - }); - }; - - /** - * @deprecated - * @return {!{readEntries: !function()}} - */ - Directory.prototype.createReader = function () { - _warn("Directory.createReader()", "Directory.getContents()"); - - var dir = this; - - // Return fake DirectoryReader object - return { - readEntries: function (successCallback, errorCallback) { - dir.getContents(function (err, entries) { - if (err) { - errorCallback(err); - } else { - successCallback(entries); - } - }); - } - }; - }; - - /** - * @deprecated - * @param {string} path - * @param {?Object} options - * @param {!function(!FileSystemEntry)} successCallback - * @param {!function(string)} errorCallback - */ - Directory.prototype.getFile = function (path, options, successCallback, errorCallback) { - if (options && options.create) { - throw new Error("Directory.getFile() is deprecated and no longer supports 'create: true'. Use File.write(\"\") instead."); - } else { - _warn("Directory.getFile()", "FileSystem.resolve()"); - } - - // Is it a relative path? - if (path[0] !== "/" && path[1] !== ":") { - path = this.fullPath + path; - } - - FileSystem.resolve(path, function (err, entry) { - if (err) { - errorCallback(err); - } else { - if (entry.isDirectory) { - errorCallback(NativeFileError.TYPE_MISMATCH_ERR); - } else { - successCallback(entry); - } - } - }); - }; - - - // Fail-fast stubs for key methods that are not shimmed -- callers will break but with clear guidance in the exception message - - /** - * @deprecated - */ - Directory.prototype.getDirectory = function () { - throw new Error("Directory.getDirectory() has been removed. Use FileSystem.getDirectoryForPath() and/or Directory.create() instead."); - }; - - - // Define public API - exports.NativeFileSystem = NativeFileSystem; -}); diff --git a/src/project/FileIndexManager.js b/src/project/FileIndexManager.js deleted file mode 100644 index d48cc7f2db4..00000000000 --- a/src/project/FileIndexManager.js +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER - * DEALINGS IN THE SOFTWARE. - * - */ - - -/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ -/*global define */ - -/** - * This is a compatibility shim for legacy Brackets APIs that will be removed soon. - * Use ProjectManager.getAllFiles() instead. - * @deprecated - */ -define(function (require, exports, module) { - "use strict"; - - var ProjectManager = require("project/ProjectManager"); - - function _warn() { - console.error("Warning: FileIndexManager is deprecated. Use ProjectManager.getAllFiles() instead"); - } - - - function _getFilter(indexName) { - if (indexName === "css") { - return ProjectManager.getLanguageFilter("css"); - } else if (indexName === "all") { - return null; - } else { - throw new Error("Invalid index name:", indexName); - } - } - - /** - * @deprecated - * @param {!string} indexname - * @return {$.Promise} a promise that is resolved with an Array of File objects - */ - function getFileInfoList(indexName) { - _warn(); - return ProjectManager.getAllFiles(_getFilter(indexName)); - } - - /** - * @deprecated - * @param {!string} indexName - * @param {!string} filename - * @return {$.Promise} a promise that is resolved with an Array of File objects - */ - function getFilenameMatches(indexName, filename) { - _warn(); - - var indexFilter = _getFilter(indexName); - - return ProjectManager.getAllFiles(function (file) { - if (indexFilter && !indexFilter(file)) { - return false; - } - return file.name === filename; - }); - } - - exports.getFileInfoList = getFileInfoList; - exports.getFilenameMatches = getFilenameMatches; -}); From c4e924e764e8df6fdaa22bec83853cdb5b01b6d3 Mon Sep 17 00:00:00 2001 From: Triangle717 Date: Tue, 21 Oct 2014 15:52:58 -0400 Subject: [PATCH 2/2] Minor optimization --- src/brackets.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/brackets.js b/src/brackets.js index 2de59d0448f..0b2db3c3b45 100644 --- a/src/brackets.js +++ b/src/brackets.js @@ -309,7 +309,7 @@ define(function (require, exports, module) { }); // Check for updates - if (!params.get("skipUpdateCheck") && !brackets.inBrowser) { + if (!brackets.inBrowser && !params.get("skipUpdateCheck")) { AppInit.appReady(function () { // launches periodic checks for updates cca every 24 hours UpdateNotification.launchAutomaticUpdate();