Nodejs plugin says "No definition found" for import variables.

86 views
Skip to first unread message

Saravana Kumar

unread,
Jan 3, 2015, 11:50:47 AM1/3/15
to tern...@googlegroups.com
var express    = require('express'); 
var router = express.Router();
For express.Router, the definition is sitting in node_modules/express/lib/router/index.js...
But tern is not recognizing this variable. I got into tern code, found out that inside infer.js#didGuess, the 'guessing' variable is set as true.
When goto-definition is ran from emacs, the control comes to lib/tern.js#findDef(). And here, since infer.didGuess() returns true, it gives an empty object.
so when will this flag be set as false, and why is it not reset in this case? 

Saravana Kumar

unread,
Jan 3, 2015, 12:02:48 PM1/3/15
to tern...@googlegroups.com
i found out, findExprType in lib/tern.js makes 'guess' flag as true.. but still clueless about when the flag will be made as false?

Saravana Kumar

unread,
Jan 4, 2015, 6:38:13 AM1/4/15
to tern...@googlegroups.com
and inside tern.js#findExprType, the expression
srv.passes['typeAt'] is undefined when 'No definition found' error occurs. srv is the Tern server object, which i can see get its 'passes' property set through plugin mechanism. And i can see, nodejs plugin implements three methods - preCondenseReach, postLoadRef, completion but i am not seeing typeAt defined anywhere...
What does the passes property in a server object do? 

On Saturday, 3 January 2015 22:20:47 UTC+5:30, Saravana Kumar wrote:

Marijn Haverbeke

unread,
Jan 20, 2015, 5:52:23 AM1/20/15
to Saravana Kumar, tern-dev
Passes are hooks that plugins can register to do something when
certain events occur. The fact that there's no typeAt pass registered
in this case is not a bug.

The guess flag is reset when infer.resetGuessing is called. It is used
to track whether any guesses where made between two points in time.

As for why the express code does not work, I don't know, I haven't
tested with express yet.
> --
> You received this message because you are subscribed to the Google Groups
> "tern-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to tern-dev+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages