Skip to content
This repository has been archived by the owner on Sep 10, 2022. It is now read-only.

tern-closure requires version of tern too old #37

Open
pstjvn opened this issue May 9, 2015 · 8 comments
Open

tern-closure requires version of tern too old #37

pstjvn opened this issue May 9, 2015 · 8 comments
Labels

Comments

@pstjvn
Copy link

pstjvn commented May 9, 2015

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.

@lxbzmy
Copy link

lxbzmy commented Jul 18, 2015

I confirmed it, tern-closure cannot work with tern 0.11.

@lxbzmy
Copy link

lxbzmy commented Jul 19, 2015

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
    };
  }

@angelozerr
Copy link
Contributor

See #39, it seems working for me.

@jgiles
Copy link
Contributor

jgiles commented Aug 12, 2015

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.

@jgiles
Copy link
Contributor

jgiles commented Aug 12, 2015

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.

@jgiles jgiles added the bug label Aug 12, 2015
@pstjvn
Copy link
Author

pstjvn commented Aug 29, 2015

If installing from github it now works. npm however still downloads the tagged older version with tern requirement set to 0.7.0

@bfricka
Copy link

bfricka commented Oct 13, 2015

+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.

@exclipy
Copy link

exclipy commented Nov 14, 2016

+1; would appreciate it if the current version of tern-closure in npm works with the current version of tern.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants