Documentation
¶
Overview ¶
Package model owns the workspace: the set of documents, the global symbol index, and the reindex pipeline that keeps them consistent.
Index ¶
- Variables
- func DeclaredDocumentDefinitions(index *symbols.Index, sem *semantics.Model, scope *symbols.Scope) []*symbols.Symbol
- func DeclaredViews(scope *symbols.Scope) []*symbols.Symbol
- func IsModelSource(path string) bool
- func NewIndexWithStdlib() (*symbols.Index, libs.Source)
- func SiblingDocumentPlans(index *symbols.Index, sem *semantics.Model, resolver *resolve.Resolver, ...) []*docplan.Plan
- func TopLevelDeclarations(root *symbols.Scope) []*symbols.Symbol
- type Debouncer
- type Dependency
- type Document
- type DocumentDefinition
- type DocumentEdit
- type EditResult
- type Option
- type QueryTypeCandidate
- type Reading
- func (r *Reading) DeclarationText(sym *symbols.Symbol) string
- func (r *Reading) Declared(doc, fqn string) *symbols.Symbol
- func (r *Reading) DeclaredView(doc, fqn string) *symbols.Symbol
- func (r *Reading) Dependencies(roots ...*symbols.Symbol) []Dependency
- func (r *Reading) Document(name string) *Document
- func (r *Reading) Generation() uint64
- func (r *Reading) NewRuntime() (*Runtime, error)
- func (r *Reading) RenderView(doc, fqn string) (*view.Rendering, *Snapshot, error)
- func (r *Reading) TextAt(doc string, span source.Span) string
- type ReferenceLocation
- type Runtime
- func (r *Runtime) DeclarationOf(sym *symbols.Symbol) (Dependency, bool)
- func (r *Runtime) Declared(doc, fqn string) *symbols.Symbol
- func (r *Runtime) Dependencies(roots ...*symbols.Symbol) []Dependency
- func (r *Runtime) FQN(sym *symbols.Symbol) string
- func (r *Runtime) Generation() uint64
- func (r *Runtime) Model() *runtime.Model
- func (r *Runtime) Named(doc, fqn string) (*symbols.Symbol, error)
- func (r *Runtime) Referenced(scope *symbols.Scope, expr ast.Node) []*symbols.Symbol
- func (r *Runtime) Version(doc string) (int, bool)
- type Snapshot
- type StaleError
- type ViewInfo
- type VisibleName
- type VisibleNamesOptions
- type Workspace
- func (w *Workspace) AmbiguousInvocationInDoc(name string, ref resolve.Reference) []*symbols.Symbol
- func (w *Workspace) AnalyzedContent(name string) ([]byte, []diag.Diagnostic, bool)
- func (w *Workspace) ApplyEdit(name string, ops []edit.Operation, read []*Document) (result *EditResult, version int, ok bool, err error)
- func (w *Workspace) Close(name string)
- func (w *Workspace) ConformanceMode() diag.ConformanceMode
- func (w *Workspace) DeleteOnDisk(name string)
- func (w *Workspace) Diagnostics(name string) []diag.Diagnostic
- func (w *Workspace) Document(name string) *Document
- func (w *Workspace) DocumentDefinitions() []DocumentDefinition
- func (w *Workspace) DocumentNames() []string
- func (w *Workspace) ElementOnPath(scope *symbols.Scope, path []string) (*symbols.Symbol, bool)
- func (w *Workspace) EnclosingMetadataBody(scope *symbols.Scope) *symbols.Scope
- func (w *Workspace) FQNOf(sym *symbols.Symbol) string
- func (w *Workspace) Generation() uint64
- func (w *Workspace) HighlightTokens(name string) ([]byte, []highlight.Token)
- func (w *Workspace) IdentityOf(name string, sym *symbols.Symbol) (*identity.Info, bool)
- func (w *Workspace) IsDocumentDefinition(sym *symbols.Symbol) bool
- func (w *Workspace) IsLibraryDocument(name string) bool
- func (w *Workspace) IsLibraryRoot(name string) bool
- func (w *Workspace) IsOpen(name string) bool
- func (w *Workspace) LibraryDocument(name string) *Document
- func (w *Workspace) LookupQualified(fqn string) []*symbols.Symbol
- func (w *Workspace) MembersOnPath(scope *symbols.Scope, path []string) []*symbols.Symbol
- func (w *Workspace) MetadataBodyMembers(scope *symbols.Scope) []*symbols.Symbol
- func (w *Workspace) MetadataBodyRedefines(sym *symbols.Symbol) (*symbols.Symbol, string, bool)
- func (w *Workspace) NameReferencesTo(target *symbols.Symbol, name string) []ReferenceLocation
- func (w *Workspace) NewRuntime() (*Runtime, error)
- func (w *Workspace) Open(name string, content []byte, version int)
- func (w *Workspace) OpenNames() []string
- func (w *Workspace) QueryBindingParameter(sym *symbols.Symbol) (*symbols.Symbol, bool)
- func (w *Workspace) QueryDefinitions(syms []*symbols.Symbol) []*symbols.Symbol
- func (w *Workspace) QueryTypeCandidates(scope *symbols.Scope) []QueryTypeCandidate
- func (w *Workspace) QueryUsageParameters(usage *symbols.Symbol) ([]*symbols.Symbol, bool)
- func (w *Workspace) Read(fn func(r *Reading) error) error
- func (w *Workspace) ReferencesTo(target *symbols.Symbol) []ReferenceLocation
- func (w *Workspace) Remove(name string)
- func (w *Workspace) RenameConflict(target *symbols.Symbol, name, newName string) *edit.RenameConflict
- func (w *Workspace) RenderDocumentMarkdown(fqn string, opts docrender.MarkdownOptions) (string, error)
- func (w *Workspace) RenderView(doc, fqn string) (*view.Rendering, *Snapshot, error)
- func (w *Workspace) ResolveQualifiedInDoc(name string, scope *symbols.Scope, qn *ast.QualifiedName) (*symbols.Symbol, bool)
- func (w *Workspace) ResolveQualifiedSegmentsInDoc(name string, scope *symbols.Scope, qn *ast.QualifiedName) []*symbols.Symbol
- func (w *Workspace) ResolveReferenceInDoc(name string, ref resolve.Reference) (*symbols.Symbol, bool)
- func (w *Workspace) ResolveReferenceNameSegmentsInDoc(name string, ref resolve.Reference) []*symbols.Symbol
- func (w *Workspace) ResolveReferenceSegmentsInDoc(name string, ref resolve.Reference) []*symbols.Symbol
- func (w *Workspace) ScopeAt(doc string, offset int) *symbols.Scope
- func (w *Workspace) SetConformanceMode(mode diag.ConformanceMode)
- func (w *Workspace) SetOnDisk(name string, content []byte)
- func (w *Workspace) StandsInFor(name string) string
- func (w *Workspace) TopLevelSymbols(doc string) []*symbols.Symbol
- func (w *Workspace) Update(name string, content []byte, version int)
- func (w *Workspace) Views(doc string) ([]ViewInfo, *Document)
- func (w *Workspace) VisibleNames(scope *symbols.Scope, opts VisibleNamesOptions) []VisibleName
- func (w *Workspace) VisibleNamesAt(doc string, offset int, opts VisibleNamesOptions) []VisibleName
Constants ¶
This section is empty.
Variables ¶
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 ¶
DeclaredViews returns the views declared in scope and its nested scopes, outermost first and in declaration order.
func IsModelSource ¶
IsModelSource reports whether path is a SysML/KerML source file.
func NewIndexWithStdlib ¶
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.
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 ¶
NewDebouncer returns a debouncer with the given coalescing window.
type Dependency ¶
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.
type DocumentDefinition ¶
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 ¶
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 ¶
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 ¶
DeclarationText is the source text of sym's declaration, "" when its document is gone.
func (*Reading) Declared ¶
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 ¶
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 ¶
Document is the held document name, nil for one the workspace does not hold.
func (*Reading) Generation ¶
Generation is the workspace's generation as read.
func (*Reading) NewRuntime ¶
NewRuntime is Workspace.NewRuntime over the documents as read.
func (*Reading) RenderView ¶
RenderView is Workspace.RenderView of the documents as read.
type ReferenceLocation ¶
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 ¶
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) Generation ¶
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 ¶
Model is the runtime model executions are built over with runtime.NewContext.
func (*Runtime) Named ¶
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 ¶
Referenced is the symbols expr's names reach when resolved in scope, as the runtime's index has them.
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.
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
DocumentNames returns a snapshot of the names of all known documents.
func (*Workspace) ElementOnPath ¶
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 ¶
EnclosingMetadataBody returns the nearest scope, from scope outward, whose declarations redefine the features of a metadata type; nil outside one.
func (*Workspace) FQNOf ¶
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 ¶
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 ¶
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 ¶
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 ¶
IsDocumentDefinition reports whether sym is a native document definition: a part def specializing DocumentQueries::Document.
func (*Workspace) IsLibraryDocument ¶
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 ¶
IsLibraryRoot reports whether name is a top-level package of the workspace's library.
func (*Workspace) LibraryDocument ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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) QueryBindingParameter ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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) Views ¶
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.