codeintel CIX schema

Posted by trentm on 2007-02-19 13:19
OS: All / Any | Product: Komodo | tags: komodo codeintel cix apicatalog
Question: 

What is the schema for CIX (codeintel XML)?

Answer: 

CIX stands for Code Intelligence XML. It is the XML format that is used to describe codeintel information for programming language content (variables, classes, functions, etc.) in Komodo's Code Intelligence system. This format is used by the internal scanners of Python, Perl, PHP, JavaScript, Ruby, etc. code. It is used to define the standard library data and API catalog data for these languages.

Attached are the CIX schema (in RelaxNG) and a small catalog.xml (XML catalog file) that can be added in Komodo's "Languages > XML Catalogs" table to get XML autocomplete for .cix files.

All .cix files should start out like this:

<?xml version="1.0" encoding="UTF-8"?>
<codeintel xmlns="urn:activestate:cix:2.0" version="2.0">
   ...
</codeintel>
AttachmentSize
cix-2.0.rng19 KB
catalog.xml.txt194 bytes

robertDouglass | Fri, 2007-03-02 01:33

My first thoughts are: make the tools for creating .cix files in different languages open source and get all the developers who use Komodo motivated to improve them. You'll get a world-class tool in the deal, and you won't have to add everybody's feature requests to the release cycle... because it will have been done (with joy) for you.

Lullabot | Drupal

jayant | Sat, 2007-03-17 22:26

THIS IS GREAT! It took me less than an hour to get started with my own CIX files for my Javascript project. But one question. If I have object B which is a child of object A, how would I represent the inheritence in my CIX? So that if I create B, I get the properties & functions defined within A too.

Javascript:
function A() { this.foo = "foo"; }
function B() {}
B.prototype = new A();

I want the code intel to allow:
var b = new B();
b.foo;

trentm | Mon, 2007-03-19 08:55

jayant,
The "classrefs" attribute of a class scope can be used to indicate a base class:

function A() { this.foo = "foo"; }
function B() {}
B.prototype = new A();
<?xml version="1.0" encoding="UTF-8"?>
<codeintel version="2.0">
  <file lang="JavaScript" mtime="1174323086" path="foo.js">
    <scope ilk="blob" lang="JavaScript" name="foo.js" src="foo.js">
      <scope ilk="class" line="2" lineend="2" name="A">
        <scope attributes="__ctor__" ilk="function" line="2" lineend="2" name="A" signature="A()">
          <variable citdl="A" name="this" />
        </scope>
        <variable citdl="String" line="2" name="foo" />
      </scope>
      <scope classrefs="A" ilk="class" line="3" name="B">
        <scope attributes="__ctor__" ilk="function" line="3" lineend="3" name="B" signature="B()">
          <variable citdl="B" name="this" />
        </scope>
      </scope>
    </scope>
  </file>
</codeintel>

ax | Thu, 2008-02-21 17:40

cix-2.0.rng:

I have no idea if the "value" attribute on <attribute> is legal Relax NG, but
tough, the authors of the RelaxNG spec strove for obtusness. You know what I
mean.

it is not

trentm | Fri, 2008-02-22 09:33

ax,
Thanks for the validation link. Not sure what the best answer is for the schema then. Do you know? Should I just use a comment, e.g. change this:

<attribute name="ilk" value="blob"/>

to this:

<attribute name="ilk" /> <!-- value is "blob" -->

Does Schematron fit in here? I've never played with it, but have heard of its use in conjuction with RelaxNG.

ax | Fri, 2008-02-22 16:19

trentm,

i cannot see what you want change to what :( guess you should &lt; &gt; escape it.

trentm | Fri, 2008-02-22 16:27

updated previous comment with escaping

ax | Sat, 2008-02-23 01:09

this should work: replace all instances of

  <attribute name="ilk" value="something"/>

with

  <attribute name="ilk">
      <value>something</value>
  </attribute>

did you read the RELAX NG Tutorial? very helpful. also helpful: oXygen XML Editor with Relax NG Visual Schema Editor, Validation, Completion, Documentation, ...

regards

trentm | Mon, 2008-02-25 09:33

http://bugs.activestate.com/show_bug.cgi?id=75105 add for the cix.rng update. Thanks.

ax | Tue, 2008-02-26 08:28

for (hopefully) fixing this.

ax | Tue, 2008-02-26 11:02

great, thanks again.

p.s. you might consider removing the 'I have no idea if the "value" attribute on is legal Relax NG ...' :)