source

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 18, 2026 License: Apache-2.0 Imports: 0 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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.

func (*LineIndex) OffsetAt

func (li *LineIndex) OffsetAt(p Pos) int

OffsetAt returns the byte offset for a 1-based line/col.

func (*LineIndex) PosAt

func (li *LineIndex) PosAt(offset int) Pos

PosAt returns the 1-based line/col for a byte offset. Col counts bytes from the line start + 1.

type Pos

type Pos struct {
	Line int
	Col  int
}

Pos is a 1-based line/column location.

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) Name

func (sf *SourceFile) Name() string

Name returns the file name.

func (*SourceFile) Text

func (sf *SourceFile) Text(sp Span) string

Text returns the substring covered by the span.

type Span

type Span struct {
	Offset int
	Len    int
}

Span is a byte range within a SourceFile: [Offset, Offset+Len).

func (Span) End

func (s Span) End() int

End returns the exclusive end offset.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL