Documentation
¶
Overview ¶
Package source provides source file management and text indexing for the SysML v2 parser.
This package defines SourceFile, which represents a single input file (either .sysml or .kerml), along with Span and Position types for tracking locations in source text. LineIndex provides efficient line/column lookups for error reporting and IDE features.
All source locations are represented as byte offsets; LineIndex converts between offsets and user-facing line:column positions on demand.
Package source owns file content and byte-offset span types.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LineIndex ¶
type LineIndex struct {
// contains filtered or unexported fields
}
LineIndex maps byte offsets to 1-based line/column positions. lineStarts[i] is the byte offset where line (i+1) begins.
type SourceFile ¶
type SourceFile struct {
// contains filtered or unexported fields
}
SourceFile owns the raw bytes of one source file.
func New ¶
func New(name string, content []byte) *SourceFile
New creates a SourceFile from a name and its raw bytes.
func (*SourceFile) Bytes ¶
func (sf *SourceFile) Bytes() []byte
Bytes returns the raw content (do not mutate).
func (*SourceFile) Len ¶
func (sf *SourceFile) Len() int
Len returns the byte length of the content.
func (*SourceFile) Lines ¶
func (sf *SourceFile) Lines() *LineIndex
Lines returns a LineIndex for this file (recomputed each call; cache at call site if hot). Col is a byte column (1-based). LSP requires UTF-16 code-unit columns; that conversion is an LSP-layer concern (Plan 06), not the source package.
func (*SourceFile) Text ¶
func (sf *SourceFile) Text(sp Span) string
Text returns the substring covered by the span.