Files
Lyrebird/LiveCompile/Sources/LyrebirdLiveCompile/Diagnostic.swift
T
josh b6fdee8bfc Lyrebird 2.0.0 — Linux support
Consolidated release: the cross-platform Linux port (engine, generators, CLI,
REPL, NRT, portable DSP), live ALSA audio + ALSA MIDI + POSIX OSC + portable
WAV codec, the GTK4 GUI (LyrebirdUI on the SwiftOpenUI backend), and the Linux
live-coding scratchpad (LiveCompile). Apple platforms unchanged; all additive.
See RELEASES.md and LINUX_README.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-09-10 21:09:11 -07:00

53 lines
1.6 KiB
Swift

// Diagnostic.swift
// Lyrebird
//
// Copyright (c) 2026 Joshua Parmenter / realizedsound
// SPDX-License-Identifier: MIT
// LyrebirdLiveCompile
//
// One parsed `swiftc` diagnostic, with `line` already mapped from the wrapped-
// snippet coordinate space back to the user's snippet coordinate space (via the
// `userBodyLineOffset` from `SnippetHarness.wrap(userBody:)`).
//
// The editor (`LyrebirdScratchView`) renders diagnostics in its
// margin gutter using `(line, column)` directly.
#if os(macOS) || os(Linux)
public struct Diagnostic: Equatable, Sendable {
/// 1-based line number in the **user's** snippet body. May be `nil` when the
/// diagnostic landed inside the harness preamble (i.e. the wrapped line
/// number is less than `userBodyLineOffset`) — that almost always points at
/// the user importing a missing module or otherwise breaking the preamble.
public let line: Int?
/// 1-based column number. swiftc emits the same column for preamble and
/// user-body lines, so no translation is needed.
public let column: Int
public let severity: DiagnosticSeverity
public let message: String
/// 1-based line number swiftc actually reported, before user-coordinate
/// translation. Useful for debugging the parser; not surfaced to end users.
public let rawLine: Int
public init(
line: Int?,
column: Int,
severity: DiagnosticSeverity,
message: String,
rawLine: Int
) {
self.line = line
self.column = column
self.severity = severity
self.message = message
self.rawLine = rawLine
}
}
#endif