Search code examples
ace-editor

Is there a list of documentation for the properties on the objects used in auto completion?


I'm working on setting up an auto completion list and I've been trying to figure out what each property does. Is there more documentation on this object?

Here's what I have so gathered far:

public class AutoCompleteObject {

    public function AutoCompleteObject(name:String = null, metadata:String = null) {
        this.value = name;
        meta = metadata;
    }

    /**
     * Value written upon auto completion
     * 
     * @see #caption
     * */
    public var value:String;

    /**
     * The caption is what is shown in the auto completion list as you type the value
     * 
     * @see #value
     * */
    public var caption:String;

    /**
     * The score is a reason unknown 
     * */
    public var score:String;

    /**
     * What is shown to the right of the value or caption if set in the auto complete list
     * 
     * */
    public var meta:String;

    /**
     * Unknown
     * */
    public var className:String;

    /**
     * Unknown
     * */
    public var matchMask:Object;

    /**
     * Unknown
     * */
    public var exactMatch:Object;

    /**
     * Unknown
     * Option: "rightAlignedText"
     * */
    public var type:String;

}

Here's my function for getting autocompletion objects:

public function getObjectsFromArray(values:Array, metadataType:String = "attribute", className:String = null):Array {
    var newValues:Array = [];
    var numberOfItems:int = values ? values.length :0;
    var autoCompleteObject:AutoCompleteObject;
    var testing:Boolean;
    var object:Object;

    for (var i:int = 0; i < numberOfItems; i++) {
        if (testing) {
            object = {"value":values[i], meta:metadataType};
            newValues.push(object);
        }
        else {
            autoCompleteObject = new AutoCompleteObject(values[i], metadataType);
            autoCompleteObject.className = className;
            autoCompleteObject.type = "attribute";
            newValues.push(autoCompleteObject);
        }
    }

    return newValues;
}

My question is what do the following properties mean:

  • score (I'm guessing it's a weighted value)
  • className
  • type

Less important:

  • matchMask
  • exactMatch

My related questions, if they should be separate questions let me know, are:
- if class name is what I think it is can I show className in the autocomplete list? - can I sort the list by meta type? so my list is above the built in list? - Should the strongly typed object I'm using be changed to dynamic type for future proofing? I found the other properties mentioned because errors were thrown when I changed from using Object.

I can post these as separate questions.


Solution

  • score is a number used for sorting https://github.com/ajaxorg/ace/blob/v1.2.6/lib/ace/autocomplete.js#L494 matchMask and exactMatch are internal properties used by the sorting algorithm

    className is added to the row as a class name https://github.com/ajaxorg/ace/blob/v1.2.6/lib/ace/autocomplete/popup.js#L190

    type is a custom property used only by snippet completer https://github.com/ajaxorg/ace/blob/v1.2.6/lib/ace/ext/language_tools.js#L67