lint · API

mojolint.facts

What the compiler knows and the text does not, fetched in one LSP batch.

For every function: its resolved signature. For every var local: its resolved type and every name-resolved use. For every struct field: its resolved type. That is the whole of what the rules ask the compiler for, and it is enough to replace the three textual guesses in tier 1 — "mentioned again" (references), "spelled MutUntrackedOrigin" (types, so aliases and helpers count), and "built as var x = S(" (types again).

Facts() with no arguments is the empty set; every lookup then comes back empty and the rules fall back to their textual form.

Structs

Facts

struct Facts

Implements Movable

Fields
available: Bool
errors: Int: Parse errors the server reported: types may be missing when > 0.
local_types: Dict[String, String]
local_uses: Dict[String, List[Pos]]: Every reference to a local, declaration first, sorted.
field_types: Dict[String, String]
signatures: Dict[String, String]

__init__

def __init__(out self)

local_type

def local_type(self, f: Func, name: String) -> String

The resolved type of local name in f; empty if unknown.

last_use

def last_use(self, f: Func, name: String) -> Optional[Pos]

The last reference to local name after its declaration.

field_type

def field_type(self, s: Struct, field: String) -> String

signature

def signature(self, f: Func) -> String

def f(...) with every type resolved; empty if unknown.

Functions

collect_facts

def collect_facts(path: String, source: String, lines: List[Line], mod: Module, include: List[String]) -> Facts

Ask the server about every function, local and field in mod.