Repository navigation
Editor Extras
This page collects the editor features that are not covered elsewhere: highlighting and colors, doc comments, inlay hints, templates, folding, the structure view, typing aids, links in strings, spell checking and the SDK banners. Completion, inspections, refactorings and formatting have their own pages: Code Completion, Diagnostics and Inspections, Refactoring and Navigation and Formatting and Code Style.
Colors for Haxe code are in Settings | Editor | Color Scheme | Haxe. Besides keywords, numbers, strings and comments, the plugin colors code by meaning: parameters, local variables, instance and static fields and methods, classes, interfaces and type parameters each have their own entry. The entries are grouped like this:
| Group | Entries |
|---|---|
| Comments | Line comment, Block comment, Documentation comment, Documentation inline code, Documentation tag |
| String | String text, Escape sequence (Valid and Invalid), File link, Code link |
| Braces and Operators | Operator, Parenths, Brackets, Braces, Comma, Dot, Semicolon |
| Classes and Modules | Class name, Interface name, Instance variable, Instance method, Static method, Static variable |
| Parameters | Parameter, Type parameter |
| Conditional compilation | Conditional code, Defined flag, Undefined Flag, Error directive. See Conditional Compilation. |
| Xml/Markup literal | Tags, Attribute name, for inline XML markup in Haxe code |
| Ungrouped | Keyword, Number, Metadata, Local variable, Reification expressions, Injected language, Unparseable data, Bad character |
Escape sequences in strings are highlighted, and an invalid escape sequence gets its own color. Unparseable data marks code the parser could not make sense of.
Build files in hxml format have their own page, Settings | Editor | Color Scheme | HXML, with the entries Key, Value, Comment, Include and ClassName.
More highlighting in Haxe files:
-
Colors in hex literals: a six-digit color literal such as
0xFF8800shows a color swatch in the gutter. Click the swatch to pick another color; the literal is rewritten in place. -
Regular expressions: the pattern of a regular expression literal (
~/[a-z]+/i) is highlighted and checked as a regular expression. -
GLSL shaders: with the GLSL plugin installed, the strings of
OpenFL's shader metadata (
@:glFragmentSource,@:glVertexSource,@:glFragmentHeader,@:glVertexHeader,@:glFragmentBodyand@:glVertexBody) are edited as GLSL.
Haxe doc comments start with /** and end with **/, and their text is Markdown.
- Type
/**and press Enter: the IDE adds the closing**/and puts the caret on the empty line between. - Press Enter inside a doc comment: the new line starts at the same indentation as the line before, so aligned descriptions stay aligned.
- Type
@at the start of a line and invoke basic completion (Code | Code Completion | Basic): the IDE offers the tags it understands,@param,@return,@throws,@event,@sinceand@see. The completion list does not open by itself in comments. - Tags and
inline codeare highlighted with the Documentation tag and Documentation inline code colors. - A fenced code block is highlighted as the language in its first word:
```haxe,```hxor a fence without a language as Haxe; other words as the IDE language of that name (for example```json). Errors inside code blocks are not reported, and Haxe code blocks offer no completion.
How doc comments are indented when you reformat is a code style option; see Formatting and Code Style.
View | Quick Documentation on a symbol shows its signature and its doc comment, rendered as Markdown:
-
@paramand@returnlines become a table with the columns Argument and Description;@eventand@throwslines become tables with Event or Exception and Description. -
@since 4.1is shown as "Available since 4.1", and@seelines as a "see also:" list. - Inline code that names a class, a member or a parameter becomes a link to it.
- Fenced code blocks and inline code are syntax-highlighted.
- A symbol with
@:deprecatedmetadata shows Deprecated, with the message from the metadata if there is one.
Quick Documentation also explains the compiler's built-in metadata: on @:keep, for example, it shows what the
metadata does and the targets it applies to. For metadata that takes arguments, the arguments are listed too.
To read doc comments rendered right in the editor, use the IDE's Toggle Rendered View icon in the gutter, or select Render documentation comments in Settings | Editor | General | Appearance to render all of them.
Settings | Languages & Frameworks | Haxe | Documentation has four options, all on by default:
| Option | What it does |
|---|---|
| Highlight code blocks as their language (```haxe fences) | Highlights fenced code blocks in their language. |
| Highlight tags and inline code (@param, `code`) | Colors doc tags and inline code. |
| Complete documentation tags | Offers the tags after @. |
| Enter continues at the previous line's indentation | Keeps the indentation of the line above when you press Enter. |
Inlay hints are set up in Settings | Editor | Inlay Hints.
Under Types, the plugin adds hints that show inferred types where your code does not write them. All of them are on by default:
| Hint | Shows |
|---|---|
| Local variable types | The type of a local variable without a type hint. |
| Field types | The type of a field without a type hint. |
| Return types | The return type of a function without one. |
| untyped parameters | The type of a function parameter without a type hint. |
| for-loop types | The type of a for loop variable. |
| capture variable types | The type of a variable that captures the value in a switch case, such as case var x:. |
| Enum extractor types | The types of the values bound by an enum pattern, such as case Rgb(r, g, b):. |
| Compiler types (beta) | The types the Haxe compiler infers for these declarations. It shows hints only while the compiler provides the type hints; see Type hints from the compiler. |
Under Parameter names, the plugin shows the parameter name next to an argument. It has these options:
| Option | Default |
|---|---|
| Parameter name hints in constructors | On |
| Parameter name hints in method and function calls | On |
| Parameter name hints in EnumValue constructors | On |
| Parameter name hints also for non-literal arguments | Off: hints are shown only for literal arguments, such as numbers and strings. |
Calls to common methods such as get(...), set(...) and indexOf(...) are excluded by default; edit the exclude
list on the same settings page.
Note
Beta. Type hints from the compiler work and are supported, but may still change.
The other type hints come from the plugin's own analysis. To show the types the Haxe compiler infers instead:
- Open Settings | Build, Execution, Deployment | Compiler | Haxe Compiler.
- Select Use compiler for IDE features (beta). The Type inlays option below it is selected by default.
Then:
- The Compiler types (beta) hint shows the types, and the plugin's other type hints show nothing.
- A type name in a hint is a link to the type's declaration.
- A declaration the compiler has not answered for shows no hint; the plugin does not fill in a type of its own.
- The types of class members follow the files on disk and update after you save. In a file with unsaved changes, the plugin asks the compiler about each declaration with the editor's text, and with Haxe 3.4.7 it always does.
This needs the compilation server, switched on for the module.
Type an abbreviation and press Tab to expand it. The Haxe templates are in Settings | Editor | Live Templates, group Haxe, where you can change them or add your own.
| Abbreviation | Expands to |
|---|---|
iter |
A for (o in array) loop over an array in scope. |
itar |
An indexed loop, for (i in 0...array.length), with var o = array[i]; inside. |
ritar |
A reverse indexed loop, var i = array.length; while (i-- > 0), with var o = array[i]; inside. |
pv, prv
|
public var, private var
|
psv, prsv
|
public static var, private static var
|
psiv, psc
|
public static inline var (both expand to the same text) |
pf, prf
|
A public function or private function with a name, arguments and a Void return type to fill in. |
psf, prsf
|
The same for public static function and private static function. |
Select statements and use Code | Surround With… to wrap them in if, if / else, while, do / while or try / catch.
Right-click a source folder, open New and choose the Haxe class entry. In the New Haxe Class dialog, enter the
name and pick the kind: Class, Interface, Enum, Abstract or Module. The new file gets the
package line of its folder. The Abstract template has no underlying type yet, so add one, for example
abstract Meters(Float) {}.
The templates are listed in Settings | Editor | File and Code Templates, where you can change them. Templates you
add there with the extension hx appear in the dialog too. The entry is offered in modules that have a Haxe SDK or
contain Haxe or hxml files.
You can fold:
- the imports and
usingstatements at the top of a file, - code blocks,
switchblocks and object literals, - the bodies of classes, interfaces, enums, abstracts and anonymous structures,
- array and map literals, macro reification blocks and inline XML tags,
- doc comments, and runs of several
//line comments, - every branch of an
#ifblock (see Conditional Compilation), - custom regions marked with comments, in any of these styles:
class Main {
// region Helpers
static function helper() {}
// endregion
/*{ region Constants */
static inline final LIMIT = 10;
/*} end region */
/*# region Fields */
var count:Int;
/*# end region */
}Which of these are folded when a file opens is set in Settings | Editor | General | Code Folding. Besides the IDE's own options for imports and doc comments, there are four Haxe options:
- Haxe: IDEA style regions: /* region title */ ... /* end region */
- Haxe: FlashDevelop style regions: /*{ region title */ ... /*} end region */
- Haxe: C#/AS3 style regions: /*# region title */ ... /*# end region */
- Haxe: Unused conditionally compiled code: #if/#else/#elseif/#end
The Structure tool window and the File Structure popup list the types of the file and their members. Under a class, its parent class and interfaces are listed first. You can sort the list alphabetically or by visibility, and the Show Fields button shows or hides fields.
The editor breadcrumbs show where the caret is: the enclosing class, interface, enum, abstract or typedef, and the method or local function.
-
Pairs: the IDE closes
(,[,{and quotes, and highlights the matching bracket. Typing<after a type name adds>, and typing{after$in a string adds}. -
Comments: Comment with Line Comment uses
//, Comment with Block Comment uses/* */. In hxml files, line comments use#. -
Complete Current Statement: adds a missing semicolon, turns a bare
ifinto anif (...) {}statement and adds the braces of a class body. It also works in inactive#ifbranches. - Move Statement Up and Move Statement Down: on a declaration such as a class or a function, move the whole declaration past its neighbor, together with its doc comment and metadata.
- Extend Selection and double-click select single words inside strings, comments and doc comments.
-
Paste: when you paste Haxe code into another file, the IDE adds the imports and
usingstatements it needs, following the Insert imports on paste: option in the Java section of Settings | Editor | General | Auto Import. - Parameter Info shows the parameters of the function you are calling.
- Code | Generate… adds a Constructor, Getter, Setter or Getter and Setter for fields you choose. Code | Override Methods… and Code | Implement Methods… add members from parent classes and interfaces.
Press Show Context Actions to see what applies at the caret. The Haxe intentions are:
| Intention | Applies to |
|---|---|
| Surround with double quotation marks, Surround with single quotation marks | A string: switches its quotes. |
| Add explicit field type to declaration, Remove explicit field type from declaration | A field. |
| Add explicit return type to declaration, Remove explicit return type from declaration | A function. |
| Convert variable to property (default), (get/set), (read only) | A variable, turned into a property with those accessors. |
| Convert property to variable | A property. |
| Split into declaration and assignment | A local variable with an initializer. |
| Introduce for-loop for expression, Introduce for-loop for expression (key-value) | An expression you can iterate. |
| Replace with single class imports | A wildcard import. |
Quick fixes for reported problems are described in Diagnostics and Inspections.
A string literal whose content names a file or a class becomes a link: Ctrl+click it (Cmd+click on macOS), or use Navigate | Declaration or Usages.
-
File paths: an absolute path, a path relative to the project's root folder or a path relative to the folder of
the current file, for example
"assets/data/levels.json". These links use the File link color of the String group. -
Qualified names: a dotted name of a class or of a member, for example
"com.example.Main"or"com.example.Main.run". These links use the Code link color.
Strings with interpolation ('${...}') and ordinary text never become links.
Completion works inside strings too. Basic completion offers files and folders for a path, and packages, types and
members for a qualified name. The list opens by itself after you type / in a path, or after the second . of a
qualified name that starts with a known package.
The IDE's spell checker checks the names you declare, comments, doc comments and string literals in Haxe code. With the bundled Natural Languages plugin enabled, comments, doc comments and string literals are also checked as natural-language text; the interpolated parts of strings are left out of that check.
When a Haxe file belongs to a module without a usable Haxe SDK, a banner appears above the editor:
- No Haxe SDK is configured for this module - pick one here or in the Haxe tool window under Environment. Click Setup SDK in the banner to pick or add an SDK for the module.
-
Haxe SDK has no valid root. Set up or change SDK. None of the SDK's folders contains the Haxe standard
library. When the
HAXE_STD_PATHenvironment variable is set, the banner reads Haxe SDK has no valid root: no folder in HAXE_STD_PATH (...) contains the standard library instead, with the variable's value in the brackets.
See Installation for registering a Haxe SDK.
Getting started
Working with projects
- The Haxe Tool Window
- Build Files
- Targets and Sections
- Resolve Context
- Libraries and Haxelib
- Defines and Custom Targets
- Building and Running
- Run Configurations
- Tools
- Compilation Server
Debugging
Testing
Profiling
Editing code
- Code Completion
- Diagnostics and Inspections
- Refactoring and Navigation
- Formatting and Code Style
- Conditional Compilation
- Editor Extras
Reference