document

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2025 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadDocument

func ReadDocument(u uri.URI) (contents []byte, err error)

Read the document from the given URI and return its contents. This default implementation of a ReadDocumentFunc only handles file: URIs and returns an error otherwise.

Types

type BakeHCLDocument

type BakeHCLDocument interface {
	Document
	Decoder() *decoder.PathDecoder
	File() *hcl.File
	DockerfileForTarget(block *hclsyntax.Block) (string, error)
}

func NewBakeHCLDocument

func NewBakeHCLDocument(u uri.URI, version int32, input []byte) BakeHCLDocument

type BakePrintOutput added in v0.3.6

type BakePrintOutput struct {
	Group  map[string]bake.Group  `json:"group,omitempty"`
	Target map[string]bake.Target `json:"target"`
}

type ComposeDocument

type ComposeDocument interface {
	Document
	RootNode() yaml.Node
}

func NewComposeDocument

func NewComposeDocument(u uri.URI, version int32, input []byte) ComposeDocument

type DockerfileDocument

type DockerfileDocument interface {
	Document
	Instruction(p protocol.Position) *parser.Node
	Nodes() []*parser.Node
}

func NewDockerfileDocument

func NewDockerfileDocument(u uri.URI, version int32, input []byte) DockerfileDocument

type Document

type Document interface {
	URI() uri.URI
	Copy() Document
	Input() []byte
	Version() int32
	Update(version int32, input []byte) bool
	Close()
	LanguageIdentifier() protocol.LanguageIdentifier
}

func NewDocument

func NewDocument(u uri.URI, identifier protocol.LanguageIdentifier, version int32, input []byte) Document

type DocumentMap

type DocumentMap map[uri.URI]Document

type Manager

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

Manager provides simplified file read/write operations for the LSP server.

func NewDocumentManager

func NewDocumentManager(opts ...ManagerOpt) *Manager

func (*Manager) Get

func (m *Manager) Get(ctx context.Context, u uri.URI) Document

func (*Manager) Keys

func (m *Manager) Keys() []uri.URI

func (*Manager) LockDocument added in v0.3.0

func (m *Manager) LockDocument(uri uri.URI) bool

LockDocument locks the specified document in preparation of publishing diagnostics. False may be returned if the document is not recognized as being opened in the client.

func (*Manager) Overwrite

func (m *Manager) Overwrite(ctx context.Context, u uri.URI, version int32, input []byte) (bool, error)

func (*Manager) Queue added in v0.3.0

func (m *Manager) Queue(ctx context.Context, u uri.URI, fn func())

Queue enqueues the given function as something that should be run in the near future. The URI will be used as a key so if another function had previously enqueued for this function and it had not yet been run that the previously enqueued function will be discarded and replaced with the provided function.

func (*Manager) Read

func (m *Manager) Read(ctx context.Context, u uri.URI) (doc Document, err error)

Read returns the contents of the file for the given URI.

If no file exists at the path or the URI is of an invalid type, an error is returned.

func (*Manager) Remove

func (m *Manager) Remove(u uri.URI)

func (*Manager) UnlockDocument added in v0.3.0

func (m *Manager) UnlockDocument(uri uri.URI)

func (*Manager) Version

func (m *Manager) Version(ctx context.Context, u uri.URI) (int32, error)

func (*Manager) Write

func (m *Manager) Write(ctx context.Context, u uri.URI, identifier protocol.LanguageIdentifier, version int32, input []byte) (bool, error)

Write creates or replaces the contents of the file for the given URI. True will be returned if the document's syntax tree has changed.

type ManagerOpt

type ManagerOpt func(manager *Manager)

func WithReadDocumentFunc

func WithReadDocumentFunc(readDocFunc ReadDocumentFunc) ManagerOpt

type NewDocumentFunc

type NewDocumentFunc func(u uri.URI, identifier protocol.LanguageIdentifier, version int32, input []byte) Document

type ReadDocumentFunc

type ReadDocumentFunc func(uri.URI) ([]byte, error)

Jump to

Keyboard shortcuts

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