compilerservice

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package compilerservice owns reusable, editor-independent project snapshots. CLI, LSP, and future agent adapters can share overlays, diagnostics, checked artifacts, and language-service contexts without rebuilding compiler phases.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service maintains immutable snapshots over project inputs and unsaved document overlays. Any input change invalidates the current analysis.

func New

func New(units []compiler.SourceUnit, options compiler.Options) *Service

func (*Service) Analyze

func (s *Service) Analyze() Snapshot

Analyze returns the current immutable project snapshot. Project analysis happens outside the service lock. If inputs change concurrently, the obsolete result is discarded and analysis restarts from the newer generation.

func (*Service) AnalyzeOnce added in v0.2.30

func (s *Service) AnalyzeOnce() (result Snapshot, current bool)

AnalyzeOnce analyzes one captured input generation. Analysis happens outside the service lock. If an input changes before it finishes, the obsolete result is not committed and current is false.

func (*Service) CloseDocument

func (s *Service) CloseDocument(filename string)

CloseDocument removes an unsaved overlay and restores the on-disk project unit, if one exists.

func (*Service) Generation added in v0.2.30

func (s *Service) Generation() uint64

Generation returns the current input generation. It advances whenever a workspace input or editor overlay changes.

func (*Service) RemoveWorkspaceDocument added in v0.2.6

func (s *Service) RemoveWorkspaceDocument(filename string)

RemoveWorkspaceDocument removes an on-disk project input while preserving an open editor overlay until the editor closes it.

func (*Service) ReplaceWorkspaceDocuments added in v0.2.29

func (s *Service) ReplaceWorkspaceDocuments(units []compiler.SourceUnit)

ReplaceWorkspaceDocuments atomically replaces the on-disk workspace input. Open document overlays are preserved and continue to take precedence over the replacement units.

func (*Service) SetDocument

func (s *Service) SetDocument(unit compiler.SourceUnit)

SetDocument installs an unsaved source unit. Existing project files and new files use the same operation; adapters are responsible for deriving the module and package names of a newly created file.

func (*Service) SetWorkspaceDocument added in v0.2.6

func (s *Service) SetWorkspaceDocument(unit compiler.SourceUnit)

SetWorkspaceDocument updates the on-disk project input beneath any open editor overlay. Closing an overlay therefore restores the latest saved file.

type Snapshot

type Snapshot struct {
	Version     uint64
	Diagnostics []diagnostic.Diagnostic
	Artifacts   []*compiler.Artifact
	Stale       bool
	// contains filtered or unexported fields
}

func (Snapshot) Context

func (s Snapshot) Context(modulePath string) (languageservice.Context, bool)

func (Snapshot) HasErrors

func (s Snapshot) HasErrors() bool

func (Snapshot) ImportCandidates added in v0.2.30

func (s Snapshot) ImportCandidates(modulePath string) languageservice.Context

ImportCandidates returns project declarations with one unambiguous import origin, excluding declarations owned by modulePath.

func (Snapshot) Source added in v0.2.30

func (s Snapshot) Source(path string) ([]byte, bool)

Source returns the exact source input analyzed for path. The returned bytes are a copy, so callers cannot mutate the snapshot or a later cached result.

Jump to

Keyboard shortcuts

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