Skip to content

Commit 6c6371d

Browse files
author
Marcel Gerber
committed
Use a getter to deprecate the old values
1 parent f9d46a6 commit 6c6371d

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

src/command/Commands.js

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
define(function (require, exports, module) {
2929
"use strict";
3030

31+
var _ = require("thirdparty/lodash"),
32+
DeprecationWarning = require("utils/DeprecationWarning");
33+
3134
/**
3235
* List of constants for global command IDs.
3336
*/
@@ -85,18 +88,6 @@ define(function (require, exports, module) {
8588
exports.TOGGLE_CLOSE_BRACKETS = "edit.autoCloseBrackets"; // EditorOptionHandlers.js _getToggler()
8689
exports.SHOW_CODE_HINTS = "edit.showCodeHints"; // CodeHintManager.js _startNewSession()
8790

88-
// DEPRECATED: Redirect Edit commands that were moved from the Edit Menu to the Find Menu
89-
exports.EDIT_FIND = "cmd.find"; // FindReplace.js _launchFind()
90-
exports.EDIT_FIND_IN_FILES = "cmd.findInFiles"; // FindInFiles.js _doFindInFiles()
91-
exports.EDIT_FIND_IN_SELECTED = "cmd.findInSelected"; // FindInFiles.js _doFindInSubtree()
92-
exports.EDIT_FIND_IN_SUBTREE = "cmd.findInSubtree"; // FindInFiles.js _doFindInSubtree()
93-
exports.EDIT_FIND_NEXT = "cmd.findNext"; // FindReplace.js _findNext()
94-
exports.EDIT_FIND_PREVIOUS = "cmd.findPrevious"; // FindReplace.js _findPrevious()
95-
exports.EDIT_FIND_ALL_AND_SELECT = "cmd.findAllAndSelect"; // FindReplace.js _findAllAndSelect()
96-
exports.EDIT_ADD_NEXT_MATCH = "cmd.addNextMatch"; // FindReplace.js _expandAndAddNextToSelection()
97-
exports.EDIT_SKIP_CURRENT_MATCH = "cmd.skipCurrentMatch"; // FindReplace.js _skipCurrentMatch()
98-
exports.EDIT_REPLACE = "cmd.replace"; // FindReplace.js _replace()
99-
10091
// FIND
10192
exports.CMD_FIND = "cmd.find"; // FindReplace.js _launchFind()
10293
exports.CMD_FIND_IN_FILES = "cmd.findInFiles"; // FindInFiles.js _doFindInFiles()
@@ -161,5 +152,26 @@ define(function (require, exports, module) {
161152
// File shell callbacks - string must MATCH string in native code (appshell/command_callbacks.h)
162153
exports.APP_ABORT_QUIT = "app.abort_quit"; // DocumentCommandHandlers.js handleAbortQuit()
163154
exports.APP_BEFORE_MENUPOPUP = "app.before_menupopup"; // DocumentCommandHandlers.js handleBeforeMenuPopup()
155+
156+
_.each([{
157+
oldPrefix: "EDIT",
158+
newPrefix: "CMD",
159+
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"]
160+
}], function (deprecationEntry) {
161+
var oldPrefix = deprecationEntry.oldPrefix,
162+
newPrefix = deprecationEntry.newPrefix;
163+
164+
_.each(deprecationEntry.properties, function (rawCommandId) {
165+
var oldCommandId = oldPrefix + "_" + rawCommandId,
166+
newCommandId = newPrefix + "_" + rawCommandId;
167+
168+
Object.defineProperty(exports, oldCommandId, {
169+
get: function () {
170+
DeprecationWarning.deprecationWarning("Use Commands." + newCommandId + " instead of Commands." + oldCommandId, true);
171+
return exports[newCommandId];
172+
}
173+
});
174+
});
175+
});
164176
});
165177

0 commit comments

Comments
 (0)