Titanium JIRA Archive
Alloy (ALOY)

[ALOY-388] TiStudio code completion for Alloy view files (XML)

GitHub Issuen/a
TypeNew Feature
Resolution Date2012-12-12T00:06:01.000+0000
Affected Version/sAlloy 0.3.1
Fix Version/sAlloy 0.3.4, 2012 Sprint 25
ComponentsTitanium Studio
LabelsGA-candidate, notable
ReporterTony Lukasavage


Alloy view files, which are XML, need code completion in TiStudio. There are 2 primary points at which code completion should be shown:

When a user types an opening angle bracket \(<\) and begins to type the name of a Titanium API, a list of possible code completions should appear

When a user has already typed the name of the element, code completion should help with typing the attributes of the XML element, based on the name of the element.

To do this, I assume TiStudio can continue to use the jsca documentation that it currently uses for code completion in traditional Titanium javascript files. This same method of code completion would then be applied instead to the creation of the Alloy XML views. There are a couple special considerations when dealing with Alloy view XML. I will list them below, in order from least to highest priority in terms of determining which API is being created in the XML.

By default, all XML elements are assumed to be using the *Ti.UI* namespace. For example:

would assume that the Titanium API to be created would be *Ti.UI.Label*.

Alloy has a set of "implicit namespaces" to make XML creation easier. For example:

will not assume *Ti.UI*, but will instead assume *Ti.UI.iOS* as the namespace for the created component. Alloy has a listing of all "implicit namespaces" and will provide a means of generating the listing that TiStudio can use to improve the autocompletion for attributes.

Finally, Alloy allows for a *ns* attribute which will explicitly set the namespace of the API to be created. For example:

<View ns="Ti.Map"/>
would create a *Ti.Map.View* and autocompletion for attributes should apply to this API. From initial conversations about Alloy view autocompletion, it sounds as though the TiStudio team will need to establish criteria for determining that they are autcompleting for Alloy XML vs. generic XML, as they share the same extension. Hopefully there is additional criteria that can be used to make this distinction.


A list of implicit namespaces can now be retrieved from Alloy by issuing the following command:

alloy info namespaces

The list of implicit namespaces will returned as a JSON object. The object will look like this and will update as necessary with Alloy versions. The format will remain the same.

    "Collection": "Alloy",
    "Model": "Alloy",
    "Require": "Alloy",
    "Widget": "Alloy",
    "ButtonNames": "Alloy.Abstract",
    "ButtonName": "Alloy.Abstract",
    "BarItemTypes": "Alloy.Abstract",
    "BarItemType": "Alloy.Abstract",
    "CoverFlowImageTypes": "Alloy.Abstract",
    "CoverFlowImageType": "Alloy.Abstract",
    "FlexSpace": "Alloy.Abstract",
    "Images": "Alloy.Abstract",
    "Item": "Alloy.Abstract",
    "Items": "Alloy.Abstract",
    "Labels": "Alloy.Abstract",
    "Option": "Alloy.Abstract",
    "Options": "Alloy.Abstract",
    "Menu": "Ti.Android",
    "MenuItem": "Ti.Android",
    "Annotation": "Ti.Map",
    "VideoPlayer": "Ti.Media",
    "MusicPlayer": "Ti.Media",
    "AdView": "Ti.UI.iOS",
    "CoverFlowView": "Ti.UI.iOS",
    "TabbedBar": "Ti.UI.iOS",
    "Toolbar": "Ti.UI.iOS",
    "DocumentViewer": "Ti.UI.iPad",
    "Popover": "Ti.UI.iPad",
    "SplitWindow": "Ti.UI.iPad",
    "NavigationGroup": "Ti.UI.iPhone",
    "StatusBar": "Ti.UI.iPhone"


  1. Christopher Williams 2012-11-15

    @tlukasavage I've opened the tickets necessary for Titanium Studio for alloy view content assist. From your side we'll need this ticket (or some other one) to encompass the work to get the listing of implicit namespace mappings. I'm fine with pretty much any sort of simple listing of pairs, whether that's in some static JSON file, or parseable (JSON?) output from an "alloy mapping" CLI command or something.
  2. Tony Lukasavage 2012-12-06

    @chris The following command will give you a list of implicit namespaces as a JSON object in the latest alloy in master:
       alloy info namespaces
    That will allow you to do better attribute completion based on the element name. I think that's everything you needed from the Alloy side for XML code completion. Please let me know if there's additional things you need, or if you need testing on my end. If you have everything you need from Alloy, let me know and I will close this ticket.
  3. Tony Lukasavage 2012-12-12

    initial work for tistudio XML code completion has been completed from the Alloy side. Any further work necessary from Alloy to facilitate it will be documented in future tickets.

JSON Source