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.


Reader Comments

  1. 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?

  2. 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?

  3. 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

  4. 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.

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

    I can’t find that documented anywhere :(

  6. 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.

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

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

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

  10. 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?

  11. 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!

  12. 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.

  13. 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.

  14. 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).

  15. 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…

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

  17. 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

  18. 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.

  19. 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…

  20. 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.

Write a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.