Module Liquidsoap_tooling.Analysis

Typecheck a script without running it, for editor tooling. Nothing here prints or exits.

type diagnostic = {
  1. severity : [ `Warning | `Error ];
  2. code : int;
  3. pos : Liquidsoap_lang_prelude.Pos.t option;
  4. message : string;
}
type env = (string * Liquidsoap_lang_types.Type.scheme) list
type result = {
  1. diagnostics : diagnostic list;
  2. term : Liquidsoap_lang_ast.Term.t option;
    (*

    The typed script, when it parsed. Each type error in it is replaced with a placeholder that typechecks as any type.

    *)
  3. file : string;
    (*

    The script's name, which its own positions carry.

    *)
}
val load_env : string -> env

Raises Failure unless dump was written in the current Liquidsoap_lang_types.Jsoo_safe_env.abi_version.

val check : ?file:string -> env:env -> string -> result

file names the script, so that %include resolves next to it.

val type_at : result -> line:int -> column:int -> string option

The type of the innermost subterm at a 1-based line and a byte column.

val locals_at : result -> line:int -> column:int -> string list

The names the script binds around a position, in enclosing definitions and functions. They shadow the environment's names of the same spelling.

val scope_at : env:env -> result -> line:int -> column:int -> string list

The names a script can write that are in scope at a position: the environment's, and locals_at.

val methods_at : result -> line:int -> column:int -> (string * string) list

The methods of the innermost subterm's type at a position, with their types.

val definition_at : result -> line:int -> column:int -> Liquidsoap_lang_prelude.Pos.t option

Where the variable at a position is bound in the script: by a definition, or as a function's argument. None for the environment's names.

val null_methods : env:env -> (string * string) list

The methods of null.m, which no script can shadow.