1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-14 20:15:46 +01:00

Be somewhat less insistent/more informative in deprecation complaints.

This commit is contained in:
Kris Maglione
2010-10-05 11:10:13 -04:00
parent 3da8b7af2a
commit 37e209bb15
3 changed files with 14 additions and 12 deletions

View File

@@ -131,9 +131,10 @@ const Command = Class("Command", {
* @param {Object} modifiers Any modifiers to be passed to {@link #action}. * @param {Object} modifiers Any modifiers to be passed to {@link #action}.
*/ */
execute: function (args, modifiers) { execute: function (args, modifiers) {
if (this.deprecated) { if (this.deprecated && !set.add(this.complained, io.sourcing ? io.sourcing.file : "[Command Line]")) {
let loc = io.sourcing ? io.sourcing.file + ":" + io.sourcing.line + ": " : ""; let loc = io.sourcing ? io.sourcing.file + ":" + io.sourcing.line + ": " : "";
dactyl.echoerr(loc + ":" + this.name + " is deprecated"); dactyl.echoerr(loc + ":" + this.name + " is deprecated" +
(isString(this.deprecated) ? ": " + this.deprecated : ""));
} }
let self = this; let self = this;
@@ -180,6 +181,8 @@ const Command = Class("Command", {
extra: extra extra: extra
}), }),
complained: Class.memoize(function () ({})),
/** /**
* @property {string[]} All of this command's name specs. e.g., "com[mand]" * @property {string[]} All of this command's name specs. e.g., "com[mand]"
*/ */

View File

@@ -25,16 +25,14 @@ const FailedAssertion = Class("FailedAssertion", Error, {
} }
}); });
deprecated.seen = {}; deprecated.seen = { "chrome://dactyl/content/javascript.js": true };
function deprecated(fn) function deprecated(reason, fn)
function deprecatedMethod() { function deprecatedMethod() {
let frame = Components.stack.caller; let frame = Components.stack.caller;
let caller = frame.filename + ":" + frame.lineNumber; if (!set.add(deprecated.seen, frame.filename))
if (frame.filename != "chrome://dactyl/content/javascript.js" && dactyl.echoerr(frame.filename + ":" + frame.lineNumber + ": " +
!set.add(deprecated.seen, caller))
dactyl.echoerr(caller + ": " +
(this.className || this.constructor.className) + "." + fn.name + (this.className || this.constructor.className) + "." + fn.name +
" is deprecated"); " is deprecated: " + reason);
return fn.apply(this, arguments); return fn.apply(this, arguments);
} }
@@ -691,7 +689,8 @@ const Dactyl = Module("dactyl", {
*/ */
_globalVariables: {}, _globalVariables: {},
globalVariables: Class.Property({ globalVariables: Class.Property({
get: deprecated(function globalVariables() this._globalVariables) get: deprecated("Please use the options system instead",
function globalVariables() this._globalVariables)
}), }),
loadPlugins: function () { loadPlugins: function () {

View File

@@ -1307,7 +1307,7 @@ const Options = Module("options", {
dactyl.echoerr("E18: Unexpected characters in :let"); dactyl.echoerr("E18: Unexpected characters in :let");
}, },
{ {
deprecated: true, deprecated: "Please use the options system instead",
literal: 0 literal: 0
} }
); );
@@ -1389,7 +1389,7 @@ const Options = Module("options", {
{ {
argCount: "+", argCount: "+",
bang: true, bang: true,
deprecated: true deprecated: "Please use the options system instead"
}); });
}, },
completion: function () { completion: function () {