ariya.io About Talks Articles

JavaScript Code Editing with Autocompletion in Eclipse Orion

2 min read

Version 0.5 of Eclipse Orion, the web-focused IDE, has been released. One of its improved features is a better editing autocomplete, known in the Eclipse world as Content Assist or within Microsoft Visual Studio users as IntelliSense. The logic to drive the autocompletion is made possible because the parser understands syntax errors in the source text and keeps going without the need to stop immediately.

Orion autocompletion backend is based on Esprima, the fast JavaScript parser I’ve started some months ago. In the Esprima world, the ability to recover from a parsing error is denoted as tolerant mode. This is still a work-in-progress, see issue 130, although it already works to a certain extent. Orion itself uses a modified version of Esprima with a higher level of error tolerance, this will be somehow merged back into upstream at some point in the near future.

The blog post Better JavaScript content assist in Eclipse Orion from Andrew gives a detailed information how content assist works. This is a must read if you want to know what happens behind the scene and would like to apply the approach for other uses cases.

The parser in a real JavaScript engine usually will refuse to continue once it finds an error. This makes sense, there is no benefit of processing the code if it is not valid anyway. However, we can see from the above smart autocompletion feature that sometimes a tolerant parser can be really useful!

Related posts:

♡ this article? Explore more articles and follow me Twitter.

Share this on Twitter Facebook