Documentation
¶
Overview ¶
Package modules provides facilities to track the parsed state of modules and provider completion and hover contexts, among other things.
Index ¶
- Constants
- type Config
- type DocStore
- type DynamicSchemaProvider
- type DynamicSchemas
- type Modules
- func (m *Modules) PathCompletionContext(p lang.Path, filename string, pos hcl.Pos) (decoder.CompletionContext, error)
- func (m *Modules) PathContext(p lang.Path) (decoder.Context, error)
- func (m *Modules) Paths() ([]lang.Path, error)
- func (m *Modules) ProcessOpenForTesting(dir string) error
- func (m *Modules) ReferenceMap(p lang.Path) (*target.ReferenceMap, error)
- func (m *Modules) Start(ctx context.Context)
- func (m *Modules) WaitUntilProcessed(dir string)
- type ReadOnlyFS
Constants ¶
const ( // XRDFile is a metadata file in the same directory as a module to discover // the API version and kind of the composite resource such that this can // provide intelligent completion for the `req.composite` external variable. XRDFile = ".xrd.yaml" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
EventBus *eventbus.EventBus // event bus to listen on
DocStore DocStore // document store
FS ReadOnlyFS // filesystem that can provide unsaved document changes
Provider DynamicSchemaProvider // provider to get dynamic schemas for a module, for autocomplete
}
Config is the feature configuration.
type DocStore ¶
type DocStore interface {
// HasOpenDocuments returns true if the supplied directory has documents open.
HasOpenDocuments(dirHandle document.DirHandle) bool
// IsDocumentOpen returns true if the supplied document is currently open.
IsDocumentOpen(dh document.Handle) bool
}
DocStore provides minimal information about the state of the document store for efficient module processing.
type DynamicSchemaProvider ¶
type DynamicSchemaProvider func(modPath string) DynamicSchemas
DynamicSchemaProvider provides dynamic schema information for a module rooted at the supplied path.
type DynamicSchemas ¶
type DynamicSchemas interface {
Keys() []resource.Key // return all known keys
Schema(apiVersion, kind string) *schema.AttributeSchema // return schema for the supplied key
}
DynamicSchemas provides schemas on demand for an API version, kind tuple. It can also list all such known tuples.
type Modules ¶
type Modules struct {
// contains filtered or unexported fields
}
Modules groups everything related to modules. Its internal state keeps track of all modules in the workspace.
func (*Modules) PathCompletionContext ¶
func (m *Modules) PathCompletionContext(p lang.Path, filename string, pos hcl.Pos) (decoder.CompletionContext, error)
PathCompletionContext returns the completion/ hover context for the supplied path, for a given position in a specific file. This takes into account the variables that are visible from that position.
func (*Modules) PathContext ¶
PathContext returns the context for the supplied path.
func (*Modules) ProcessOpenForTesting ¶
ProcessOpenForTesting processes an open event in a completely synchronous fashion for use by unit tests in other packages. It assumes that the dir has not been opened.
func (*Modules) ReferenceMap ¶
ReferenceMap returns the map of document references from declaration to references and vice-versa.
func (*Modules) Start ¶
Start starts background activities. It terminates when the supplied context is closed.
func (*Modules) WaitUntilProcessed ¶
WaitUntilProcessed waits until all jobs currently queued for the supplied directory complete.
type ReadOnlyFS ¶
type ReadOnlyFS interface {
fs.FS // extends a base FS
ReadDir(name string) ([]fs.DirEntry, error) // allows listing directory contents.
ReadFile(name string) ([]byte, error) // convenience method to read a file.
Stat(name string) (fs.FileInfo, error) // provides file information
}
ReadOnlyFS is a read-only filesystem needed for module processing.