Components.utils.import("resource://dactyl/bootstrap.jsm");
defineModule("javascript", {
exports: ["JavaScript", "javascript"],
- use: ["services", "template", "util"]
+ use: ["messages", "services", "template", "util"]
}, this);
let isPrototypeOf = Object.prototype.isPrototypeOf;
this.window = window;
init.supercall(this);
- },
+ }
}),
globals: Class.memoize(function () [
- [this.modules.userContext, "Global Variables"],
+ [this.modules.userContext, /*L*/"Global Variables"],
[this.modules, "modules"],
[this.window, "window"]
]),
lazyInit: true,
- newContext: function () this.modules.newContext(this.modules.userContext),
+ newContext: function () this.modules.newContext(this.modules.userContext, true),
get completers() JavaScript.completers, // For backward compatibility
if (obj == null)
return;
- let seen = isinstance(obj, ["Sandbox"]) ? set(JavaScript.magicalNames) : {};
+ let seen = isinstance(obj, ["Sandbox"]) ? Set(JavaScript.magicalNames) : {};
let globals = values(toplevel && this.window === obj ? this.globalNames : []);
if (toplevel && isObject(obj) && "wrappedJSObject" in obj)
- if (!set.add(seen, "wrappedJSObject"))
+ if (!Set.add(seen, "wrappedJSObject"))
yield "wrappedJSObject";
for (let key in iter(globals, properties(obj, !toplevel, true)))
- if (!set.add(seen, key))
+ if (!Set.add(seen, key))
yield key;
// Properties aren't visible in an XPCNativeWrapper until
// they're accessed.
for (let key in properties(this.getKey(obj, "wrappedJSObject"), !toplevel, true))
try {
- if (key in obj && !set.has(seen, key))
+ if (key in obj && !Set.has(seen, key))
yield key;
}
catch (e) {}
return cache[key];
context[JavaScript.EVAL_TMP] = tmp;
- context[JavaScript.EVAL_EXPORT] = function export_(obj) cache[key] = obj;
try {
- if (tmp != null) // Temporary hack until bug 609949 is fixed.
- this.modules.dactyl.userEval(JavaScript.EVAL_EXPORT + "(" + arg + ")", context, "[Command Line Completion]", 1);
- else
- cache[key] = this.modules.dactyl.userEval(arg, context, "[Command Line Completion]", 1);
+ cache[key] = this.modules.dactyl.userEval(arg, context, /*L*/"[Command Line Completion]", 1);
return cache[key];
}
catch (e) {
util.reportError(e);
- this.context.message = "Error: " + e;
+ this.context.message = _("error.error", e);
return null;
}
finally {
if (this._top.char != arg) {
this.context.highlight(this._top.offset, this._i - this._top.offset, "SPELLCHECK");
- throw Error("Invalid JS");
+ throw Error(/*L*/"Invalid JS");
}
// The closing character of this stack frame will have pushed a new
if (this._checkFunction(prev, dot, cacheKey))
return [];
if (prev != statement && obj == null) {
- this.context.message = "Error: " + cacheKey.quote() + " is " + String(obj);
+ this.context.message = /*L*/"Error: " + cacheKey.quote() + " is " + String(obj);
return [];
}
let end = (frame == -1 ? this._lastIdx : this._get(frame + 1).offset);
this._cacheKey = null;
- let obj = [[this.cache.evalContext, "Local Variables"]].concat(this.globals);
+ let obj = [[this.cache.evalContext, /*L*/"Local Variables"]].concat(this.globals);
// Is this an object dereference?
if (dot < statement) // No.
dot = statement - 1;
const self = this;
if (!getOwnPropertyNames && !services.debugger.isOn && !this.context.message)
- this.context.message = "For better completion data, please enable the JavaScript debugger (:set jsdebugger)";
+ this.context.message = /*L*/"For better completion data, please enable the JavaScript debugger (:set jsdebugger)";
let base = this.context.fork("js", this._top.offset);
base.forceAnchored = true;
objects.forEach(function (obj) {
obj.ctxt_p.split(obj[1] + "/anchored", this, function (context) {
context.anchored = true;
- context.title[0] += " (prototypes)";
+ context.title[0] += /*L*/" (prototypes)";
});
});
objects.forEach(function (obj) {
obj.ctxt_t.split(obj[1] + "/unanchored", this, function (context) {
context.anchored = false;
- context.title[0] += " (substrings)";
+ context.title[0] += /*L*/" (substrings)";
context.filters.push(unanchored);
});
});
objects.forEach(function (obj) {
obj.ctxt_p.split(obj[1] + "/unanchored", this, function (context) {
context.anchored = false;
- context.title[0] += " (prototype substrings)";
+ context.title[0] += /*L*/" (prototype substrings)";
context.filters.push(unanchored);
});
});
// Wait for a keypress before completing when there's no key
if (!this.context.tabPressed && key == "" && obj.length > 1) {
this.context.waitingForTab = true;
- this.context.message = "Waiting for key press";
+ this.context.message = _("completion.waitingForKeyPress");
return null;
}
"Math", "NaN", "Namespace", "Number", "Object", "Proxy", "QName",
"ROCSSPrimitiveValue", "RangeError", "ReferenceError", "RegExp",
"StopIteration", "String", "SyntaxError", "TypeError", "URIError",
- "Uint16Array", "Uint32Array", "Uint8Array", "XML",
- "XMLHttpProgressEvent", "XMLList", "XMLSerializer", "XPCNativeWrapper",
- "XPCSafeJSWrapper", "XULControllers", "constructor", "decodeURI",
- "decodeURIComponent", "encodeURI", "encodeURIComponent", "escape",
- "eval", "isFinite", "isNaN", "isXMLName", "parseFloat", "parseInt",
- "undefined", "unescape", "uneval"
+ "Uint16Array", "Uint32Array", "Uint8Array", "XML", "XMLHttpProgressEvent",
+ "XMLList", "XMLSerializer", "XPCNativeWrapper", "XPCSafeJSWrapper",
+ "XULControllers", "constructor", "decodeURI", "decodeURIComponent",
+ "encodeURI", "encodeURIComponent", "escape", "eval", "isFinite", "isNaN",
+ "isXMLName", "parseFloat", "parseInt", "undefined", "unescape", "uneval"
].concat([k.substr(6) for (k in keys(Ci)) if (/^nsIDOM/.test(k))])
.concat([k.substr(3) for (k in keys(Ci)) if (/^nsI/.test(k))])
.concat(this.magicalNames)
}, {
EVAL_TMP: "__dactyl_eval_tmp",
- EVAL_EXPORT: "__dactyl_eval_export",
/**
* A map of argument completion functions for named methods. The
* time they are accessed, so they should be accessed
* judiciously.
*
- * @param {function|function[]} funcs The functions for which to
+ * @param {function|[function]} funcs The functions for which to
* install the completers.
- * @param {function[]} completers An array of completer
+ * @param {[function]} completers An array of completer
* functions.
*/
setCompleter: function (funcs, completers) {
modes.addMode("REPL", {
description: "JavaScript Read Eval Print Loop",
- bases: [modes.COMMAND_LINE]
+ bases: [modes.COMMAND_LINE],
+ displayName: Class.memoize(function () this.name)
});
},
commandline: function initCommandLine(dactyl, modules, window) {
this.js.newContext = function newContext() modules.newContext(self.context, !sandbox);
this.js.globals = [
- [this.context, "REPL Variables"],
- [context, "REPL Global"]
+ [this.context, /*L*/"REPL Variables"],
+ [context, /*L*/"REPL Global"]
].concat(this.js.globals.filter(function ([global]) isPrototypeOf.call(global, context)));
if (!isPrototypeOf.call(modules.jsmodules, context))
this.repl = REPL(this.context);
},
+
open: function open(context) {
- this.updatePrompt();
modules.mow.echo(this.repl);
this.widgets.message = null;
open.superapply(this, arguments);
+ this.updatePrompt();
},
complete: function complete(context) {
mode: modes.REPL,
+ get completionList() this.widgets.statusbar.commandline.id,
+
accept: function accept() {
- dactyl.trapErrors(function () { this.repl.addOutput(this.command) }, this);
+ dactyl.trapErrors(function () { this.repl.addOutput(this.command); }, this);
this.completions.cleanup();
this.history.save();
commands.add(["javas[cript]", "js"],
"Evaluate a JavaScript string",
function (args) {
- modules.commandline;
-
if (args[0] && !args.bang)
dactyl.userEval(args[0]);
else {
.open();
}
}, {
+ argCount: "?",
bang: true,
completer: function (context) modules.completion.javascript(context),
hereDoc: true,