ariya.io About Talks Articles

JavaScript Editing with Autocomplete

1 min read

Code autocomplete is probably one of the exciting features of a programmer’s text editor. Ever since Eclipse Orion started to demonstrate its wonderful Content Assist feature last summer, I do believe that an online, web-based editing component should always provide a minimalistic and convenient autocompletion. Fortunately, this is rather easy to achieve these days, thanks to Orion and Scripted.

With the recent growing interests to improve the state of JavaScript language tooling, I thought it is a good time to publish a simple example that I have put together some time ago. The editor itself is the same one used in Eclipse Orion. With its recent version 2.0 release, it becomes rather easy to embed Orion editor in any web page: one JavaScript file, one CSS file, and a bit of of glue code.

jsautocomplete

For the autocompletion itself, Scripted’s Content Assist is employed. As I have written before, it has a well-developed type inferencer. Using a simple static code analysis, it can detect the possible matches on a best-effort basis. In addition to that, JSDoc-style of type annotation is also supported.

You can enjoy the working example at esprima.org/demo/autocomplete.html. Have fun!

Related posts:

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

Share this on Twitter Facebook