Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit 7ca5f89

Browse files
committed
Update Commands deprecation code
1 parent 427c8e9 commit 7ca5f89

1 file changed

Lines changed: 31 additions & 12 deletions

File tree

src/command/Commands.js

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

31+
var DeprecationWarning = require("utils/DeprecationWarning");
32+
33+
/**
34+
* @private
35+
* Create a deprecation warning and action for updated Command constants
36+
* @param {!string} oldConstant
37+
* @param {!string} newConstant
38+
*/
39+
function _deprecateCommand(oldConstant, newConstant) {
40+
var warning = "Use Commands." + newConstant + " instead of Commands." + oldConstant + ".",
41+
newValue = exports[newConstant];
42+
43+
Object.defineProperty(exports, oldConstant, {
44+
get: function () {
45+
DeprecationWarning.deprecationWarning(warning, true);
46+
return newValue;
47+
}
48+
});
49+
}
50+
3151
/**
3252
* List of constants for global command IDs.
3353
*/
@@ -85,18 +105,6 @@ define(function (require, exports, module) {
85105
exports.TOGGLE_CLOSE_BRACKETS = "edit.autoCloseBrackets"; // EditorOptionHandlers.js _getToggler()
86106
exports.SHOW_CODE_HINTS = "edit.showCodeHints"; // CodeHintManager.js _startNewSession()
87107

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-
100108
// FIND
101109
exports.CMD_FIND = "cmd.find"; // FindReplace.js _launchFind()
102110
exports.CMD_FIND_IN_FILES = "cmd.findInFiles"; // FindInFiles.js _doFindInFiles()
@@ -161,5 +169,16 @@ define(function (require, exports, module) {
161169
// File shell callbacks - string must MATCH string in native code (appshell/command_callbacks.h)
162170
exports.APP_ABORT_QUIT = "app.abort_quit"; // DocumentCommandHandlers.js handleAbortQuit()
163171
exports.APP_BEFORE_MENUPOPUP = "app.before_menupopup"; // DocumentCommandHandlers.js handleBeforeMenuPopup()
172+
173+
// DEPRECATED: Edit commands that were moved from the Edit Menu to the Find Menu
174+
_deprecateCommand("EDIT_FIND", "CMD_FIND");
175+
_deprecateCommand("EDIT_FIND_IN_SELECTED", "CMD_FIND_IN_SELECTED");
176+
_deprecateCommand("EDIT_FIND_IN_SUBTREE", "CMD_FIND_IN_SUBTREE");
177+
_deprecateCommand("EDIT_FIND_NEXT", "CMD_FIND_NEXT");
178+
_deprecateCommand("EDIT_FIND_PREVIOUS", "CMD_FIND_PREVIOUS");
179+
_deprecateCommand("EDIT_FIND_ALL_AND_SELECT", "CMD_FIND_ALL_AND_SELECT");
180+
_deprecateCommand("EDIT_ADD_NEXT_MATCH", "CMD_ADD_NEXT_MATCH");
181+
_deprecateCommand("EDIT_SKIP_CURRENT_MATCH", "CMD_SKIP_CURRENT_MATCH");
182+
_deprecateCommand("EDIT_REPLACE", "CMD_REPLACE");
164183
});
165184

0 commit comments

Comments
 (0)