model

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: Apache-2.0 Imports: 33 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 model owns the workspace: the set of documents, the global symbol index, and the reindex pipeline that keeps them consistent.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoView = errors.New("declares no view")

ErrNoView is a document that declares no view, which is rendered through a pseudo-view instead.

Functions

func DeclaredDocumentDefinitions

func DeclaredDocumentDefinitions(index *symbols.Index, sem *semantics.Model, scope *symbols.Scope) []*symbols.Symbol

DeclaredDocumentDefinitions returns the document definitions declared in scope and its nested scopes, outermost first and in declaration order.

func DeclaredViews

func DeclaredViews(scope *symbols.Scope) []*symbols.Symbol

DeclaredViews returns the views declared in scope and its nested scopes, outermost first and in declaration order.

func IsModelSource

func IsModelSource(path string) bool

IsModelSource reports whether path is a SysML/KerML source file.

func NewIndexWithStdlib

func NewIndexWithStdlib() (*symbols.Index, libs.Source)

NewIndexWithStdlib returns an index carrying the standard library for a consumer that resolves library names outside a workspace — the REPL's runtime, which has to resolve the measurement unit a quantity expression names. It shares the one library index every model reads, and hands out the source holding the bytes that index was built from.

func SiblingDocumentPlans

func SiblingDocumentPlans(index *symbols.Index, sem *semantics.Model, resolver *resolve.Resolver, entry *symbols.Symbol) []*docplan.Plan

SiblingDocumentPlans compiles the document definitions the workspace documents declare other than entry, skipping any whose plan does not compile, so a single-document render can emit the anchors incoming cross-document references expect.

func TopLevelDeclarations

func TopLevelDeclarations(root *symbols.Scope) []*symbols.Symbol

TopLevelDeclarations returns root declarations, expanding packages one level.

Types

type Debouncer

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

Debouncer coalesces bursts of triggers per key into a single delayed call.

func NewDebouncer

func NewDebouncer(window time.Duration) *Debouncer

NewDebouncer returns a debouncer with the given coalescing window.

func (*Debouncer) Trigger

func (d *Debouncer) Trigger(key string, fn func())

Trigger (re)starts key's timer; fn runs once when the window elapses with no further trigger for that key. A trigger within the window resets the timer.

type Dependency

type Dependency struct {
	Doc  string
	FQN  string
	Text string
}

Dependency is a declaration a behavior's run reads, in a document the workspace holds: named by document and qualified name, with its text.

func (Dependency) Name

func (dep Dependency) Name() string

Name is what a message calls the dependency: its qualified name, or its document when it is one.

type Document

type Document struct {
	Name             string
	Content          []byte
	Version          int
	AST              *ast.RootNamespace
	ParseDiagnostics []parser.Diagnostic
	ParseWarnings    []parser.Diagnostic
	Scope            *symbols.Scope
	// contains filtered or unexported fields
}

Document is the parsed state of one source file. It is immutable once built: it is parsed from bytes the workspace owns, newDocument sets every field and nothing writes one afterwards, so a document the workspace hands out is a snapshot that neither a later update nor whoever supplied the bytes can touch.

func (*Document) Digest

func (d *Document) Digest() string

Digest fingerprints the document's text: equal for equal content, so a position read from one snapshot can be checked against a later one.

func (*Document) Lines

func (d *Document) Lines() *source.LineIndex

Lines returns the document's line index, built once and cached.

type DocumentDefinition

type DocumentDefinition struct {
	FQN string
	Doc string
}

DocumentDefinition is one native document definition the workspace holds: a part def specializing DocumentQueries::Document, and the file declaring it.

type DocumentEdit

type DocumentEdit struct {
	Name     string
	Original []byte
	Content  []byte
	Applied  []edit.Applied
	Version  int
	Open     bool
}

DocumentEdit is one document's rewrite: the content it was computed from, what it becomes, and what each operation changed in it. Version is the one the workspace held the content at; Open reports whether that is a client buffer's version, or 0 for content read from disk.

type EditResult

type EditResult struct {
	Documents []DocumentEdit
}

EditResult is what ApplyEdit computed: the edited document first, then every other document the edit rewrote or read a target's declaration in, in name order. A document read and left as it was has its content as its rewrite.

type Option

type Option func(*Workspace)

Option configures a workspace at construction.

func WithConformanceMode

func WithConformanceMode(mode diag.ConformanceMode) Option

WithConformanceMode analyzes this workspace's documents at mode.

func WithLibrarySource

func WithLibrarySource(src libs.Source) Option

WithLibrarySource names the source the index's library documents were read from, so LibraryDocument can serve their text. It must serve the bytes the index was built from, or the index's spans address the wrong text.

type QueryTypeCandidate

type QueryTypeCandidate struct {
	Name string
	Sym  *symbols.Symbol
}

QueryTypeCandidate pairs a visible spelling with the element it reaches, so an alias completes under the name it is reachable by, not its target's.

type Reading

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

Reading answers questions of the workspace's documents as they all stand at one moment: it lives for one call of Workspace.Read, under the lock.

func (*Reading) DeclarationText

func (r *Reading) DeclarationText(sym *symbols.Symbol) string

DeclarationText is the source text of sym's declaration, "" when its document is gone.

func (*Reading) Declared

func (r *Reading) Declared(doc, fqn string) *symbols.Symbol

Declared is the element fqn names in doc: by qualified name in the index, else by qualified or simple name among the document's own declarations.

func (*Reading) DeclaredView

func (r *Reading) DeclaredView(doc, fqn string) *symbols.Symbol

DeclaredView is the view RenderView renders for fqn in doc: the view named, the document's one view for "", nil for a pseudo-view or a name declaring none.

func (*Reading) Dependencies

func (r *Reading) Dependencies(roots ...*symbols.Symbol) []Dependency

Dependencies is Runtime.Dependencies over the documents as read.

func (*Reading) Document

func (r *Reading) Document(name string) *Document

Document is the held document name, nil for one the workspace does not hold.

func (*Reading) Generation

func (r *Reading) Generation() uint64

Generation is the workspace's generation as read.

func (*Reading) NewRuntime

func (r *Reading) NewRuntime() (*Runtime, error)

NewRuntime is Workspace.NewRuntime over the documents as read.

func (*Reading) RenderView

func (r *Reading) RenderView(doc, fqn string) (*view.Rendering, *Snapshot, error)

RenderView is Workspace.RenderView of the documents as read.

func (*Reading) TextAt

func (r *Reading) TextAt(doc string, span source.Span) string

TextAt is the source text at span in doc, from the document or the library file behind the documents; "" when neither holds doc.

type ReferenceLocation

type ReferenceLocation struct {
	Doc     string
	Content []byte
	Span    source.Span
}

ReferenceLocation is one written name segment in a workspace document, with the document text its span addresses (the bytes the index was built from).

type Runtime

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

Runtime is a runtime model over the workspace's documents as they stood when it was built, on an index of its own that later edits do not touch.

func (*Runtime) DeclarationOf

func (r *Runtime) DeclarationOf(sym *symbols.Symbol) (Dependency, bool)

DeclarationOf is the dependency sym is listed as: the nearest declaration its document names around it; false when the workspace does not hold its document or names nothing around it.

func (*Runtime) Declared

func (r *Runtime) Declared(doc, fqn string) *symbols.Symbol

Declared is the element fqn names in doc as the runtime's own index has it, by qualified name or among the document's declarations; build executors from it.

func (*Runtime) Dependencies

func (r *Runtime) Dependencies(roots ...*symbols.Symbol) []Dependency

Dependencies lists the declarations a run from roots reads: the roots, what their text names, what that names in turn — in the runtime's documents alone, as no edit reaches a library — sorted by document then name, each listed as the nearest declaration its document names (see dependencyWalk.declaration).

func (*Runtime) FQN

func (r *Runtime) FQN(sym *symbols.Symbol) string

FQN spells sym's fully qualified name as the runtime's index holds it.

func (*Runtime) Generation

func (r *Runtime) Generation() uint64

Generation is the workspace's generation the runtime was built from; the workspace still holds the same documents while Workspace.Generation equals it.

func (*Runtime) Model

func (r *Runtime) Model() *runtime.Model

Model is the runtime model executions are built over with runtime.NewContext.

func (*Runtime) Named

func (r *Runtime) Named(doc, fqn string) (*symbols.Symbol, error)

Named is the element fqn names from doc: doc's own, else the one another held document declares by qualified name; an error names the documents when several do.

func (*Runtime) Referenced

func (r *Runtime) Referenced(scope *symbols.Scope, expr ast.Node) []*symbols.Symbol

Referenced is the symbols expr's names reach when resolved in scope, as the runtime's index has them.

func (*Runtime) Version

func (r *Runtime) Version(doc string) (int, bool)

Version is the version of the named document the runtime was built from, and false for a document it does not hold.

type Snapshot

type Snapshot struct {
	// Rendered is the document the rendering was asked of.
	Rendered *Document
	// contains filtered or unexported fields
}

Snapshot is the workspace's documents as one read of them, the read a rendering was made under, so that a span the rendering locates in any of them is a span of the text held here, whatever the workspace holds since.

func (*Snapshot) Document

func (s *Snapshot) Document(name string) *Document

Document is the named document as the snapshot holds it; nil for a name the workspace held no document of, a bundled library file's included.

type StaleError

type StaleError struct {
	Name string
}

StaleError reports that a document an operation was computed against has been replaced since, so a position in it may name something else now.

func (*StaleError) Error

func (e *StaleError) Error() string

type ViewInfo

type ViewInfo struct {
	Name      string
	Kind      view.Kind
	Supported bool
	Reason    string
	Origin    view.Origin
}

ViewInfo is one view a document declares: its qualified name, the rendering kind it states, whether this implementation produces that kind, and why not when it does not. Origin is where the view is declared, so a client can tell which view a cursor is in; the zero Origin for a view without a declaration.

type VisibleName

type VisibleName struct {
	// Name is the path in the pilot's notation, segments joined by ".".
	Name string
	// FQN is the "::"-qualified name of the element the path reaches.
	FQN string
	// Kind classifies the element, an alias resolved to its target: a caller
	// restricting the set by metatype — a specialization names a type, a
	// redefinition names a feature — needs what the name reaches, not the name.
	Kind symbols.SymbolKind
	// Depth is the number of segments in Name.
	Depth int
}

VisibleName is one spelling resolution would consider at a point: the dotted path a reference there may be written as, and the element it reaches.

type VisibleNamesOptions

type VisibleNamesOptions struct {
	// Redefinition enumerates only what the anchor's owner inherits: a
	// redefinition's target is resolved against the generals of the owning type
	// rather than against its own members (KerML 8.3.3.3.6).
	Redefinition bool
	// LibraryRoots names the standard-library root packages the caller counts
	// as loaded: `Base` alone admits the implicit `self` and `that` it
	// contributes to a declaration. A library element is reachable through
	// inheritance and imports only when its root is named here, and a library
	// root package is never offered as a top-level name of its own.
	LibraryRoots []string
	// MaxDepth bounds the number of segments in an enumerated path.
	MaxDepth int
}

VisibleNamesOptions bounds a visible-name enumeration.

type Workspace

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

Workspace is the single source of truth for a server/REPL session: the document set plus the global symbol index. Mutations are serialized under a write lock; reads take a read lock.

func NewWorkspace

func NewWorkspace(opts ...Option) *Workspace

NewWorkspace returns a workspace with stdlib pre-loaded into the global index. Stdlib files are loaded from embedded sources (or OPENSYSML_LIBRARY_PATH if set). Without options it analyzes in the default conformance mode.

func NewWorkspaceWithIndex

func NewWorkspaceWithIndex(idx *symbols.Index, opts ...Option) *Workspace

NewWorkspaceWithIndex returns a workspace over a caller-built index, for a consumer whose resource set is not the bundled standard library. The options travel with the resource set, so any index is analyzed under the asked mode. The library files the index holds are the workspace's library, whatever their tier: a workspace document may stand in for one or take its name.

func (*Workspace) AmbiguousInvocationInDoc

func (w *Workspace) AmbiguousInvocationInDoc(name string, ref resolve.Reference) []*symbols.Symbol

AmbiguousInvocationInDoc returns the equally specific overloads an invocation's arguments leave tied, when ref is the name it calls; nil for any other reference and for a call that selects one declaration.

func (*Workspace) AnalyzedContent

func (w *Workspace) AnalyzedContent(name string) ([]byte, []diag.Diagnostic, bool)

AnalyzedContent returns a document's diagnostics together with the content they were computed against, so an edit cannot split the two. Reports whether the document exists.

func (*Workspace) ApplyEdit

func (w *Workspace) ApplyEdit(name string, ops []edit.Operation, read []*Document) (result *EditResult, version int, ok bool, err error)

ApplyEdit rewrites the named document's current content by ops and returns the result without changing the workspace: the client owns the buffers, so it applies the text and the changes arrive back through the usual document notifications. A rename or a cascading delete also rewrites every other document of the workspace that refers to the target, open or read from disk; every document is read under the one lock, so the edit is computed from a single coherent state and each rewrite reports the version it was read at. Read are the workspace documents, as handed out earlier, that the operations' positions were computed from; when the workspace no longer holds one of those snapshots, the edit is refused with a *StaleError, and otherwise each is among the result's documents, rewritten or not, at the version it was read at, so that the client can pin the edit to it. The returned version is the named document's. An unknown document reports ok false; a refused edit is an *edit.Error and rewrites nothing.

func (*Workspace) Close

func (w *Workspace) Close(name string)

Close drops the open buffer for name; the document reverts to on-disk content if any, otherwise it is removed.

func (*Workspace) ConformanceMode

func (w *Workspace) ConformanceMode() diag.ConformanceMode

ConformanceMode reports the strictness this workspace judges notation at.

func (*Workspace) DeleteOnDisk

func (w *Workspace) DeleteOnDisk(name string)

DeleteOnDisk forgets the on-disk bytes recorded for name. An open document keeps its authoritative buffer; a closed one leaves the document set.

func (*Workspace) Diagnostics

func (w *Workspace) Diagnostics(name string) []diag.Diagnostic

Diagnostics returns the analysis diagnostics for name, computing them lazily (and caching) on first request after a change. Returns nil for unknown docs.

func (*Workspace) Document

func (w *Workspace) Document(name string) *Document

Document returns the current parsed document for name, or nil. The document is a snapshot: an update installs a new one, so it stays consistent after the lock.

func (*Workspace) DocumentDefinitions

func (w *Workspace) DocumentDefinitions() []DocumentDefinition

DocumentDefinitions lists the document definitions declared across the workspace's own documents, in qualified-name order.

func (*Workspace) DocumentNames

func (w *Workspace) DocumentNames() []string

DocumentNames returns a snapshot of the names of all known documents.

func (*Workspace) ElementOnPath

func (w *Workspace) ElementOnPath(scope *symbols.Scope, path []string) (*symbols.Symbol, bool)

ElementOnPath resolves a dotted path from a scope to the element it names: the first segment as an unqualified name, each later one as a member of the previous, an alias replaced by its target.

func (*Workspace) EnclosingMetadataBody

func (w *Workspace) EnclosingMetadataBody(scope *symbols.Scope) *symbols.Scope

EnclosingMetadataBody returns the nearest scope, from scope outward, whose declarations redefine the features of a metadata type; nil outside one.

func (*Workspace) FQNOf

func (w *Workspace) FQNOf(sym *symbols.Symbol) string

FQNOf is the qualified name the index registers an element under, which is how a caller comparing enumerations tells two paths to one element apart.

func (*Workspace) Generation

func (w *Workspace) Generation() uint64

Generation counts the changes made to the workspace's documents so far; two readings with the same generation read the same documents.

func (*Workspace) HighlightTokens

func (w *Workspace) HighlightTokens(name string) ([]byte, []highlight.Token)

HighlightTokens returns the semantic tokens of a document, ordered by source position, with the content they index; the workspace or bundled library document is chosen under one lock, so neither an edit nor a close can split or lose them. Nil for unknown documents.

func (*Workspace) IdentityOf

func (w *Workspace) IdentityOf(name string, sym *symbols.Symbol) (*identity.Info, bool)

IdentityOf returns the identity side-table entry of a declaration of the named document, a bundled library file included; ok is false when it has no qualified name or is not indexed there.

func (*Workspace) IsDocumentDefinition

func (w *Workspace) IsDocumentDefinition(sym *symbols.Symbol) bool

IsDocumentDefinition reports whether sym is a native document definition: a part def specializing DocumentQueries::Document.

func (*Workspace) IsLibraryDocument

func (w *Workspace) IsLibraryDocument(name string) bool

IsLibraryDocument reports whether name is a bundled library file, as opposed to a document of the workspace's own — a version of a library file included, whatever its mark in the index.

func (*Workspace) IsLibraryRoot

func (w *Workspace) IsLibraryRoot(name string) bool

IsLibraryRoot reports whether name is a top-level package of the workspace's library.

func (*Workspace) IsOpen

func (w *Workspace) IsOpen(name string) bool

IsOpen reports whether name has an authoritative open buffer.

func (*Workspace) LibraryDocument

func (w *Workspace) LibraryDocument(name string) *Document

LibraryDocument returns the parsed text of the named bundled library file, read from the source the index was built from, so its spans are the ones the index's symbols carry. It is nil for a name that is no library document and when the workspace has no library source. Library documents are read-only: they are never added to the index, which holds them already.

func (*Workspace) LookupQualified

func (w *Workspace) LookupQualified(fqn string) []*symbols.Symbol

LookupQualified resolves a fully-qualified name against the global index under the read lock and returns a copy of the matching symbols, so callers never touch the shared index concurrently with a reindex. This is the safe read path for consumers (LSP/REPL); the raw index is intentionally not exposed.

func (*Workspace) MembersOnPath

func (w *Workspace) MembersOnPath(scope *symbols.Scope, path []string) []*symbols.Symbol

MembersOnPath returns the members visible on the element that path names from scope — the members of a usage's type included, since typing is a generalization edge — so that completion after `v.` offers what `v` has. Segments after the first are looked up as members of the previous one; an unresolved segment yields no members.

func (*Workspace) MetadataBodyMembers

func (w *Workspace) MetadataBodyMembers(scope *symbols.Scope) []*symbols.Symbol

MetadataBodyMembers returns the members of the metadata definition an annotation body's declarations redefine, as seen from the body scope, or nil when scope is not a metadata annotation body or its metaclass does not resolve.

func (*Workspace) MetadataBodyRedefines

func (w *Workspace) MetadataBodyRedefines(sym *symbols.Symbol) (*symbols.Symbol, string, bool)

MetadataBodyRedefines returns the metadata-definition feature a metadata annotation body declaration implicitly redefines (KerML 7.4.7), with the feature's qualified name. ok is false when sym is not such a declaration or the annotation's metaclass does not resolve.

func (*Workspace) NameReferencesTo

func (w *Workspace) NameReferencesTo(target *symbols.Symbol, name string) []ReferenceLocation

NameReferencesTo returns every segment in the workspace's documents that writes name as target's own name — what renaming that name edits. A segment spelling target's other name (short for long, or the reverse) still resolves after the rename and is left alone; an alias use is edited via the alias.

func (*Workspace) NewRuntime

func (w *Workspace) NewRuntime() (*Runtime, error)

NewRuntime builds a runtime over the workspace's current documents, on a fresh overlay of the library index (a bare index when the workspace has no base).

func (*Workspace) Open

func (w *Workspace) Open(name string, content []byte, version int)

Open registers an authoritative open buffer for name and reindexes.

func (*Workspace) OpenNames

func (w *Workspace) OpenNames() []string

OpenNames returns a snapshot of the names with an open buffer.

func (*Workspace) QueryBindingParameter

func (w *Workspace) QueryBindingParameter(sym *symbols.Symbol) (*symbols.Symbol, bool)

QueryBindingParameter resolves the parameter a document query binding names: for an `in` member of a calc usage typed by a query definition, the matching parameter declaration on that definition.

func (*Workspace) QueryDefinitions

func (w *Workspace) QueryDefinitions(syms []*symbols.Symbol) []*symbols.Symbol

QueryDefinitions filters syms to the query definitions among them: the calc defs specializing DocumentQueries::Query.

func (*Workspace) QueryTypeCandidates

func (w *Workspace) QueryTypeCandidates(scope *symbols.Scope) []QueryTypeCandidate

QueryTypeCandidates lists what a calc usage's type position may name: the query definitions reachable by a single name from scope — imports, aliases and inheritance included — and the namespaces a qualified name may start with.

func (*Workspace) QueryUsageParameters

func (w *Workspace) QueryUsageParameters(usage *symbols.Symbol) ([]*symbols.Symbol, bool)

QueryUsageParameters lists the `in` parameters of the query definition a calc usage is typed by; false when the usage is not typed by one.

func (*Workspace) Read

func (w *Workspace) Read(fn func(r *Reading) error) error

Read calls fn with a Reading under the write lock (its answers query the shared resolver), so all are of the same documents. fn must not call the workspace itself.

func (*Workspace) ReferencesTo

func (w *Workspace) ReferencesTo(target *symbols.Symbol) []ReferenceLocation

ReferencesTo returns every segment in the workspace's documents that reaches target or writes its name (an alias use counts for both), in document then position order.

func (*Workspace) Remove

func (w *Workspace) Remove(name string)

Remove deletes the document entirely (open buffer, on-disk cache, and index).

func (*Workspace) RenameConflict

func (w *Workspace) RenameConflict(target *symbols.Symbol, name, newName string) *edit.RenameConflict

RenameConflict reports why renaming target's name (long or short, as written) to newName is refused: the name already taken where target is declared, or a reference in any workspace document that would read another element afterwards.

func (*Workspace) RenderDocumentMarkdown

func (w *Workspace) RenderDocumentMarkdown(fqn string, opts docrender.MarkdownOptions) (string, error)

RenderDocumentMarkdown compiles the named document definition, evaluates its queries against the workspace model, and renders the result as Markdown.

func (*Workspace) RenderView

func (w *Workspace) RenderView(doc, fqn string) (*view.Rendering, *Snapshot, error)

RenderView renders a view of a document. fqn names a declared view or a pseudo-view (`#<kind>[:<fqn>]`); "" renders the document's own view. The snapshot returned holds the documents the rendering was made from, read under the same lock, so their versions, content and scopes are the rendering's.

func (*Workspace) ResolveQualifiedInDoc

func (w *Workspace) ResolveQualifiedInDoc(name string, scope *symbols.Scope, qn *ast.QualifiedName) (*symbols.Symbol, bool)

ResolveQualifiedInDoc resolves a qualified name against the given scope using the workspace's symbol index. Used by the LSP layer for go-to-definition.

func (*Workspace) ResolveQualifiedSegmentsInDoc

func (w *Workspace) ResolveQualifiedSegmentsInDoc(name string, scope *symbols.Scope, qn *ast.QualifiedName) []*symbols.Symbol

