Skip to content

Commit

Permalink
Use a getter to deprecate the old values
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcel Gerber committed Apr 21, 2014
1 parent f9d46a6 commit 6c6371d
Showing 1 changed file with 24 additions and 12 deletions.
36 changes: 24 additions & 12 deletions src/command/Commands.js
Expand Up @@ -28,6 +28,9 @@
define(function (require, exports, module) {
"use strict";

var _ = require("thirdparty/lodash"),
DeprecationWarning = require("utils/DeprecationWarning");

/**
* List of constants for global command IDs.
*/
Expand Down Expand Up @@ -85,18 +88,6 @@ define(function (require, exports, module) {
exports.TOGGLE_CLOSE_BRACKETS = "edit.autoCloseBrackets"; // EditorOptionHandlers.js _getToggler()
exports.SHOW_CODE_HINTS = "edit.showCodeHints"; // CodeHintManager.js _startNewSession()

// DEPRECATED: Redirect Edit commands that were moved from the Edit Menu to the Find Menu
exports.EDIT_FIND = "cmd.find"; // FindReplace.js _launchFind()
exports.EDIT_FIND_IN_FILES = "cmd.findInFiles"; // FindInFiles.js _doFindInFiles()
exports.EDIT_FIND_IN_SELECTED = "cmd.findInSelected"; // FindInFiles.js _doFindInSubtree()
exports.EDIT_FIND_IN_SUBTREE = "cmd.findInSubtree"; // FindInFiles.js _doFindInSubtree()
exports.EDIT_FIND_NEXT = "cmd.findNext"; // FindReplace.js _findNext()
exports.EDIT_FIND_PREVIOUS = "cmd.findPrevious"; // FindReplace.js _findPrevious()
exports.EDIT_FIND_ALL_AND_SELECT = "cmd.findAllAndSelect"; // FindReplace.js _findAllAndSelect()
exports.EDIT_ADD_NEXT_MATCH = "cmd.addNextMatch"; // FindReplace.js _expandAndAddNextToSelection()
exports.EDIT_SKIP_CURRENT_MATCH = "cmd.skipCurrentMatch"; // FindReplace.js _skipCurrentMatch()
exports.EDIT_REPLACE = "cmd.replace"; // FindReplace.js _replace()

// FIND
exports.CMD_FIND = "cmd.find"; // FindReplace.js _launchFind()
exports.CMD_FIND_IN_FILES = "cmd.findInFiles"; // FindInFiles.js _doFindInFiles()
Expand Down Expand Up @@ -161,5 +152,26 @@ define(function (require, exports, module) {
// File shell callbacks - string must MATCH string in native code (appshell/command_callbacks.h)
exports.APP_ABORT_QUIT = "app.abort_quit"; // DocumentCommandHandlers.js handleAbortQuit()
exports.APP_BEFORE_MENUPOPUP = "app.before_menupopup"; // DocumentCommandHandlers.js handleBeforeMenuPopup()

_.each([{
oldPrefix: "EDIT",
newPrefix: "CMD",
properties: ["FIND", "FIND_IN_FILES", "FIND_IN_SELECTED", "FIND_IN_SUBTREE", "FIND_NEXT", "FIND_PREVIOUS", "FIND_ALL_AND_SELECT", "ADD_NEXT_MATCH", "SKIP_CURRENT_MATCH", "REPLACE"]
}], function (deprecationEntry) {
var oldPrefix = deprecationEntry.oldPrefix,
newPrefix = deprecationEntry.newPrefix;

_.each(deprecationEntry.properties, function (rawCommandId) {
var oldCommandId = oldPrefix + "_" + rawCommandId,
newCommandId = newPrefix + "_" + rawCommandId;

Object.defineProperty(exports, oldCommandId, {
get: function () {
DeprecationWarning.deprecationWarning("Use Commands." + newCommandId + " instead of Commands." + oldCommandId, true);
return exports[newCommandId];
}
});
});
});
});

0 comments on commit 6c6371d

Please sign in to comment.