(Advanced) autocompletion through cix file

Hi,

I have managed to create a (partially) working cix file for a JavaScript web framework through some intermediate steps, starting from jsdoc.
When using KomodoEdit with this cix file I get some autocompletion.

The web framework uses the class method .create() to create new instances of classes. There is sadly no hinting or completion on the instance methods however. I tried to set the __ctor__ attribute on this create method, but that leads to the method not popping up in the completion lists. What would the best way to make this work?

Additionally, this .create() method accepts an object literal with properties. I was wondering whether it would be possible to have Komodo display the hints from the instance methods and properties of the class being created, and how this should be done through the cix file (if possible of course).

Thanks in advance!

Hi there!

It sounds like the easiest thing to do here is to pretend create() is a class method that returns an instance of the class? That is, as if it was something like:


function Foo() {}

/**
 * @returns Foo
 */
Foo.create = function() {};

As for object literals, unfortunately Komodo doesn’t support that yet; while it’s a common pattern there hasn’t really been any standardized ways to document it yet (other than basically free form text). It’s one of the annoying points about the language :expressionless:

Thanks for the answer!
Am I right in assuming that in order for this to work, the create method should be explicitly defined on every class? Because if that is the case, I am afraid that might get complex, as this create method is part of the base class and copied onto the newer classes when they are extended.

Right; there’s no good way to document, essentially, “creates an instance of a class; which class is determined at runtime”. You’ll need to generate your cix automatically with create() stubbed out for every derived class, sorry.

If you have really complicated requirements that call for evaluating everything at runtime, there’s the under-documented interface that Komodo uses for the XPCOM catalog, but it sounds like that’s overkill for your case (and everything’s actually saner if you pre-generate the various create() methods in your cix).

“creates an instance of a class; which class is determined at runtime”: welcome to JavaScript :smile:

Pregenerating the .create method in the cix is indeed a good idea. It is rather straightforward and clear. I quickly looked at the XPCOM catalog and it looks like this kind of interface would be great to be used with external systems such as tern.