ResolveQualifiedSegmentsInDoc resolves a qualified name and returns the symbol each of its segments denotes, so `A::B::C` yields the symbols for A, B and C. Entries are nil where a segment did not resolve. Used by rename, which must edit a name wherever it appears, qualifier positions included.

func (*Workspace) ResolveReferenceInDoc

func (w *Workspace) ResolveReferenceInDoc(name string, ref resolve.Reference) (*symbols.Symbol, bool)

ResolveReferenceInDoc resolves one name occurrence, which may be the target of a reference subsetting or a feature chain's member segment (see resolve.Reference).

func (*Workspace) ResolveReferenceNameSegmentsInDoc

func (w *Workspace) ResolveReferenceNameSegmentsInDoc(name string, ref resolve.Reference) []*symbols.Symbol

ResolveReferenceNameSegmentsInDoc is ResolveReferenceSegmentsInDoc reporting what each segment's name *is* rather than the element it reaches, so a segment written as an alias name is the alias. Rename edits names, not elements.

func (*Workspace) ResolveReferenceSegmentsInDoc

func (w *Workspace) ResolveReferenceSegmentsInDoc(name string, ref resolve.Reference) []*symbols.Symbol

ResolveReferenceSegmentsInDoc is ResolveQualifiedSegmentsInDoc for one name occurrence (see ResolveReferenceInDoc).

func (*Workspace) ScopeAt

func (w *Workspace) ScopeAt(doc string, offset int) *symbols.Scope

ScopeAt is the deepest scope of a document whose declaration contains offset, which is the namespace a name written there is resolved in.

func (*Workspace) SetConformanceMode

func (w *Workspace) SetConformanceMode(mode diag.ConformanceMode)

SetConformanceMode switches the mode for a live session — an LSP client changing its setting, a REPL user asking the strict question — and drops the cached diagnostics, which answered the other question.

func (*Workspace) SetOnDisk

func (w *Workspace) SetOnDisk(name string, content []byte)

SetOnDisk records a copy of the bytes a file holds on disk. If the document is not open, it becomes the active content and the document is reindexed.

func (*Workspace) StandsInFor

func (w *Workspace) StandsInFor(name string) string

StandsInFor is the bundled library document name is a version of and stands in for in the index, "" for the workspace's own file.

func (*Workspace) TopLevelSymbols

func (w *Workspace) TopLevelSymbols(doc string) []*symbols.Symbol

TopLevelSymbols returns the symbols declared at the root of the index as seen from the document named doc: the standard library's top-level packages and every document's top-level declarations. This is the read path for completion, which offers library names that no open document declares.

func (*Workspace) Update

func (w *Workspace) Update(name string, content []byte, version int)

Update replaces the open buffer content for name and reindexes.

func (*Workspace) Views

func (w *Workspace) Views(doc string) ([]ViewInfo, *Document)

Views lists the views a document declares, in qualified-name order, each with the rendering kind it states. A recognized kind this build does not produce is listed as unsupported with the reason. The document returned is the snapshot the listing was read from, so the origins are located in its text; nil when the workspace does not hold the document.

func (*Workspace) VisibleNames

func (w *Workspace) VisibleNames(scope *symbols.Scope, opts VisibleNamesOptions) []VisibleName

VisibleNames enumerates every name resolution would consider in scope: the members of the enclosing namespace chain, what those namespaces inherit and import, and the document roots the index holds, each under every path it can be reached by. It is the read-only enumeration behind the single-name lookup resolve performs, and it answers both halves of a visibility question — a name that should be reachable and is not, and one that is reachable and should not be. Results are sorted by name, so two runs agree byte for byte.

func (*Workspace) VisibleNamesAt

func (w *Workspace) VisibleNamesAt(doc string, offset int, opts VisibleNamesOptions) []VisibleName

VisibleNamesAt is VisibleNames for the deepest scope of a document that contains offset.

Jump to

Keyboard shortcuts

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