RunMat
GitHub

Diagnostics & Highlighting

Diagnostics and semantic highlighting come from a static analysis pass over the current document. The server tokenizes, parses, lowers to HIR, runs static analysis, performs a VM compile check, and converts those results into LSP diagnostics and semantic tokens.

Error Diagnostics

RunMat emits error diagnostics from four stages:

Problem typeExampleDiagnostic sourceRange selection
Syntax errorAn unfinished expression or mismatched delimiter.runmat-parserError range at the unexpected token or best available location.
Lowering errorA binding, call, import, or language construct cannot be resolved into HIR.runmat-hirError range at the HIR span or a best-effort symbol range.
Compile errorLowered code cannot be compiled to VM bytecode.runmat-vmError range at the compile-error span when one is available.
Static-analysis errorShape or MIR analysis reports an error-severity diagnostic.runmat-hirError diagnostic with a code and message.

The language server reports the earliest blocking compiler result first. A syntax error prevents reliable lowering, so parser diagnostics take precedence in the editor. If parsing succeeds but lowering fails, the HIR error is shown. If lowering succeeds but bytecode compilation fails, the VM compile error is shown. Once the document is analyzable, shape and MIR diagnostics are added.

Warnings, Hints, And Status

The LSP also reports non-error diagnostics from static analysis.

SeverityTypical meaning
ErrorThe document cannot be parsed, lowered, compiled, or statically validated.
WarningStatic analysis found a non-blocking issue.
InformationThe server has non-blocking analysis status to report.
HintHelpful static-analysis guidance.

The native server also emits a runmat/status notification after analysis. Hosts can use that to show lightweight status like ok or the current blocking error summary without reinterpreting the diagnostics list.

Analysis Flow

Loading diagram...

This analysis does not run the program, mutate variables, call user functions, or trigger runtime side effects.

Highlighting

Semantic highlighting combines lexer token classes with information learned during lowering.

Token typeWhat it marks
keywordMATLAB/RunMat control-flow and declaration keywords.
functionFunction declarations and call sites. Builtin calls receive the defaultLibrary modifier.
variableLocals, outputs, globals, and generic identifiers.
parameterFunction input bindings.
namespaceImports and package references.
string, number, operator, commentDirect lexer token classes.

Declarations receive the declaration modifier. Builtin calls receive defaultLibrary, allowing themes to distinguish standard-library calls from user-defined functions.

Project-Aware Feedback

When a document URI points into a RunMat project, the server discovers the nearest project manifest and the project composition graph. That extra context improves:

  • unresolved function checks during lowering;
  • go-to-definition and references across files;
  • workspace symbols from unopened project files;
  • reanalysis of dependent open documents when exported functions change.

If project discovery is unavailable, the server still analyzes the open document and builtins, but cross-file feedback is limited.