Documentation
¶
Overview ¶
Package compiler implements the Hime-san .sando compiler.
Index ¶
- Constants
- Variables
- func Compile(path string, source []byte) (CompiledFile, []Diagnostic)
- type AnalysisImport
- type AnalysisRegion
- type AnalysisRegionKind
- type CompiledFile
- type Context
- type Diagnostic
- type DiagnosticsError
- type DocumentAnalysis
- type FileResult
- type Result
- type Severity
- type SourceInput
Constants ¶
const RuntimeABI = version.RuntimeABI
RuntimeABI is the generated-code/runtime compatibility boundary for v1.
Variables ¶
var CompilerVersion = version.Compiler
CompilerVersion mirrors the release-injected compiler version for callers that need to display provenance alongside generated output.
Functions ¶
func Compile ¶
func Compile(path string, source []byte) (CompiledFile, []Diagnostic)
Compile parses, context-checks, and formats one .sando source entirely in memory. It never reads project metadata, writes a file, or executes Go code.
Types ¶
type AnalysisImport ¶
AnalysisImport describes one import already present in a .sando header.
type AnalysisRegion ¶
type AnalysisRegion struct {
Kind AnalysisRegionKind `json:"kind"`
Text string `json:"text,omitempty"`
Context Context `json:"context,omitempty"`
Offset int `json:"offset"`
Length int `json:"length"`
Line int `json:"line"`
Column int `json:"column"`
}
AnalysisRegion describes a Hime-san tag body using zero-based byte offsets. Line and Column retain the compiler's one-based byte-coordinate convention; protocol adapters convert them to UTF-16 where required.
type AnalysisRegionKind ¶
type AnalysisRegionKind string
AnalysisRegionKind identifies an author-visible template region.
const ( AnalysisStatement AnalysisRegionKind = "statement" AnalysisExpression AnalysisRegionKind = "expression" AnalysisComponent AnalysisRegionKind = "component" AnalysisComment AnalysisRegionKind = "comment" )
type CompiledFile ¶
type CompiledFile struct {
SourcePath string
OutputPath string
Package string
Component string
Digest string
Code []byte
// contains filtered or unexported fields
}
CompiledFile is a fully validated generated output held in memory.
type Context ¶
type Context string
Context identifies the escaping context assigned to a renderer operation.
type Diagnostic ¶
type Diagnostic struct {
Path string `json:"path"`
Line int `json:"line"`
Column int `json:"column"`
Code string `json:"code"`
Severity Severity `json:"severity"`
Message string `json:"message"`
}
Diagnostic is a stable, machine-readable compiler message. Line and Column are one-based. A diagnostic without a source position uses line and column 1.
func DiscoverSources ¶
func DiscoverSources(ctx context.Context, paths []string) ([]string, []Diagnostic)
DiscoverSources finds .sando sources using the same filesystem, symlink, nested-module, VCS, and vendor boundaries as Generate and Check. It omits generated-output inspection because editor analysis does not own freshness.
func (Diagnostic) Error ¶
func (d Diagnostic) Error() string
type DiagnosticsError ¶
type DiagnosticsError struct {
Diagnostics []Diagnostic
}
DiagnosticsError reports one or more error diagnostics.
func (*DiagnosticsError) Error ¶
func (e *DiagnosticsError) Error() string
type DocumentAnalysis ¶
type DocumentAnalysis struct {
Path string `json:"path"`
Package string `json:"package,omitempty"`
Component string `json:"component,omitempty"`
TypeParams string `json:"type_params,omitempty"`
Params string `json:"params,omitempty"`
Signature string `json:"signature,omitempty"`
ComponentOffset int `json:"component_offset,omitempty"`
ComponentLine int `json:"component_line,omitempty"`
ComponentColumn int `json:"component_column,omitempty"`
Imports []AnalysisImport `json:"imports,omitempty"`
Regions []AnalysisRegion `json:"regions,omitempty"`
Diagnostics []Diagnostic `json:"diagnostics,omitempty"`
}
DocumentAnalysis is the compiler-owned semantic description consumed by read-only tools such as the language server.
func AnalyzeSources ¶
func AnalyzeSources(ctx context.Context, inputs []SourceInput) []DocumentAnalysis
AnalyzeSources applies the normal parser, HTML-context analyzer, trust audit, backend validation, duplicate-component checks, and statically knowable cycle checks to an in-memory source set. It performs no I/O.
type FileResult ¶
type FileResult struct {
SourcePath string `json:"source_path"`
OutputPath string `json:"output_path"`
Changed bool `json:"changed"`
Stale bool `json:"stale"`
Missing bool `json:"missing"`
}
FileResult describes one source/output pair processed by Generate or Check.
type Result ¶
type Result struct {
Files []FileResult `json:"files"`
Diagnostics []Diagnostic `json:"diagnostics,omitempty"`
Discovered int `json:"discovered"`
Changed int `json:"changed"`
Unchanged int `json:"unchanged"`
Stale int `json:"stale"`
Missing int `json:"missing"`
}
Result is returned even when an operation reports diagnostics.
type SourceInput ¶
SourceInput supplies one in-memory .sando document for editor analysis.