1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-13 08:45:45 +01:00

Move common deprecation message content to deprecated().

This commit is contained in:
Doug Kearns
2011-01-13 05:21:22 +11:00
parent 68620dadc7
commit 0f9a558a3c
8 changed files with 60 additions and 61 deletions

View File

@@ -260,9 +260,9 @@ function properties(obj, prototypes, debugger_) {
}
}
function deprecated(reason, fn) {
function deprecated(alternative, fn) {
if (isObject(fn))
return Class.Property(iter(fn).map(function ([k, v]) [k, callable(v) ? deprecated(reason, v) : v])
return Class.Property(iter(fn).map(function ([k, v]) [k, callable(v) ? deprecated(alternative, v) : v])
.toObject());
let name, func = callable(fn) ? fn : function () this[fn].apply(this, arguments);
@@ -276,7 +276,7 @@ function deprecated(reason, fn) {
if (!set.add(deprecatedMethod.seen, filename))
util.dactyl(fn).echoerr(
util.urlPath(filename) + ":" + frame.lineNumber + ": " +
obj + (fn.name || name) + " is deprecated: " + reason);
obj + (fn.name || name) + " is deprecated: Please use " + alternative + " instead");
return func.apply(this, arguments);
}
memoize(deprecatedMethod, "seen", function () set([
@@ -319,8 +319,8 @@ function values(obj) iter(function values() {
yield obj[k];
}());
var forEach = deprecated("Please use iter.forEach instead", function forEach() iter.forEach.apply(iter, arguments));
var iterAll = deprecated("Please use iter instead", function iterAll() iter.apply(null, arguments));
var forEach = deprecated("iter.forEach", function forEach() iter.forEach.apply(iter, arguments));
var iterAll = deprecated("iter", function iterAll() iter.apply(null, arguments));
/**
* Utility for managing sets of strings. Given an array, returns an

View File

@@ -250,7 +250,7 @@ var IO = Module("io", {
*/
sourcing: null,
expandPath: deprecated("Please use File.expandPath instead", function expandPath() File.expandPath.apply(File, arguments)),
expandPath: deprecated("File.expandPath", function expandPath() File.expandPath.apply(File, arguments)),
/**
* Returns the first user RC file found in *dir*.
@@ -475,7 +475,7 @@ var IO = Module("io", {
/**
* @property {string} The current platform's path separator.
*/
PATH_SEP: deprecated("Please use File.PATH_SEP instead", { get: function PATH_SEP() File.PATH_SEP })
PATH_SEP: deprecated("File.PATH_SEP", { get: function PATH_SEP() File.PATH_SEP })
}, {
init: function init(dactyl, modules, window) {
modules.plugins.contexts = {};

View File

@@ -239,16 +239,16 @@ var Styles = Module("Styles", {
let (obj = this[args[0] ? "system" : "user"])
obj[name].apply(obj, Array.slice(args, 1)),
addSheet: deprecated("Please use Styles#{user,system}.add instead", function addSheet() this._proxy("add", arguments)),
findSheets: deprecated("Please use Styles#{user,system}.find instead", function findSheets() this._proxy("find", arguments)),
get: deprecated("Please use Styles#{user,system}.get instead", function get() this._proxy("get", arguments)),
removeSheet: deprecated("Please use Styles#{user,system}.remove instead", function removeSheet() this._proxy("remove", arguments)),
addSheet: deprecated("Styles#{user,system}.add", function addSheet() this._proxy("add", arguments)),
findSheets: deprecated("Styles#{user,system}.find", function findSheets() this._proxy("find", arguments)),
get: deprecated("Styles#{user,system}.get", function get() this._proxy("get", arguments)),
removeSheet: deprecated("Styles#{user,system}.remove", function removeSheet() this._proxy("remove", arguments)),
userSheets: Class.Property({ get: deprecated("Please use Styles#user.sheets instead", function userSheets() this.user.sheets) }),
systemSheets: Class.Property({ get: deprecated("Please use Styles#system.sheets instead", function systemSheets() this.system.sheets) }),
userNames: Class.Property({ get: deprecated("Please use Styles#user.names instead", function userNames() this.user.names) }),
systemNames: Class.Property({ get: deprecated("Please use Styles#system.names instead", function systemNames() this.system.names) }),
sites: Class.Property({ get: deprecated("Please use Styles#user.sites instead", function sites() this.user.sites) }),
userSheets: Class.Property({ get: deprecated("Styles#user.sheets", function userSheets() this.user.sheets) }),
systemSheets: Class.Property({ get: deprecated("Styles#system.sheets", function systemSheets() this.system.sheets) }),
userNames: Class.Property({ get: deprecated("Styles#user.names", function userNames() this.user.names) }),
systemNames: Class.Property({ get: deprecated("Styles#system.names", function systemNames() this.system.names) }),
sites: Class.Property({ get: deprecated("Styles#user.sites", function sites() this.user.sites) }),
registerSheet: function registerSheet(url, agent, reload) {
let uri = services.io.newURI(url, null, null);

View File

@@ -817,10 +817,9 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]),
.map(function (node) "//" + node).join(" | ");
},
map: deprecated("Please use iter.map instead", function map(obj, fn, self) iter(obj).map(fn, self).toArray()),
writeToClipboard: deprecated("Please use dactyl.clipboardWrite instead", function writeToClipboard(str, verbose) util.dactyl.clipboardWrite(str, verbose)),
readFromClipboard: deprecated("Please use dactyl.clipboardRead instead", function readFromClipboard() util.dactyl.clipboardRead(false)),
map: deprecated("iter.map", function map(obj, fn, self) iter(obj).map(fn, self).toArray()),
writeToClipboard: deprecated("dactyl.clipboardWrite", function writeToClipboard(str, verbose) util.dactyl.clipboardWrite(str, verbose)),
readFromClipboard: deprecated("dactyl.clipboardRead", function readFromClipboard() util.dactyl.clipboardRead(false)),
/**
* Converts a URI string into a URI object.