From 37e209bb152fdf7f29a602af8726bc8f3bb9178f Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Tue, 5 Oct 2010 11:10:13 -0400 Subject: [PATCH] Be somewhat less insistent/more informative in deprecation complaints. --- common/content/commands.js | 7 +++++-- common/content/dactyl.js | 15 +++++++-------- common/content/options.js | 4 ++-- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/common/content/commands.js b/common/content/commands.js index 5a0183a8..5d594579 100644 --- a/common/content/commands.js +++ b/common/content/commands.js @@ -131,9 +131,10 @@ const Command = Class("Command", { * @param {Object} modifiers Any modifiers to be passed to {@link #action}. */ 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 + ": " : ""; - dactyl.echoerr(loc + ":" + this.name + " is deprecated"); + dactyl.echoerr(loc + ":" + this.name + " is deprecated" + + (isString(this.deprecated) ? ": " + this.deprecated : "")); } let self = this; @@ -180,6 +181,8 @@ const Command = Class("Command", { extra: extra }), + complained: Class.memoize(function () ({})), + /** * @property {string[]} All of this command's name specs. e.g., "com[mand]" */ diff --git a/common/content/dactyl.js b/common/content/dactyl.js index 804ab444..c4d13a24 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -25,16 +25,14 @@ const FailedAssertion = Class("FailedAssertion", Error, { } }); -deprecated.seen = {}; -function deprecated(fn) +deprecated.seen = { "chrome://dactyl/content/javascript.js": true }; +function deprecated(reason, fn) function deprecatedMethod() { let frame = Components.stack.caller; - let caller = frame.filename + ":" + frame.lineNumber; - if (frame.filename != "chrome://dactyl/content/javascript.js" && - !set.add(deprecated.seen, caller)) - dactyl.echoerr(caller + ": " + + if (!set.add(deprecated.seen, frame.filename)) + dactyl.echoerr(frame.filename + ":" + frame.lineNumber + ": " + (this.className || this.constructor.className) + "." + fn.name + - " is deprecated"); + " is deprecated: " + reason); return fn.apply(this, arguments); } @@ -691,7 +689,8 @@ const Dactyl = Module("dactyl", { */ _globalVariables: {}, globalVariables: Class.Property({ - get: deprecated(function globalVariables() this._globalVariables) + get: deprecated("Please use the options system instead", + function globalVariables() this._globalVariables) }), loadPlugins: function () { diff --git a/common/content/options.js b/common/content/options.js index abef2bd4..05032c13 100644 --- a/common/content/options.js +++ b/common/content/options.js @@ -1307,7 +1307,7 @@ const Options = Module("options", { dactyl.echoerr("E18: Unexpected characters in :let"); }, { - deprecated: true, + deprecated: "Please use the options system instead", literal: 0 } ); @@ -1389,7 +1389,7 @@ const Options = Module("options", { { argCount: "+", bang: true, - deprecated: true + deprecated: "Please use the options system instead" }); }, completion: function () {