Skip to main content

Crate lattice_compilation

Crate lattice_compilation 

Source
Expand description

Native compilation mode: runs a build / test / lint command off-thread and streams its output into a read-only *compilation* buffer (CM.1).

Runs a build/test/lint command off-thread (pipe-captured) and streams its stdout+stderr into a read-only synthetic *compilation* Document buffer live. The emacs compilation-mode / M-x recompile and vim :make workflow’s streaming half, on Lattice’s substrate.

This is a native built-in wired through the SubsystemBoot install seam (not a plugin). CM.1 delivers the streaming buffer plus :compile / :recompile / :make. The error list (CM.2), parser registry (CM.3), and *problems* multibuffer view (CM.4) land in later slices — see docs/dev/architecture/compilation-mode.md and its slice plan.

§Shape

  • [events] — the CompilationOutputPushed typed event + OutputChunk.
  • [mode] — CompilationMode (ReadOnly + NoFile major) + its streaming drain.
  • [service] — CompilationService (process lifecycle, pipe-capture, kill-on-recompile) off the actor thread.
  • [ex_commands] — :compile / :recompile / :make.
  • install — the crate-owned SubsystemBoot entry point.

Structs§

AnsiPalette
The interned theme elements CM.5 paints ANSI output with.
CleanLine
One line with every escape sequence removed, plus the spans that describe what colour the surviving bytes were.
CompilationHeaderline
A Headerline impl backed by CompilationHeadlineState.
CompilationHeadlineState
Shared state the compilation drain updates and the headerline renderer reads.
CompilationLocation
CM.3b: a source location parsed out of a single *compilation* buffer line by parse_location_line for the <CR>-jump. line / col are 0-based — the error substrate + Editor::jump_to_file_line_col convention.
CompilationMode
Major mode for the *compilation* buffer.
CompilationOutputPushed
Typed event carrying one OutputChunk from the compilation service to the *compilation* buffer drain.
CompilationParserFactories
The registered set of plugin parser factories, in registration order.
DefaultCompilationService
Default CompilationService: sh -c <cmd>, pipe-captured, streamed over the event bus.
ParserRegistry
The active set of parsers. Feeds each line to every parser and concatenates their entries. The Vec<Box<dyn CompilationParser>> is the extensibility seam: built-in parsers, plus (CM.6) WASM-contributed ones — a plugin implementing the error-parser world is registered here as one more Box<dyn CompilationParser> and is indistinguishable from a native parser downstream.
SgrState
Active SGR attributes.

Enums§

OutputChunk
One unit of streamed compilation output. The drain applies these in arrival order:

Constants§

COMPILATION_BUFFER_NAME
Synthetic name of the streaming compilation buffer. :ls and :b *compilation* reach it; :bn / :bp skip it (listed = false).
COMPILATION_HEADERLINE_PROVIDER_ID
Provider id tag for the compilation headerline so re-activations can unregister / register idempotently.

Traits§

CompilationParser
A named matcher over streamed compiler-output lines producing [ErrorEntry]s.
CompilationParserFactory
Mints a fresh CompilationParser for one pipe reader.
CompilationService
Process-lifecycle surface. Registered in the ServiceRegistry at boot (as CompilationServiceHandle); the AppEffect::CompileRun host arm looks it up and calls CompilationService::run (after creating the *compilation* buffer host-side).

Functions§

apply_chunk
Pure model of applying one chunk to the current buffer text.
clean_line
Strip escape sequences out of one line, returning the clean text and its spans. state is updated in place so the next line continues where this one left off.
gutter_level
CM.3c: map the parser-native [ErrorSeverity] onto the renderer- facing [GutterSeverityLevel] (Error→Error, Warning→Warning, Info→Info, Note→Info). The single conversion in the whole compilation-severity pipeline — the parser, the inbound bus, and the AppEffect payload all carry ErrorSeverity, and the host arm calls this once when writing the render-state slot. Note collapses to Info because GutterSeverityLevel has no Note rank; there is no reverse conversion, so nothing is lost by round-trip.
install
Wire the compilation subsystem’s ex-commands, mode, service, and off-keystroke wake into the editor at boot. One Phase-B line in editor_boot.rs.
match_severity
CM.3c: the severity a single *compilation* line declares, or None when it carries no severity keyword. Reuses the built-in rustc-header and gnu-full-form patterns (via [crate::parsers::match_severity]) — the same compiled regexes the streaming parsers use. Keyword-driven: progress / summary / prose / location (-->) / gnu-short lines return None. The severity gutter mark lands on the line where the severity is textually visible (the rustc header line; the gnu full-form line), mirroring emacs compilation-mode.
parse_location_line
CM.3b: parse a source location out of ONE *compilation* buffer line — the <CR>-jump seam. Runs the built-in rustc---> and gnu-style location regexes (the same compiled patterns the streaming parsers use, via [crate::parsers::match_location_line]) against the line and returns the first match, converting 1-based line/col to 0-based. None when the line carries no navigable location (progress, summary, backtraces, prose).
register_compilation_ex_commands
Register :compile / :recompile / :make.
scan_location_lines
CM.3c: scan a block of streamed text for severity lines, returning (absolute_line, severity) for each match. base_line is the 0-based buffer line number the block’s FIRST line lands on; line i of the block (via str::lines) maps to absolute line base_line + i.
scan_severities
CM.3c: scan a block of streamed text for severity lines, returning (absolute_line, severity) for each match. base_line is the 0-based buffer line number the block’s FIRST line lands on; line i of the block (via str::lines) maps to absolute line base_line + i.
start_compilation
Provision the *compilation* buffer and kick off a run — the compilation mode’s own responsibility, driven through the &mut-backed [ModeActivator::ensure_named_document] creation seam.

Type Aliases§

CompilationAnsiSlot
CM.5: write-once slot holding the interned compilation.ansi.* element ids the pipe readers paint captured SGR with.
CompilationGutterBusHandle
CM.3c: the off-thread → host-state seam for the *compilation* buffer’s per-buffer severity gutter index. The compilation drain (in CompilationMode::on_activate) sends (buffer_id, full_index) through this bus whenever the index changes; the install-registered handler maps each send to [AppEffect::CompilationGutterSet]. Registered as a ServiceRegistry handle under this exact alias (per the Arc/TypeId convention); the drain looks it up via ctx.service::<CompilationGutterBusHandle>(). send bakes in the editor wake, so marks reach the screen off-keystroke.
CompilationLocationBusHandle
CM.3c (2026-07-22): the off-thread → host-state seam for the *compilation* buffer’s location-line index (theme-based highlighting). Twin of CompilationGutterBusHandle: the compilation drain sends (buffer_id, full_location_lines) through this bus whenever the index changes; the install-registered handler maps each send to [AppEffect::CompilationLocationLines]. Registered as a ServiceRegistry handle under this exact alias; the drain looks it up via ctx.service::<CompilationLocationBusHandle>().
CompilationParserFactoriesHandle
The runtime-mutable handle, registered as a boot service under this exact alias (the ServiceRegistry Arc/TypeId convention).
CompilationServiceHandle
Per the ServiceRegistry Arc/TypeId convention: register and look up under this exact alias.
CompilationThemeColorsBusHandle
CM.3d (2026-07-22): the theme colours bus — the mode sends resolved (bg, fg) once during activation; the handler maps to [AppEffect::CompilationThemeColors].