8.3.2 Field access completion

Field completion is triggered after a dot . character to list the fields that are available on the given type. The compiler parses and types everything up to the point of completion and then outputs the relevant information to stderr:

class Main {
  public static function main() {

If this file is saved to Main.hx, the completion can be invoked using the command haxe --display Main.hx@0. The output looks similar to this (we omit several fields for brevity and improve the formatting for readability):

<i n="length">
    The number of characters in `this` String.
<i n="charAt">
  <t>index : Int -&gt; String</t>
    Returns the character at position `index` of `this` String.
    If `index` is negative or exceeds `this.length`, the empty String
    "" is returned.
<i n="charCodeAt">
  <t>index : Int -&gt; Null&lt;Int&gt;</t>
    Returns the character code at position `index` of `this` String.
    If `index` is negative or exceeds `this.length`, null is returned.
    To obtain the character code of a single character, "x".code can
    be used instead to inline the character code at compile time.
    Note that this only works on String literals of length 1.

The XML structure follows:

  • The document node list encloses several nodes i, each representing a field.
  • The n attribute contains the name of the field.
  • The t node contains the type of the field.
  • the d node contains the documentation of the field.
since Haxe 3.2.0

When compiling with -D display-details, each field additionally has a k attribute which can either be var or method. This allows distinguishing method fields from variable fields that have a function type.