Repository navigation
Diagnostics and Inspections
The plugin checks your Haxe code while you type and highlights problems in the editor. Most checks are inspections that you can switch off or give another severity. With the compilation server, the Haxe compiler can report problems too. This page lists the checks, their quick fixes and how to configure them.
| Source | What it checks | How you control it |
|---|---|---|
| Inspections | Typing, validity, naming, unused code and more; see Inspections | Settings | Editor | Inspections, under Haxe |
| Language checks | Code the Haxe compiler rejects, and syntax that does not fit the module's language level; see Language checks | Always on, unless only compiler diagnostics are used |
| Compiler diagnostics | What the Haxe compiler reports, macros included; see Compiler diagnostics | Settings | Build, Execution, Deployment | Compiler | Haxe Compiler |
Use Show Context Actions (Alt+Enter, macOS: ⌥⏎) on a highlighted problem to see its quick fixes. To check many files at once, use Code | Inspect Code….
Code in inactive conditional-compilation branches and code samples in documentation comments are not analyzed. See Conditional Compilation.
All Haxe inspections are under Haxe in Settings | Editor | Inspections. There you can switch each one on or off, change its severity and limit it to a scope, as for any IntelliJ IDEA inspection. All of them are on by default.
The Default severity column shows what the settings page shows before you change anything. A few checks use fixed
highlighting for some findings; for example, unbalanced #if and #end are always shown as errors.
| Inspection | Default severity | Reports |
|---|---|---|
| Duplicate Class Modifiers | Error | A modifier repeated on one class declaration. The quick fix removes the repetition. |
| Duplicate Class Members | Error | A member declared twice in the same class. |
| Field Redefinition | Error | A field that redefines a field of a superclass. |
| Final Field is Initialized | Error | A final field that is never initialized: in place for static fields, in place or in every constructor for instance fields. |
| Inherited Interface Method Signature Compatibility | Warning | A method whose signature does not match a method of an interface that the implemented interface extends. |
| Interface Method Signature Compatibility | Error | An implemented interface member whose types, optional parameters or property access differ from the interface. |
| Method Overrides | Error | A missing or misplaced override, overriding a static, inline or final method, or reducing visibility. |
| Overridden Method Signature Compatibility | Warning | An override whose parameters or return type do not match the overridden method. |
| Interface Method Existence | Error | A class that does not implement all methods of its interfaces or all abstract methods of its abstract base class. The quick fix generates them. |
| Missing Type Specifier | Error | A method of an interface or extern class without parameter or return types. |
| Duplicate Parameter Name | Warning | The same parameter name used twice in one signature. _ is allowed. |
| Property Accessor Existence | Error | A property declared with get or set whose get_/set_ method is missing. The quick fix creates it. |
| Property Accessor Validity | Error | A property accessor that is not get, set, default, null, never or dynamic, or get/set on the wrong side. |
| Property Cannot Be Final | Error | A property with accessors declared final. The quick fix makes it var. |
| Property is Not a Real Variable | Error | A property without storage that has an initializer, or whose accessors read or write it directly. Quick fixes add @:isVar or remove the initializer. |
| Superclass Type Compatibility | Error | An extends that names something that cannot be extended there, such as an interface or a final class. |
| Superinterface Type Compatibility | Error | An implements that names something that is not an interface. |
| Conditional Compilation (Preprocessing) | Warning | Unbalanced or malformed #if, #elseif, #else and #end. |
| Inspection | Default severity | Reports |
|---|---|---|
| Assignment Type Compatibility | Error | An assignment whose value does not fit the variable, rebinding a method that is not dynamic, and writes to final variables. Quick fixes wrap the value in a standard conversion where one exists. |
| Local Variable Initialization | Error | An initializer whose type does not fit the declared type of a variable or field, Void used as a value and ?? operands whose types do not unify. |
| Incompatible Type Check | Error | A type check (expression : Type) whose expression cannot unify with the type. |
| 'Is' Operator Type Correctness | Error | An is whose right side is not a plain type. Below language level 4.2, the stricter rules of Haxe 4.1 apply. The option 'Is' Operator compatibility for Haxe 4.1.x applies them at every level. |
| Binary Operator Applicability | Error | A binary operator the operand types do not support, and operators other than equality used on Dynamic values, which may fail at runtime on static targets. |
| Unary Operator Applicability | Error |
++ and -- on expressions that cannot be written or do not support them. |
| Parameter Default Initializer Compatibility | Error | A parameter default value that is not constant or does not match the parameter type. |
| Inspection | Default severity | Reports |
|---|---|---|
| Type Name Correctness | Error | A type name that does not start with an upper-case letter. The quick fix capitalizes it. |
| Package Name Correctness | Error | A package name that is not lower case or does not match the file's directory. The quick fix corrects it. |
| Inspection | Default severity | Reports |
|---|---|---|
| Interpolated String Quotes | Warning |
$name or ${expression} in a double-quoted string, where Haxe does not interpolate. The quick fix switches to single quotes. |
| Unresolved type | Error | A type or static member name that does not resolve but exists elsewhere in the project. The quick fixes add the import. |
| Unresolved symbol | Warning | A name that does not resolve. Quick fixes create the missing local variable, parameter, field, method, local function, enum value or type. |
| Inspection | Default severity | Reports |
|---|---|---|
| Unused import statement | Warning | An import nothing in the file uses. Quick fixes remove it or optimize all imports of the file. |
| Unused variable | Warning | A local variable that is never read. |
| Unused field | Warning | A non-public field that is never read or written. |
| Unused method | Warning | A non-public method that is never called. |
| Unused function | Warning | A local function that is never called. |
Fields and methods that carry compile-time metadata are not reported, because a macro may use them. With compiler
diagnostics on, only metadata the compiler knows counts, so a misspelled metadata name does not hide a finding; the
unused checks then also count the uses the compiler finds in macro-generated code. With Haxe 3, which does not list
the metadata it knows, any metadata still counts. To keep a field or method that looks unused, add @:keep; the
quick fix Add @:keep metadata to 'name' does that for you.
| Inspection | Default severity | Reports |
|---|---|---|
| Deprecated symbol | Warning | Uses of fields, methods, classes and other symbols marked @:deprecated. |
These inspections check hxml files and the XML files the plugin recognizes as Lime, OpenFL or NME project files (see Build Files).
| Inspection | Default severity | Reports |
|---|---|---|
| Define name with a dash | Warning | A -D define in an hxml file, or a <haxedef> or <define> in a project file, whose name contains a dash. The compiler registers it with underscores, so #if only finds that spelling. The quick fix Replace with 'name' rewrites the name; for a Lime <define> it also renames the uses in if, unless and ${...}. |
| Library not installed | Warning | A -lib line or <haxelib name> whose library haxelib has not installed, or not in the pinned version. The quick fix Install 'name' Using Haxelib installs it. See Libraries and Haxelib. |
| Include file not found | Warning | An <include path> (or <include name>) of a project file that names nothing on disk, or a folder without an include.lime, include.nmml or include.xml. Paths with ${...} and <include haxelib> are not checked. |
| Inspection | Group | Default severity | Reports |
|---|---|---|---|
| Compiler errors and warnings | Compiler diagnostics | Error | See Compiler diagnostics. |
| Compiler unused imports | Compiler diagnostics | Warning | See Compiler diagnostics. |
| Compiler unused code | Compiler diagnostics | Warning | See Compiler diagnostics. |
| NMML Build Directory Inspection | Haxe | Warning | NME project files that do not use separate build directories for release and debug builds. The quick fix Create debug tag adds one. |
Some checks are not inspections. Most of them report code that the Haxe compiler rejects, so you cannot switch them off one by one. They include:
- a field without a type and without an initializer,
- the wrong number of type parameters,
- rules for abstract classes and methods, constructors,
supercalls and__init__, - calls with the wrong number or types of arguments, or calls on values that are not functions,
- access to private fields, and static access to instance fields or the other way around,
- a missing
return, or a return value that does not fit the return type, - more than one
packagestatement, - conditions in
#ifthat the compiler would reject (see Conditional Compilation), - language features the module's language level does not have (see the next section).
The plugin also offers small improvements without reporting a problem, for example Convert to String interpolation for string concatenations.
Each module has a language level, the Haxe version whose syntax the editor expects; see
Core Concepts. Syntax that is newer than the language level is an error, for example
arrow functions below 4.0 or ?? below 4.3. Syntax that a newer version removed is an error too, such as custom
accessor method names at 4.0 and later. The quick fix Set language level to version changes the module's
language level.
Where the old and the new spelling of a construct mean the same, the plugin also converts between them:
| Older form | Newer form | Newer form needs |
|---|---|---|
@:enum abstract |
enum abstract |
4.0 |
@:final |
final |
4.0 |
@:extern on a field or method |
extern on a field or method |
4.0 |
Std.instance |
Std.downcast |
4.0 |
__js__, __php__
|
js.Syntax.code, php.Syntax.code
|
4.0 |
Std.is |
Std.isOfType |
4.1 |
At or above the level in the last column, the older form is a warning, and the quick fix Replace with newer form
updates it. Below that level, the newer form is reported, and Replace with older form converts it back. A final
field or local variable has no older form; below 4.0 the quick fix turns it into var.
@:enum abstract Mode(Int) { // warning at language level 4.0 and later
var Fast = 1;
}
// after "Replace with enum abstract":
enum abstract Mode(Int) {
var Fast = 1;
}
Note
Beta. Compiler diagnostics work and are supported, but may still change. They need Haxe 4.3.5 or later, or Haxe 3.4.7, and the compilation server.
With compiler diagnostics, the Haxe compiler checks the file you edit and the editor shows what it reports. Because it is the real compiler, it also sees code that macros generate, which the plugin's own analysis cannot.
- Open Settings | Build, Execution, Deployment | Compiler | Haxe Compiler.
- Select Use compiler diagnostics (beta).
- Set the options below it and click OK.
The options apply only while Use compiler diagnostics (beta) is selected:
| Option | Default | What it does |
|---|---|---|
| Errors and warnings | On | Shows compiler and parser errors, deprecation warnings, unresolved identifiers and missing fields. |
| Unused imports | Off | Shows the imports the compiler finds unused after macros ran. While on, it replaces the Unused import statement inspection. |
| Unused code | Off | Shows the unused local variables and functions the compiler reports. While on, it replaces the Unused variable and Unused function inspections. The compiler does not report unused fields or methods. |
| Compiler diagnostics only | Off | Turns off the plugin's own checks: inspections and language checks. Syntax highlighting and parser errors stay. |
The compiler also needs a build it can compile: see How the plugin finds the build arguments.
- Problems are highlighted with the compiler's severity: errors, warnings, and weak warnings for hints. Deprecated code is struck through, unresolved names are shown like unknown symbols, and unused imports and code are grayed out.
- Each file is checked by the build it is analyzed under, its resolve context. A Node.js program's main class, for example, is checked as the Node.js build compiles it, whichever build file is active.
- Unsaved changes are checked too. While a file has a syntax error, the compiler is not asked; the parser's error marks show the problem.
- Files with compiler errors are marked as problem files in the Project view and in the editor tabs. This also marks files you have not opened, as long as the build reaches them.
- A deprecation warning about a construct the module's language level cannot replace yet is hidden.
| Problem | Quick fixes |
|---|---|
| Unresolved identifier | Import 'name' for each type the compiler suggests, and Change to 'name' for each spelling it suggests. |
| Missing fields | Implement missing members, Create constructor initializing final fields, Create function 'name' or Create field 'name', depending on what is missing. |
| Deprecated syntax | Replace with newer form, as described in Language levels and syntax migration. |
| Unused import | Remove unused import |
| Unused code | Remove unused code, or Replace with compiler suggestion when the compiler proposes a replacement. |
The three inspections in the Compiler diagnostics group belong to these options: Compiler errors and warnings, Compiler unused imports and Compiler unused code. They let Code | Inspect Code… include the compiler's findings. If you switch one of them off in Settings | Editor | Inspections, the editor stops showing that kind of compiler problem too.
The plugin does not support suppression comments in Haxe code. To silence a check:
- switch the inspection off, or lower its severity, in Settings | Editor | Inspections,
- or limit it to a scope there, so that it does not run on some files.
Language checks cannot be switched off one by one. Compiler diagnostics only turns them off together with all inspections, while the compiler's own diagnostics stay.
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