workspace

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 13 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

Index

Constants

View Source
const ReloadDelay = 75 * time.Millisecond

ReloadDelay is the debounce period used before recomputing overlay-backed roots.

Variables

This section is empty.

Functions

func DetectConfigPath

func DetectConfigPath(root string) (string, bool, error)

DetectConfigPath resolves the mergeway config entry file for a root, checking both mergeway.yaml and mergeway.yml.

Types

type Index

type Index struct {
	ByType map[string]map[string][]*data.Object
}

Index maps entity types and identifiers to the loaded objects that match them.

type OpenDocument

type OpenDocument struct {
	URI        string
	Path       string
	LanguageID string
	Version    int32
	Text       string
}

OpenDocument is the in-memory representation of an open buffer.

type RootIndex

type RootIndex struct {
	Root        string
	ConfigPath  string
	ConfigFiles map[string]struct{}
	DataFiles   map[string][]string
	Workspace   *Workspace
}

RootIndex captures one detected mergeway root and its isolated file/index state.

func (*RootIndex) OwnsPath

func (r *RootIndex) OwnsPath(path string) bool

OwnsPath reports whether the file belongs to this root as either a config file or a configured data include target.

func (*RootIndex) TypesForFile

func (r *RootIndex) TypesForFile(path string) []string

TypesForFile reports the configured types that include the given file.

type RootRuntime

type RootRuntime struct {
	Index      *RootIndex
	Workspace  *Workspace
	LoadErr    error
	Validation *ValidationReport
}

RootRuntime tracks the current overlay-backed view of one detected root.

type RootSet

type RootSet struct {
	Roots        []*RootIndex
	MissingRoots []string
}

RootSet captures all roots detected during one initialization pass.

func OpenRoots

func OpenRoots(candidates []string) (*RootSet, error)

OpenRoots detects mergeway roots under the provided directories and loads one isolated workspace index per discovered root.

type Runtime

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

Runtime manages open documents and overlay-backed root reloads.

func NewRuntime

func NewRuntime(set *RootSet) *Runtime

NewRuntime constructs a runtime around a detected root set.

func (*Runtime) DidChange

func (r *Runtime) DidChange(path string, version int32, text string) error

DidChange replaces the full document text and schedules a debounced recompute.

func (*Runtime) DidClose

func (r *Runtime) DidClose(path string)

DidClose removes the in-memory buffer and schedules a debounced recompute.

func (*Runtime) DidOpen

func (r *Runtime) DidOpen(doc *OpenDocument) error

DidOpen stores full-document content and schedules a debounced recompute.

func (*Runtime) Document

func (r *Runtime) Document(path string) *OpenDocument

Document returns the currently open in-memory buffer, if any.

func (*Runtime) FlushReload

func (r *Runtime) FlushReload() error

FlushReload forces any pending debounced recompute to run immediately.

func (*Runtime) RootByPath

func (r *Runtime) RootByPath(path string) *RootRuntime

RootByPath returns the current root runtime for the given file.

func (*Runtime) SetReloadHook

func (r *Runtime) SetReloadHook(hook func())

SetReloadHook registers a callback that runs after each successful reload.

func (*Runtime) Snapshot

func (r *Runtime) Snapshot() *Snapshot

Snapshot returns a stable copy of the current runtime state.

type Snapshot

type Snapshot struct {
	Roots     map[string]*RootRuntime
	Documents map[string]*OpenDocument
}

Snapshot captures a read-only copy of the runtime state used by callers that need a consistent view across roots and open documents.

type ValidationReport

type ValidationReport struct {
	Root               string
	ConfigPath         string
	Config             *config.Config
	Result             *validation.Result
	Workspace          *Workspace
	WorkspaceLoadError error
}

ValidationReport combines semantic validation output with the best-effort loaded workspace/index for callers that need both in one step.

func Validate

func Validate(root, configPath string, opts validation.Options) (*ValidationReport, error)

Validate loads config, runs the existing semantic validator, and attaches a best-effort loaded workspace/index for valid callers that need both outputs.

func ValidateWithConfig

func ValidateWithConfig(root, configPath string, cfg *config.Config, opts validation.Options) (*ValidationReport, error)

ValidateWithConfig runs the existing semantic validator with a caller-provided config and attaches a best-effort loaded workspace/index.

func ValidateWithConfigAndOps

func ValidateWithConfigAndOps(root, configPath string, cfg *config.Config, opts validation.Options, ops fileutil.Ops) (*ValidationReport, error)

ValidateWithConfigAndOps runs semantic validation with caller-provided config and file operations.

func ValidateWithOps

func ValidateWithOps(root, configPath string, opts validation.Options, ops fileutil.Ops) (*ValidationReport, error)

ValidateWithOps loads config and validates using the provided file operations.

type Workspace

type Workspace struct {
	Root          string
	ConfigPath    string
	Config        *config.Config
	ObjectsByType map[string][]*data.Object
	Index         *Index
}

Workspace captures a loaded mergeway workspace and a reusable entity index.

func Load

func Load(root, configPath string) (*Workspace, error)

Load reads the workspace config, loads all configured entities, and builds a per-type/per-identifier index without invoking CLI code.

func LoadWithConfig

func LoadWithConfig(root, configPath string, cfg *config.Config) (*Workspace, error)

LoadWithConfig loads all configured entities and builds an entity index using a caller-provided config.

func LoadWithConfigAndOps

func LoadWithConfigAndOps(root, configPath string, cfg *config.Config, ops fileutil.Ops) (*Workspace, error)

LoadWithConfigAndOps loads all configured entities and builds an entity index using a caller-provided config and file operations.

func LoadWithOps

func LoadWithOps(root, configPath string, ops fileutil.Ops) (*Workspace, error)

LoadWithOps reads the workspace config and builds an index using the provided file operations.

func (*Workspace) Find

func (w *Workspace) Find(typeName, id string) []*data.Object

Find returns all indexed objects that match the given type and identifier.

func (*Workspace) Objects

func (w *Workspace) Objects(typeName string) []*data.Object

Objects returns the loaded objects for a type.

Jump to

Keyboard shortcuts

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