1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 08:27:59 +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

@@ -197,7 +197,7 @@ var Bookmarks = Module("bookmarks", {
} }
}, },
getSearchEngines: deprecated("Please use bookmarks.searchEngines instead", function getSearchEngines() this.searchEngines), getSearchEngines: deprecated("bookmarks.searchEngines", function getSearchEngines() this.searchEngines),
/** /**
* Returns a list of all visible search engines in the search * Returns a list of all visible search engines in the search
* services, augmented with keyword, title, and icon properties for * services, augmented with keyword, title, and icon properties for

View File

@@ -600,7 +600,7 @@ var Buffer = Module("buffer", {
* @param {bool} follow Whether to follow the matching link. * @param {bool} follow Whether to follow the matching link.
* @param {string} path The XPath to use for the search. @optional * @param {string} path The XPath to use for the search. @optional
*/ */
followDocumentRelationship: deprecated("Please use buffer.findLink instead", followDocumentRelationship: deprecated("buffer.findLink",
function followDocumentRelationship(rel) { function followDocumentRelationship(rel) {
this.findLink(rel, options[rel + "pattern"], 0, true); this.findLink(rel, options[rel + "pattern"], 0, true);
}), }),
@@ -1102,24 +1102,24 @@ var Buffer = Module("buffer", {
this.setZoom(Math.round(values[i] * 100), fullZoom); this.setZoom(Math.round(values[i] * 100), fullZoom);
}, },
getAllFrames: deprecated("Please use buffer.allFrames instead", function getAllFrames() buffer.getAllFrames.apply(buffer, arguments)), getAllFrames: deprecated("buffer.allFrames", function getAllFrames() buffer.getAllFrames.apply(buffer, arguments)),
scrollTop: deprecated("Please use buffer.scrollToPercent instead", function scrollTop() buffer.scrollToPercent(null, 0)), scrollTop: deprecated("buffer.scrollToPercent", function scrollTop() buffer.scrollToPercent(null, 0)),
scrollBottom: deprecated("Please use buffer.scrollToPercent instead", function scrollBottom() buffer.scrollToPercent(null, 100)), scrollBottom: deprecated("buffer.scrollToPercent", function scrollBottom() buffer.scrollToPercent(null, 100)),
scrollStart: deprecated("Please use buffer.scrollToPercent instead", function scrollStart() buffer.scrollToPercent(0, null)), scrollStart: deprecated("buffer.scrollToPercent", function scrollStart() buffer.scrollToPercent(0, null)),
scrollEnd: deprecated("Please use buffer.scrollToPercent instead", function scrollEnd() buffer.scrollToPercent(100, null)), scrollEnd: deprecated("buffer.scrollToPercent", function scrollEnd() buffer.scrollToPercent(100, null)),
scrollColumns: deprecated("Please use buffer.scrollHorizontal instead", function scrollColumns(cols) buffer.scrollHorizontal("columns", cols)), scrollColumns: deprecated("buffer.scrollHorizontal", function scrollColumns(cols) buffer.scrollHorizontal("columns", cols)),
scrollPages: deprecated("Please use buffer.scrollHorizontal instead", function scrollPages(pages) buffer.scrollVertical("pages", pages)), scrollPages: deprecated("buffer.scrollHorizontal", function scrollPages(pages) buffer.scrollVertical("pages", pages)),
scrollTo: deprecated("Please use Buffer.scrollTo instead", function scrollTo(x, y) content.scrollTo(x, y)), scrollTo: deprecated("Buffer.scrollTo", function scrollTo(x, y) content.scrollTo(x, y)),
textZoom: deprecated("Please use buffer.zoomValue and buffer.fullZoom instead", function textZoom() config.browser.markupDocumentViewer.textZoom * 100) textZoom: deprecated("buffer.zoomValue and buffer.fullZoom", function textZoom() config.browser.markupDocumentViewer.textZoom * 100)
}, { }, {
ZOOM_MIN: Class.memoize(function () prefs.get("zoom.minPercent")), ZOOM_MIN: Class.memoize(function () prefs.get("zoom.minPercent")),
ZOOM_MAX: Class.memoize(function () prefs.get("zoom.maxPercent")), ZOOM_MAX: Class.memoize(function () prefs.get("zoom.maxPercent")),
setZoom: deprecated("Please use buffer.setZoom instead", function setZoom() buffer.setZoom.apply(buffer, arguments)), setZoom: deprecated("buffer.setZoom", function setZoom() buffer.setZoom.apply(buffer, arguments)),
bumpZoomLevel: deprecated("Please use buffer.bumpZoomLevel instead", function bumpZoomLevel() buffer.bumpZoomLevel.apply(buffer, arguments)), bumpZoomLevel: deprecated("buffer.bumpZoomLevel", function bumpZoomLevel() buffer.bumpZoomLevel.apply(buffer, arguments)),
findScrollableWindow: deprecated("Please use buffer.findScrollableWindow instead", function findScrollableWindow() buffer.findScrollableWindow.apply(buffer, arguments)), findScrollableWindow: deprecated("buffer.findScrollableWindow", function findScrollableWindow() buffer.findScrollableWindow.apply(buffer, arguments)),
findScrollable: deprecated("Please use buffer.findScrollable instead", function findScrollable() buffer.findScrollable.apply(buffer, arguments)), findScrollable: deprecated("buffer.findScrollable", function findScrollable() buffer.findScrollable.apply(buffer, arguments)),
isScrollable: function isScrollable(elem, dir, horizontal) { isScrollable: function isScrollable(elem, dir, horizontal) {
let pos = "scrollTop", size = "clientHeight", max = "scrollHeight", layoutSize = "offsetHeight", let pos = "scrollTop", size = "clientHeight", max = "scrollHeight", layoutSize = "offsetHeight",

View File

@@ -23,7 +23,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
init: function () { init: function () {
window.dactyl = this; window.dactyl = this;
// cheap attempt at compatibility // cheap attempt at compatibility
let prop = { get: deprecated("Please use dactyl instead", function liberator() dactyl) }; let prop = { get: deprecated("dactyl", function liberator() dactyl) };
Object.defineProperty(window, "liberator", prop); Object.defineProperty(window, "liberator", prop);
Object.defineProperty(modules, "liberator", prop); Object.defineProperty(modules, "liberator", prop);
this.commands = {}; this.commands = {};
@@ -92,7 +92,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
* @property {number} The current main mode. * @property {number} The current main mode.
* @see modes#mainModes * @see modes#mainModes
*/ */
mode: deprecated("Please use modes.main instead", { mode: deprecated("modes.main", {
get: function mode() modes.main, get: function mode() modes.main,
set: function mode(val) modes.main = val set: function mode(val) modes.main = val
}), }),
@@ -108,7 +108,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
forceNewTab: false, forceNewTab: false,
forceNewWindow: false, forceNewWindow: false,
version: deprecated("Please use config.version instead", { get: function version() config.version }), version: deprecated("config.version", { get: function version() config.version }),
/** /**
* @property {Object} The map of command-line options. These are * @property {Object} The map of command-line options. These are
@@ -290,9 +290,9 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
} }
}, },
dump: deprecated("Please use util.dump instead", dump: deprecated("util.dump",
{ get: function dump() util.closure.dump }), { get: function dump() util.closure.dump }),
dumpStack: deprecated("Please use util.dumpStack instead", dumpStack: deprecated("util.dumpStack",
{ get: function dumpStack() util.closure.dumpStack }), { get: function dumpStack() util.closure.dumpStack }),
/** /**
@@ -887,7 +887,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
* These are set and accessed with the "g:" prefix. * These are set and accessed with the "g:" prefix.
*/ */
_globalVariables: {}, _globalVariables: {},
globalVariables: deprecated("Please use the options system instead", { globalVariables: deprecated("the options system", {
get: function globalVariables() this._globalVariables get: function globalVariables() this._globalVariables
}), }),
@@ -1102,7 +1102,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
* @param {string} str * @param {string} str
* @returns {string[]} * @returns {string[]}
*/ */
stringToURLArray: deprecated("Please use dactyl.parseURLs instead", "parseURLs"), stringToURLArray: deprecated("dactyl.parseURLs", "parseURLs"),
parseURLs: function parseURLs(str) { parseURLs: function parseURLs(str) {
let urls; let urls;

View File

@@ -159,11 +159,11 @@ var Option = Class("Option", {
dactyl.triggerObserver("options." + this.name, newValues); dactyl.triggerObserver("options." + this.name, newValues);
}, },
getValues: deprecated("Please use Option#get instead", "get"), getValues: deprecated("Option#get", "get"),
setValues: deprecated("Please use Option#set instead", "set"), setValues: deprecated("Option#set", "set"),
joinValues: deprecated("Please use Option#stringify instead", "stringify"), joinValues: deprecated("Option#stringify", "stringify"),
parseValues: deprecated("Please use Option#parse instead", "parse"), parseValues: deprecated("Option#parse", "parse"),
values: deprecated("Please use Option#value instead", { values: deprecated("Option#value", {
get: function values() this.value, get: function values() this.value,
set: function values(val) this.value = val set: function values(val) this.value = val
}), }),
@@ -686,18 +686,18 @@ var Options = Module("options", {
this.__defineSetter__(name, function (value) { this._optionMap[name].value = value; }); this.__defineSetter__(name, function (value) { this._optionMap[name].value = value; });
}, },
allPrefs: deprecated("Please use prefs.getNames instead", function allPrefs() prefs.getNames.apply(prefs, arguments)), allPrefs: deprecated("prefs.getNames", function allPrefs() prefs.getNames.apply(prefs, arguments)),
getPref: deprecated("Please use prefs.get instead", function getPref() prefs.get.apply(prefs, arguments)), getPref: deprecated("prefs.get", function getPref() prefs.get.apply(prefs, arguments)),
invertPref: deprecated("Please use prefs.invert instead", function invertPref() prefs.invert.apply(prefs, arguments)), invertPref: deprecated("prefs.invert", function invertPref() prefs.invert.apply(prefs, arguments)),
listPrefs: deprecated("Please use prefs.list instead", function listPrefs() { commandline.commandOutput(prefs.list.apply(prefs, arguments)); }), listPrefs: deprecated("prefs.list", function listPrefs() { commandline.commandOutput(prefs.list.apply(prefs, arguments)); }),
observePref: deprecated("Please use prefs.observe instead", function observePref() prefs.observe.apply(prefs, arguments)), observePref: deprecated("prefs.observe", function observePref() prefs.observe.apply(prefs, arguments)),
popContext: deprecated("Please use prefs.popContext instead", function popContext() prefs.popContext.apply(prefs, arguments)), popContext: deprecated("prefs.popContext", function popContext() prefs.popContext.apply(prefs, arguments)),
pushContext: deprecated("Please use prefs.pushContext instead", function pushContext() prefs.pushContext.apply(prefs, arguments)), pushContext: deprecated("prefs.pushContext", function pushContext() prefs.pushContext.apply(prefs, arguments)),
resetPref: deprecated("Please use prefs.reset instead", function resetPref() prefs.reset.apply(prefs, arguments)), resetPref: deprecated("prefs.reset", function resetPref() prefs.reset.apply(prefs, arguments)),
safeResetPref: deprecated("Please use prefs.safeReset instead", function safeResetPref() prefs.safeReset.apply(prefs, arguments)), safeResetPref: deprecated("prefs.safeReset", function safeResetPref() prefs.safeReset.apply(prefs, arguments)),
safeSetPref: deprecated("Please use prefs.safeSet instead", function safeSetPref() prefs.safeSet.apply(prefs, arguments)), safeSetPref: deprecated("prefs.safeSet", function safeSetPref() prefs.safeSet.apply(prefs, arguments)),
setPref: deprecated("Please use prefs.set instead", function setPref() prefs.set.apply(prefs, arguments)), setPref: deprecated("prefs.set", function setPref() prefs.set.apply(prefs, arguments)),
withContext: deprecated("Please use prefs.withContext instead", function withContext() prefs.withContext.apply(prefs, arguments)), withContext: deprecated("prefs.withContext", function withContext() prefs.withContext.apply(prefs, arguments)),
/** /**
* Returns the option with *name* in the specified *scope*. * Returns the option with *name* in the specified *scope*.
@@ -1122,7 +1122,7 @@ var Options = Module("options", {
dactyl.echoerr("E18: Unexpected characters in :let"); dactyl.echoerr("E18: Unexpected characters in :let");
}, },
{ {
deprecated: "Please use the options system instead", deprecated: "the options system",
literal: 0 literal: 0
} }
); );
@@ -1202,7 +1202,7 @@ var Options = Module("options", {
{ {
argCount: "+", argCount: "+",
bang: true, bang: true,
deprecated: "Please use the options system instead" deprecated: "the options system"
}); });
}, },
completion: function () { completion: function () {

View File

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

View File

@@ -250,7 +250,7 @@ var IO = Module("io", {
*/ */
sourcing: null, 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*. * 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. * @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) { init: function init(dactyl, modules, window) {
modules.plugins.contexts = {}; modules.plugins.contexts = {};

View File

@@ -239,16 +239,16 @@ var Styles = Module("Styles", {
let (obj = this[args[0] ? "system" : "user"]) let (obj = this[args[0] ? "system" : "user"])
obj[name].apply(obj, Array.slice(args, 1)), obj[name].apply(obj, Array.slice(args, 1)),
addSheet: deprecated("Please use Styles#{user,system}.add instead", function addSheet() this._proxy("add", arguments)), addSheet: deprecated("Styles#{user,system}.add", function addSheet() this._proxy("add", arguments)),
findSheets: deprecated("Please use Styles#{user,system}.find instead", function findSheets() this._proxy("find", arguments)), findSheets: deprecated("Styles#{user,system}.find", function findSheets() this._proxy("find", arguments)),
get: deprecated("Please use Styles#{user,system}.get instead", function get() this._proxy("get", arguments)), get: deprecated("Styles#{user,system}.get", function get() this._proxy("get", arguments)),
removeSheet: deprecated("Please use Styles#{user,system}.remove instead", function removeSheet() this._proxy("remove", 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) }), userSheets: Class.Property({ get: deprecated("Styles#user.sheets", function userSheets() this.user.sheets) }),
systemSheets: Class.Property({ get: deprecated("Please use Styles#system.sheets instead", function systemSheets() this.system.sheets) }), systemSheets: Class.Property({ get: deprecated("Styles#system.sheets", function systemSheets() this.system.sheets) }),
userNames: Class.Property({ get: deprecated("Please use Styles#user.names instead", function userNames() this.user.names) }), userNames: Class.Property({ get: deprecated("Styles#user.names", function userNames() this.user.names) }),
systemNames: Class.Property({ get: deprecated("Please use Styles#system.names instead", function systemNames() this.system.names) }), systemNames: Class.Property({ get: deprecated("Styles#system.names", function systemNames() this.system.names) }),
sites: Class.Property({ get: deprecated("Please use Styles#user.sites instead", function sites() this.user.sites) }), sites: Class.Property({ get: deprecated("Styles#user.sites", function sites() this.user.sites) }),
registerSheet: function registerSheet(url, agent, reload) { registerSheet: function registerSheet(url, agent, reload) {
let uri = services.io.newURI(url, null, null); 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(function (node) "//" + node).join(" | ");
}, },
map: deprecated("Please use iter.map instead", function map(obj, fn, self) iter(obj).map(fn, self).toArray()), 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)),
writeToClipboard: deprecated("Please use dactyl.clipboardWrite instead", function writeToClipboard(str, verbose) util.dactyl.clipboardWrite(str, verbose)), readFromClipboard: deprecated("dactyl.clipboardRead", function readFromClipboard() util.dactyl.clipboardRead(false)),
readFromClipboard: deprecated("Please use dactyl.clipboardRead instead", function readFromClipboard() util.dactyl.clipboardRead(false)),
/** /**
* Converts a URI string into a URI object. * Converts a URI string into a URI object.