This blog post shows you how to add code completion and documentation lookup support for Appcelerator Titanium in IntelliJ IDEA. This is mostly building on top of the posts made by Amit Kothari and James Low.

Generate the Titanium JavaScript file

The first step is to get your hands on a JavaScript file containing the API and documentation with JSDoc tags by using the utilities described here, or by grabbing the file from my GitHub repository. Note that the file in this repository is specifically for Titanium Mobile.

Method 1: Include the JavaScript file as part of the project

The easiest method is to simply place the JavaScript within the project directory so that IntelliJ can parse it, as described in Amit’s blog post.

Method 2: Add the Titanium JavaScript file as a global library

The other method is to add the Titanium JavaScript file generated above as a global library in IntelliJ as described here. The steps in the article are summarized below:

  1. Click on the JavaScript Libraries item in the Project Settings section in Preferences.
  2. Click on the Configure global JavaScript libraries available on the right hand pane, which will open up the Project Structure dialog.
  3. Click on the Global Libraries item in the Platform Settings section.
  4. Click on the + (plus) button on the top of the dialog, which will add a new global library
  5. Give the library a name, for example Titanium Mobile, and attach the source JavaScript file by clicking the Attach Debug Version(s) button and selecting the file in the dialog.
  6. Click OK

IntelliJ - Define global libraryIntelliJ - Define global library

Now all we need to do is associate our Appcelerator projects with this library, which is done by:

  1. Click on the Usage Scope sub menu under the JavaScript Libraries item available under Project Settings in Preferences. This should show the project in the right hand panel.
  2. Click on the libraries, which will bring up a list of libraries.
  3. Select the Titanium library defined previously.

IntelliJ - Select global libraryIntelliJ - Select global library

Result

This should now enable code completion and documentation lookup as shown below:

IntelliJ - Titanium code completionIntelliJ - Titanium code completion