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 summarised below:
- Click on the
JavaScript Libraries
item in theProject Settings
section inPreferences
. - Click on the
Configure global JavaScript libraries
available on the right hand pane, which will open up theProject Structure
dialog. - Click on the
Global Libraries
item in thePlatform Settings
section. - Click on the
+ (plus)
button on the top of the dialog, which will add a new global library - 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. - Click
OK
Now all we need to do is associate our Appcelerator projects with this library, which is done by:
- Click on the
Usage Scope
sub menu under theJavaScript Libraries
item available underProject Settings
inPreferences
. This should show the project in the right hand panel. - Click on the libraries, which will bring up a list of libraries.
- Select the Titanium library defined previously.
Result
This should now enable code completion and documentation lookup as shown below:
