james david low

live / work / play / worship

Titanium Autocomplete Eclipse

Update
Appcelerator just announced that they’ve acquired Aptana. Not sure if it had anything to do with me pointing them in that direction via my plugin, but that would probably mean that I eventually stop maintaing this, since they’ll produce a much more integrated solution. Looking forward to it though!!!!

Original
I’ve been using Accelerator Titanium to create iPhone applications in JavaScript. One thing JavaScript is missing is really good editor with autocompletion / code completion. I recently found Aptana and wanted a way to autocomplete from the Titanium API in that. I’ve created ScriptDoc compatible JavaScript header file that does the job.

Installation
1) Install Aptana standalone or as an eclipse plugin.
2) Download the javascript header file
3) Switch to the Aptana perspective in eclipse
4) Set Aptana as the default javascript editor in preferences
5) Add the timobile.js to the references

Other points of interest:
- You can download the PHP file here that I use to create the JavaScript header file from the Titanium API JSON file. Run the PHP script in the same directory as the api.json file from Titanium.
- I’m working on an Eclipse plugin, you can view the source here.
- If you’re wondering why there are function names like Titanium_UI_Window, these are to act as dummy return types, because Aptana ScriptDoc didn’t allow me to return an Object in a name space like Titanium.UI.Window.
- Mbirth has a JSDoc code completion file here, but Adobe no longer seem to distribute JSEclipse so I’m not sure how it would work in Eclipse.


If you found any of the software useful, please consider supporting its further developement by donating.
3:24pm / May 31st / 10
« <3 Adobe Cut & Paste and Tabs in Finder »

50 Comments

    [...] plugins coming out of the woodwork for Titanium Appcelerator, which is great to see. James, over at http://jameslow.com/2010/05/31/titanium-autocomplete-eclipse/ has created what looks so far to be an excellent JS plugin for eclipse – hopefully now [...]

    AWESOME! I’m trying this on a mac (Snow Leopard) with Aptana standalone version 2, followed your video to the tee, and don’t see the Titanium API stuff in my autocompletes that appear. Do I perhaps need to use eclipse with the aptana plugin instead?

    I see the variables that are in the JS file but I have a feeling that’s just Aptana recognizing what’s in my app.js already. Any ideas as to what I can try?

    8:27pm / Jul 15th / 10 Pete

    Hmmm not sure. I think Aptana has some settings within a project that might allow you to check which references to use.

    Aptana stand alone is pretty much eclipse down to the tee, so it shouldn’t be that, but you could always try. Did you make sure Aptana was set as the javascript editor?

    10:10pm / Jul 15th / 10 James Low

    Excellent approach, thanks a lot. I started to use this extremely helpful tool yesterday and noticed that timobile.js does not contain all objects, e.g. Titanium.Filesystem.File, Titanium.Contacts.Group, … are completely missing, at least I can’t find them. To me it seems that sometimes only top level modules are contained, while the module’s objects are not contained at all.

    Additionally, the file has errors, e.g. Titanium.Filesystem.getFile, which in fact returns Titanium.Filesystem.File, is listed with “getFile: function (path) { return {}; }” (maybe a side effect of the missing Titanium.Filesystem.File). Also, e.g. Titanium.Contacts lists only 3 out of 15 methods (also maybe a side effect).
    Will you have the chance to fix this? Would be most appreciated …

    Thanks again, Thomas

    6:05pm / Jul 30th / 10 Thomas

    Excellent work! Very useful. Thanks for sharing this.

    3:15pm / Jul 31st / 10 Michael Ferguson

    I’ll have a look at it. I wasn’t using those methods so I didn’t check, but I thought I was reading the data from the son correctly so maybe its missing from there or it was an older release.

    3:27pm / Jul 31st / 10 James Low

    Will also try to get the Ti name space working.

    3:30pm / Jul 31st / 10 James Low

    I’ve updated to version 1.4 of the API

    8:06am / Sep 7th / 10 James Low

    At a total loss here … how do you install Aptana as an Eclipse plugin?

    I can’t find that documented anywhere :(

    10:25am / Sep 10th / 10 Richard

    Nevemind … color me stoopid … I found it :)

    10:27am / Sep 10th / 10 Richard

    Excellent work … works perfectly … thanks James

    5:02pm / Sep 10th / 10 vnetonline

    Very cool!

    2:52am / Sep 22nd / 10 Bob Chesley

    [...] Aptana pour Eclipse et a y ajouter le fichier javascript fourni par ce monsieur (qui en plus donne une demo video pour pouvoir y [...]

    [...] demo here to see [...]

    Hi Thomas,
    Im trying to follow the titanium autocomplete installation steps. For some reason my eclipse version with Aptana plugin does not have provision to add File References.
    I use Eclipse 3.6.1 JAVA EE version and Aptana Studio 3 plugin.
    Do I need to use different eclipse version??

    Thanks for your help.
    -Kumar.

    6:26am / Nov 3rd / 10 Kumar Kothapalli

    You can also use this in Visual Studio by adding

    ///

    9:42am / Nov 10th / 10 James Diacono

    Sorry,

    ///

    9:43am / Nov 10th / 10 James Diacono

    Damnit…

    ///

    9:44am / Nov 10th / 10 James Diacono

    [...] James David nos proporciona una solución por medio de un archivo ScriptDoc. [...]

    Is the eclipse plugin usable? Can I just used the plugin instead of the javascript reference?

    4:38am / Nov 28th / 10 Eli Mor

    Not at the moment, I’d love to get it working sometime, but for now just use the JS file.

    8:08am / Nov 28th / 10 James Low

    [...] James Low has a AppCelerator Titanium’s API AutoComplete for Eclipse+Aptana. Download it here http://jameslow.com/2010/05/31/titanium-autocomplete-eclipse/ [...]

    8:17am / Dec 8th / 10 Titanium Autocomplete |try {} except

    Very nice piece of work James.

    One detail that is easy to miss, is that the tiimobile.js file should be added to the default profile, not the dummy profile that you have to create before eclipse shows the default one.

    7:19pm / Dec 8th / 10 JeffAtStepUp

    Awesome job. Thanks for this. the Ti namespace would also be appreciated. I’ll be sending Paypal donation. Keep up the great work!

    7:57pm / Dec 13th / 10 brian

    Thanks man!

    Will be sure to update it to 1.5.0 once it’s out!

    9:33pm / Dec 13th / 10 James Low

    [...] Mostly because they don’t have their own IDE. I have chosen to use Aptana Studio with an autocomplete header file. There’s also a bundle for [...]

    I love the autocompeteness this brings. Do you plan to update your file to v1.5.1 of the API?

    6:26am / Dec 28th / 10 Royce

    Yep, just updated it, same link as before!

    9:12am / Dec 28th / 10 James Low

    Is their an easy way to get it so we can just type Ti.
    instead of Titanium?

    2:21am / Jan 2nd / 11 Chris

    Has anyone got this working with Aptana v3 (standalone)?
    There is no “references” view that I can find?

    9:58pm / Jan 5th / 11 Miles g

    [...] 1.5.1. This can be used with Eclipse+Aptana’s autocomplete, using the method described by James David Low a while [...]

    I followed the tutorial, and have it setup in Eclipse with
    Aptana plugin. So I added the project Kitchen Sink, but when I test
    the autocomplete, eclipse hangs for a while then I get a GC
    overhead limit esceeded message. Basically out of memory. Is this
    because I used the KitchenSink example to run my test?

    2:13am / Jan 12th / 11 Pat

    I apologize, Issue was a bad timobile.js file.
    Thanks.

    2:58am / Jan 12th / 11 Pat

    Hi James, I am very new to mobile dev, i looked at you
    Titanium autocomple sample, and i have a few questions. what is
    timobile.js? why do i need it? does it come with the titanium
    install package? and finally when i create a project on titanium
    developer, then import it to eclipse is there a way i can run it
    through eclipse? Many thanks in advance!

    8:08pm / Jan 12th / 11 Faton

    Great little script. Your probably right about Aptana + titanium creating some streamline system for developing but imo Titanium desperately needed it. Your script here feels like a stepping stone in the right direction for Titanium. Keep up the good work and thanks again.

    7:48pm / Jan 19th / 11 Conor Clafferty

    Any info on how to get this to work in the current Aptana 3 beta? Thanks!

    8:39am / Jan 20th / 11 Chris

    I think I couldn’t so I ended up sticking with 2. The new Aptana/Appcelerator integration should produce something better in the future. I think they release a beta in march.

    7:41am / Jan 24th / 11 James Low

    Thanks a lot, great, great work!

    For those who had problems getting it to work: just download a fresh Eclipse (the JavaScript version 3.6) and install the Aptana plug-in as described.
    I didn’t get things to work with Aptana 2.0.5 (non-plug-in version).

    8:06am / Jan 30th / 11 Ray Beyer

    Indeed, there is no “references view” in Aptana Studio 3…
    I tried the “Project References” that can reference a whole project.
    So I created a “Titanium project” with only the titanium.js file and referenced it in my project, but it did not work neither…

    Switching back to Eclipse + Aptana-plugin…

    10:45am / Feb 1st / 11 Thomas

    Thanks.. works perfectly!.. references for all are not included in the timobile.js file on this page. Check here for the latest (http://www.tryexcept.com/wp-content/uploads/2011/01/timobile151.js).

    6:59pm / Feb 2nd / 11 thepro

    Well, this works perfectly on my MacBook Pro but on windows 7, I just cant get the Aptana perspective nor the references tab!! :(

    1:26pm / Feb 9th / 11 Samanth

    Doesnt work for me. Only difference I am using exclipse ide for js web developers version. When I type Titanium.UI, I do not get Titanium, I get stuff like Titanium_Android_Calender??? no Titanium in list and no associated .UI method. I do not see this in the js header file? What am I doing wrong?

    Thanks

    11:32pm / Feb 10th / 11 bill bob

    [...] di Aptana per Eclipse, l’autocompletamento del codice piu’ essere ottenuto grazie a questo utile post in cui c’e’ un programma php per convertire le API doc di Appcelerator Titanium [...]

    I try this that you show here, but, when I type “Ti.” for example and click CTRL + Space to show what goes after but nothing about the timobilo.js is shown, what I am doing wrong, I do everything that you show here.

    Tks,
    Jairo.

    12:54pm / Feb 16th / 11 Jairo

    Great plugin and guide. Thanks for posting such a nice blog and steps to build auto complete for Titanium API’s in Javascript.

    Your blog has been very extremely useful…. Thanks once again…

    7:40pm / May 7th / 11 Prince Nishchal

    [...] 操作ミス) http://jameslow.com/2010/05/31/titanium-autocomplete-eclipse/ [...]

    [...] converter in my good friend Amit Kothari’s blog post. The script was written in PHP by James Low. Unfortunately this script changes some the identifiers to get around the problem of invalid [...]

    [...] 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. [...]

    installed the plugin, but there IS no aptana perspective. Dear God, I hate Eclipse. Screwing around with community hacked files and endless version clashes to get the most basic functionality.

    1:02pm / Nov 4th / 11 steve c