Open pstjvn opened 9 years ago
I confirmed it, tern-closure cannot work with tern 0.11.
Tern's plugin interface has been changed sine 0.11. We can do some patch to compatible new interface.
//from complete_strings.js
function complete(file, query) {
var pos = tern.resolvePos(file, query.end);
var lit = infer.findExpressionAround(file.ast, null, pos, file.scope, "Literal");
if (!lit || typeof lit.node.value != "string") return;
var before = lit.node.value.slice(0, pos - lit.node.start - 1);
var matches = [], seen = infer.cx().parent._completeStrings.seen;
for (var str in seen) if (str.length > before.length && str.indexOf(before) == 0) {
if (query.types || query.docs || query.urls || query.origins) {
var rec = {name: JSON.stringify(str), displayName: str};
matches.push(rec);
if (query.types) rec.type = "string";
if (query.origins) rec.origin = seen[str];
} else {
matches.push(JSON.stringify(str));
}
}
if (matches.length) return {
start: tern.outputPos(query, file, lit.node.start),
end: tern.outputPos(query, file, pos + (file.text.charAt(pos) == file.text.charAt(lit.node.start) ? 1 : 0)),
isProperty: false,
completions: matches
};
}
See https://github.com/google/tern-closure/pull/39, it seems working for me.
Yep, I believe this - I've been out of the game for a while (apologies). I now have some good reasons to get going again, so expect more regular updates.
Merged the above pull request, and updated the Closure side so the tests were passing.
I am going to manually test a bit more thoroughly before closing this issue.
If installing from github it now works. npm however still downloads the tagged older version with tern requirement set to 0.7.0
+1 Need to tag and push new npm version
Edit: Also, this isn't working for tern 0.15.0... I'll try to look into it later, but currently have to npm i tern@0.13.0
to make it work.
+1; would appreciate it if the current version of tern-closure in npm works with the current version of tern.
The default installation instructions no longer work: tern is 0.11 as of late and tern-closure is still with 0.7 and the installation must be reverted and tailored to satisfy this.