Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[orion-dev] Esprima-based content assist plugin

Hi all,

I just "released" a first go at an esprima-based content assist
plugin.  You can install it from this url:
http://aeisenberg.github.com/esprimaContentAssist/esprimaJsContentAssistPlugin.html

Here are a few things that it does:

1. Content assist based on scope: ie- only and all of the variables
accessible in the current scope are available in content assist
2. Simple control flow eg-
var first = 1;
var second = first;
second.|   // all number proposals are available
3. Object literals: var foo = { first: 1, second: 2};  foo.|  // first
and second appear
4. Some simple error recovery is available (thanks to Andy's work on
the parser), mostly around '.', but for some wildly bad JavaScript,
you won't get any proposals
5. Functions whose name starts with a capital letter are considered
constructors, and 'this' works appropriately inside of them.
6. Assigning a property to an existing variable will make it available
in content assist later:
this.newVal = 9
this.|  // will show newVal
this.newVal.|  // will show number proposals

Here are things that don't work:

1. Globals defined in /*global ... */
2. Keywords and templates.  These are provided by the existing JS
content assist plugin, which still runs.  This relates to:
3. The esprima proposals all appear below the existing JS proposals,
and they are prefixed with a handy "(esprima)" to let you know where
they are coming from.  This means that in some cases proposals appear
twice (once from each provider).  There is no easy way around this
right now.
4. Type information for proposals is not shown (I like the way that
the current provider shows the types, but mine doesn't do that yet)
5. Except for constructors, user-defined function return types are
ignored.  All user-defined functions are considered to be of type
"Function", whether they are accessed as a property or called as a
function.
6. Nested object literals will have multiple "this" proposals.  Nested
functions will have multiple "arguments" proposals.  And you may find
duplicates in other scenarios as well.
7. And much more.

I hope this will be useful.  I am looking for feedback on ways to
improve it, and let me know if you see problems with it, or it is
sluggish in some way.

thanks,
Andrew


Back to the top