mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-23 11:48:00 +01:00
Turn JS completion caching back on
This commit is contained in:
@@ -76,7 +76,6 @@ function Bookmarks() //{{{
|
|||||||
let uri = ioService.newURI(node.uri, null, null);
|
let uri = ioService.newURI(node.uri, null, null);
|
||||||
let keyword = bookmarksService.getKeywordForBookmark(node.itemId);
|
let keyword = bookmarksService.getKeywordForBookmark(node.itemId);
|
||||||
let tags = taggingService.getTagsForURI(uri, {}) || [];
|
let tags = taggingService.getTagsForURI(uri, {}) || [];
|
||||||
//return bookmarks.push(new Bookmark(node.uri, node.title, null, keyword, tags, node.itemId));
|
|
||||||
|
|
||||||
return bookmarks.push(new Bookmark(node.uri, node.title, null, keyword, tags, node.itemId));
|
return bookmarks.push(new Bookmark(node.uri, node.title, null, keyword, tags, node.itemId));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ function CompletionContext(editor, name, offset)
|
|||||||
this.reset();
|
this.reset();
|
||||||
}
|
}
|
||||||
this.name = name || "";
|
this.name = name || "";
|
||||||
|
this.cache = {};
|
||||||
this._items = []; // FIXME
|
this._items = []; // FIXME
|
||||||
this.selectionTypes = {};
|
this.selectionTypes = {};
|
||||||
}
|
}
|
||||||
@@ -266,37 +267,36 @@ function Completion() //{{{
|
|||||||
|
|
||||||
completion.filterMap = [null, function (v) template.highlight(v, true)];
|
completion.filterMap = [null, function (v) template.highlight(v, true)];
|
||||||
|
|
||||||
//if (cacheFilter.js === cacheKey)
|
let [obj, key] = objects;
|
||||||
// return cacheResults.js;
|
let cache = this.context.cache.objects || {};
|
||||||
//cacheFilter.js = cacheKey;
|
this.context.cache.objects = cache;
|
||||||
|
if (key in cache)
|
||||||
|
return cache[key];
|
||||||
|
|
||||||
// Can't use the cache. Build a member list.
|
// Can't use the cache. Build a member list.
|
||||||
compl = [];
|
let compl = [];
|
||||||
for (let [,obj] in Iterator(objects))
|
// Things we can dereference
|
||||||
{
|
if (["object", "string", "function"].indexOf(typeof obj) == -1)
|
||||||
// Things we can dereference
|
return [];
|
||||||
if (["object", "string", "function"].indexOf(typeof obj) == -1)
|
if (!obj)
|
||||||
continue;
|
return [];
|
||||||
if (!obj)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// XPCNativeWrappers, etc, don't show all accessible
|
// XPCNativeWrappers, etc, don't show all accessible
|
||||||
// members until they're accessed, so, we look at
|
// members until they're accessed, so, we look at
|
||||||
// the wrappedJSObject instead, and return any keys
|
// the wrappedJSObject instead, and return any keys
|
||||||
// available in the object itself.
|
// available in the object itself.
|
||||||
let orig = obj;
|
let orig = obj;
|
||||||
if (obj.wrappedJSObject)
|
if (obj.wrappedJSObject)
|
||||||
obj = obj.wrappedJSObject;
|
obj = obj.wrappedJSObject;
|
||||||
// v[0] in orig and orig[v[0]] catch different cases. XPCOM
|
// v[0] in orig and orig[v[0]] catch different cases. XPCOM
|
||||||
// objects are problematic, to say the least.
|
// objects are problematic, to say the least.
|
||||||
compl.push([v for (v in this.iter(obj)) if (v[0] in orig || orig[v[0]] !== undefined)])
|
compl.push([v for (v in this.iter(obj)) if (v[0] in orig || orig[v[0]] !== undefined)])
|
||||||
// And if wrappedJSObject happens to be available,
|
// And if wrappedJSObject happens to be available,
|
||||||
// return that, too.
|
// return that, too.
|
||||||
if (orig.wrappedJSObject)
|
if (orig.wrappedJSObject)
|
||||||
compl.push([["wrappedJSObject", obj]]);
|
compl.push([["wrappedJSObject", obj]]);
|
||||||
}
|
|
||||||
compl = util.Array.flatten(compl);
|
compl = util.Array.flatten(compl);
|
||||||
return cacheResults.js = compl;
|
return cache[key] = compl;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.filter = function filter(compl, key, last, offset)
|
this.filter = function filter(compl, key, last, offset)
|
||||||
@@ -327,9 +327,9 @@ function Completion() //{{{
|
|||||||
|
|
||||||
this.eval = function eval(arg, key, tmp)
|
this.eval = function eval(arg, key, tmp)
|
||||||
{
|
{
|
||||||
if (!("eval" in cacheResults))
|
if (!("eval" in this.context.cache))
|
||||||
cacheResults.eval = {};
|
this.context.cache.eval = {};
|
||||||
let cache = cacheResults.eval;
|
let cache = this.context.cache.eval;
|
||||||
if (!key)
|
if (!key)
|
||||||
key = arg;
|
key = arg;
|
||||||
|
|
||||||
@@ -525,6 +525,7 @@ function Completion() //{{{
|
|||||||
let statement = get(frame, 0, STATEMENTS) || 0; // Current statement.
|
let statement = get(frame, 0, STATEMENTS) || 0; // Current statement.
|
||||||
let prev = statement;
|
let prev = statement;
|
||||||
let obj;
|
let obj;
|
||||||
|
let cacheKey;
|
||||||
for (let [i, dot] in Iterator(get(frame)[DOTS].concat(stop)))
|
for (let [i, dot] in Iterator(get(frame)[DOTS].concat(stop)))
|
||||||
{
|
{
|
||||||
if (dot < statement)
|
if (dot < statement)
|
||||||
@@ -538,7 +539,7 @@ function Completion() //{{{
|
|||||||
cacheKey = str.substring(statement, dot);
|
cacheKey = str.substring(statement, dot);
|
||||||
obj = self.eval(s, cacheKey, obj);
|
obj = self.eval(s, cacheKey, obj);
|
||||||
}
|
}
|
||||||
return [[obj, str.substring(statement, stop + 1)]];
|
return [[obj, cacheKey]]
|
||||||
}
|
}
|
||||||
|
|
||||||
function getObjKey(frame)
|
function getObjKey(frame)
|
||||||
@@ -565,7 +566,7 @@ function Completion() //{{{
|
|||||||
{
|
{
|
||||||
let ctxt = this.context.fork(obj[1], top[OFFSET]);
|
let ctxt = this.context.fork(obj[1], top[OFFSET]);
|
||||||
ctxt.title = [obj[1]];
|
ctxt.title = [obj[1]];
|
||||||
ctxt.items = this.filter(compl || this.objectKeys(obj[0]), key + (string || ""), last, key.length);
|
ctxt.items = this.filter(compl || this.objectKeys(obj), key + (string || ""), last, key.length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -627,7 +628,7 @@ function Completion() //{{{
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var completer = obj[func].liberatorCompleter;
|
var completer = obj[0][0][func].liberatorCompleter;
|
||||||
}
|
}
|
||||||
catch (e) {}
|
catch (e) {}
|
||||||
if (!completer)
|
if (!completer)
|
||||||
@@ -645,10 +646,11 @@ function Completion() //{{{
|
|||||||
});
|
});
|
||||||
args.push(key);
|
args.push(key);
|
||||||
|
|
||||||
let compl = completer.call(this, func, obj, string, args);
|
let compl = completer.call(this, func, obj[0][0], string, args);
|
||||||
if (!(compl instanceof Array))
|
if (!(compl instanceof Array))
|
||||||
compl = [v for (v in compl)];
|
compl = [v for (v in compl)];
|
||||||
key = this.eval(key);
|
key = this.eval(key);
|
||||||
|
obj[0][1] += "." + func + "(...";
|
||||||
return complete.call(this, obj, key, compl, string, last);
|
return complete.call(this, obj, key, compl, string, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -383,7 +383,10 @@ const liberator = (function () //{{{
|
|||||||
{
|
{
|
||||||
args = args.string;
|
args = args.string;
|
||||||
|
|
||||||
let method = args[0] == ":" ? "execute" : "eval";
|
if (args[0] == ":")
|
||||||
|
var method = function () liberator.execute(args);
|
||||||
|
else
|
||||||
|
method = liberator.eval("(function () {" + args + "})");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -395,7 +398,7 @@ const liberator = (function () //{{{
|
|||||||
for (let i in util.interruptableRange(0, count, 500))
|
for (let i in util.interruptableRange(0, count, 500))
|
||||||
{
|
{
|
||||||
let now = Date.now();
|
let now = Date.now();
|
||||||
liberator[method](args);
|
method();
|
||||||
total += Date.now() - now;
|
total += Date.now() - now;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -437,10 +440,7 @@ const liberator = (function () //{{{
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
var beforeTime = Date.now();
|
var beforeTime = Date.now();
|
||||||
if (args && args[0] == ":")
|
method();
|
||||||
liberator.execute(args);
|
|
||||||
else
|
|
||||||
liberator.eval(args);
|
|
||||||
|
|
||||||
if (special)
|
if (special)
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user