Skip to content

Code Completion

m0rkeulv edited this page Oct 20, 2026 · 2 revisions

The plugin completes Haxe code from its own analysis of your sources, the Haxe standard library and your libraries. With the compilation server it can also offer what only the compiler knows, such as members that macros generate. This page describes both and the settings that choose between them.

Using completion

Completion works as it does everywhere else in IntelliJ IDEA: the list opens while you type, or you open it with Code | Code Completion | Basic. In Haxe files the list also opens after you type $ (macro reification), # (conditional compilation) and new followed by a space. It does not open by itself inside comments; invoking it explicitly still works there.

While the list is open, use Quick Documentation to read the documentation of the selected entry.

What the IDE completes

Variables, members and keywords

The list offers the local variables, parameters and members visible at the caret, and the keywords that are valid there: modifiers in a class body, statements in a function, case and default in a switch, the accessor keywords (get, set, null, default, never, dynamic) in a property declaration, and so on. In a switch on an enum value, the list also offers a case for each enum value that does not have one yet.

Types and imports

Type names come from your project, its libraries and the Haxe standard library. When you choose a type that is not imported yet, the plugin adds the import statement. After new, it also adds the parentheses of the constructor call. Types from the target-specific packages of other targets (such as js while you build for HashLink) are left out.

When what you type matches the start of a class name, the list also offers the public static members of that class as ClassName.member. Choosing one adds the import of its class.

Two related helpers:

  • When a type name in your code cannot be resolved but a matching type exists, a hint offers to import it. Press Alt+Enter (macOS: ⌥⏎) to add the import, or pick the type in Choose Class To Import when several types match.
  • When you paste code that uses types the file does not import, the plugin adds the missing imports. Depending on the IDE's auto-import setting for pasted code, it first asks in the Select Classes to Import dialog.

Values of an expected enum

Where the code expects a value of an enum type, the enum's values appear at the top of the list. This works for an initializer or assignment of a variable whose type is declared, a call or constructor argument, a parameter's default value, a return value and the keys and values of a map literal. It also works for enum abstract types.

enum Color { Red; Green; Blue; }

class Main {
  static function main() {
    var background:Color = // Red, Green and Blue are offered first
  }
}

Functions where a function is expected

Where the code expects a function, for example an argument of Array.filter or Array.map, the list offers an arrow function and a function literal shaped like the expected function type. The entries are marked expected function. Choosing one inserts it as a template: you type each parameter name in turn, with name suggestions, and the caret ends in the body. A function literal that has to return a value starts its body with return.

var even = [1, 2, 3, 4].filter(i -> i % 2 == 0);

Names for new declarations

While you type the name of a new local variable, parameter or field, the list suggests names the surrounding code already uses without declaring them. For a constructor parameter, it also suggests the fields of the class.

class Box {
  var width:Float;
  var height:Float;

  // completion between the parentheses suggests width and height
  public function new() {}

  // completion between the parentheses suggests limit, which the body uses but nothing declares
  function fill() {
    trace(limit);
  }
}

Metadata

After @: the list offers the metadata your Haxe compiler lists in its help, with its documentation. The plugin reads that help in the background the first time an SDK is used; until then, the list offers a built-in set of metadata. Inside @:nullSafety(...), @:analyzer(...) and @:forward(...) it offers the arguments those metadata accept. With compiler diagnostics on (see Diagnostics and Inspections), the list also contains the metadata your Haxe version and your libraries register with the compiler, except with Haxe 3.

Conditional compilation

After # the list offers #if, #elseif, #else, #end and #error. Inside a condition it offers the defines of the file's build, its resolve context. See Conditional Compilation.

Documentation comments

In a documentation comment, invoke completion after an @ at the start of a line to get the documentation tags. The list does not open by itself there, because it never does in comments. To turn tag completion off, clear Complete documentation tags in Settings | Languages & Frameworks | Haxe | Documentation. See Editor Extras.

Class names and file paths in strings

Inside a string literal, the plugin completes qualified class names and file paths. The list opens by itself after a / and after the second . of a qualified name whose beginning matches a package or class; at any other place, invoke completion explicitly. See Editor Extras for navigating from such strings.

Type-matching completion

Code | Code Completion | Type-Matching offers the values of an enum, qualified with the enum name, in the initializer of a variable declared with that enum type.

Build files

The plugin also completes build files: in hxml files, compiler arguments, library names and versions after -lib and define names after -D; in Lime, OpenFL and NME project files, the name and version attributes of <haxelib>. The compiler arguments and define names come from the help of the Haxe SDK of the file's module, which the plugin reads in the background the first time; until then, the only argument offered is -D, and no define names. See Build Files.

Compiler-backed completion

Note

Beta. Compiler-backed completion works and is supported, but may still change.

Macros can add types and members that appear in no source file. The plugin's own analysis cannot see them, but the compiler can. To let completion ask the compiler:

  1. Open Settings | Build, Execution, Deployment | Compiler | Haxe Compiler.
  2. Select Use compiler for IDE features (beta). The Completion option below it is selected by default.
  3. Choose where completion gets its symbols in Completion sources:.
Value What you get
IDE only (statically resolved) Only the plugin's own analysis. The compiler is not asked.
IDE + compiler (adds generated symbols) The default. The plugin's own analysis, plus the types and members that macros generate.
Compiler only (the compilation server answers every completion) Every completion list comes from the compiler. The plugin's own suggestions are turned off.

While Use compiler for IDE features (beta) or Completion is cleared, completion uses only the plugin's own analysis, and Completion sources: cannot be changed.

Both compiler values need the compilation server to be enabled for the project and for the module, a trusted project and a build file the compiler can work with (see How the plugin finds the build arguments).

IDE + compiler

In this mode, the plugin asks the compiler in the background which types and members exist after macros have run. The answers are kept and used for:

  • completion: generated members are marked (generated), and generated types appear with the other types,
  • code resolution: references to generated types resolve instead of being reported as unresolved,
  • navigation: Go to Class finds generated types.

References to generated members resolve whenever Use compiler for IDE features (beta) is selected, whatever the completion settings. With its Navigation option, Go to Declaration on such a member opens a preview of the generated code.

The first answer for a class can take a moment, because the compiler has to type the module's build once. Until it arrives, generated members are missing from the list and may be marked as unresolved. When the answer arrives, the editor updates by itself.

Tip

Generated members do not update when you edit a file that a macro reads. Use Restart Compilation Server, or Restart Display Process if the editor uses one, in the Haxe Compilation Server tool window. See Compilation Server.

Compiler only

In this mode, every completion request goes to the compiler, together with the unsaved text of the file. The list shows exactly what the compiler suggests at the caret. The plugin adds only the function suggestions described in Functions where a function is expected. Quick Documentation shows the documentation the compiler sends for each entry.

How a type is inserted depends on what the compiler reports for it:

  • Choosing a type the file does not import adds the import statement.
  • A type that another visible type of the same name hides is inserted by its full path, for example haxe.ds.List where another List is visible.
  • After a dotted path such as haxe.ds., also after new, in a type hint or in an import, the list offers the packages, modules and types under it by their full path.

There is no fallback to the plugin's own completion:

  • If the compiler does not answer within a few seconds (for example, while the server is still starting), no list appears. Invoke completion again a moment later.
  • Where a new class member starts, where you would type public, var or function, the compiler offers nothing, so no list appears there.
  • The compilation server must be on for the module. If it is off, completion stays empty and a No completion source notification appears once. It offers Configure compilation server and Use IDE completion, which switches Completion sources: to IDE only (statically resolved).

For the Haxe versions the compiler-backed features need, see Compilation Server.

Clone this wiki locally