Documentation
¶
Index ¶
- Constants
- func CheckCommandArgumentCount(args []json.RawMessage, expectedCount int) error
- type AddressContractNamesResolver
- type AddressImportResolver
- type CadenceCheckCompletedParams
- type CheckerCache
- type CheckerKey
- type CheckerKeyResolver
- type CodeActionResolver
- type CodeLensProvider
- type Command
- type CommandHandler
- type CompletionItemData
- type DiagnosticProvider
- type Document
- type DocumentSymbolProvider
- type InitializationOptionsHandler
- type MemberAccountAccessHandler
- type ObjectStream
- type Option
- func WithAddressContractNamesResolver(resolver AddressContractNamesResolver) Option
- func WithAddressImportResolver(resolver AddressImportResolver) Option
- func WithCheckerCache(c CheckerCache) Option
- func WithCheckerKeyResolver(r CheckerKeyResolver) Option
- func WithCodeLensProvider(provider CodeLensProvider) Option
- func WithCommand(command Command) Option
- func WithDiagnosticProvider(provider DiagnosticProvider) Option
- func WithDidOpenHook(hook func(conn protocol.Conn, uri protocol.DocumentURI, text string)) Option
- func WithExtendedStandardLibraryValues(values ...stdlib.StandardLibraryValue) Option
- func WithIdentifierImportResolver(...) Option
- func WithInitializationOptionsHandler(handler InitializationOptionsHandler) Option
- func WithMemberAccountAccessHandler(handler MemberAccountAccessHandler) Option
- func WithProjectIdentityProvider(p ProjectIdentityProvider) Option
- func WithStringImportResolver(resolver StringImportResolver) Option
- type Parameter
- type ProjectIdentityProvider
- type Server
- func (s *Server) CodeAction(_ protocol.Conn, params *protocol.CodeActionParams) (codeActions []*protocol.CodeAction, err error)
- func (s *Server) CodeLens(_ protocol.Conn, params *protocol.CodeLensParams) (codeLenses []*protocol.CodeLens, err error)
- func (s *Server) Completion(_ protocol.Conn, params *protocol.CompletionParams) (items []*protocol.CompletionItem, err error)
- func (s *Server) Definition(_ protocol.Conn, params *protocol.TextDocumentPositionParams) (*protocol.Location, error)
- func (s *Server) DidChangeConfiguration(_ protocol.Conn, params *protocol.DidChangeConfigurationParams) (any, error)
- func (s *Server) DidChangeTextDocument(conn protocol.Conn, params *protocol.DidChangeTextDocumentParams) error
- func (s *Server) DidOpenTextDocument(conn protocol.Conn, params *protocol.DidOpenTextDocumentParams) error
- func (s *Server) DocumentHighlight(_ protocol.Conn, params *protocol.TextDocumentPositionParams) ([]*protocol.DocumentHighlight, error)
- func (s *Server) DocumentLink(_ protocol.Conn, _ *protocol.DocumentLinkParams) (symbols []*protocol.DocumentLink, err error)
- func (s *Server) DocumentSymbol(_ protocol.Conn, params *protocol.DocumentSymbolParams) (symbols []*protocol.DocumentSymbol, err error)
- func (s *Server) ExecuteCommand(conn protocol.Conn, params *protocol.ExecuteCommandParams) (any, error)
- func (*Server) Exit(_ protocol.Conn) error
- func (s *Server) GetDocument(uri protocol.DocumentURI) (doc Document, ok bool)
- func (s *Server) Hover(_ protocol.Conn, params *protocol.TextDocumentPositionParams) (*protocol.Hover, error)
- func (s *Server) Initialize(conn protocol.Conn, params *protocol.InitializeParams) (*protocol.InitializeResult, error)
- func (s *Server) InlayHint(_ protocol.Conn, params *protocol.InlayHintParams) (inlayHints []*protocol.InlayHint, err error)
- func (s *Server) Rename(_ protocol.Conn, params *protocol.RenameParams) (*protocol.WorkspaceEdit, error)
- func (s *Server) ResolveCompletionItem(_ protocol.Conn, item *protocol.CompletionItem) (result *protocol.CompletionItem, err error)
- func (s *Server) SetOptions(options ...Option) error
- func (*Server) Shutdown(conn protocol.Conn) error
- func (s *Server) SignatureHelp(_ protocol.Conn, params *protocol.TextDocumentPositionParams) (*protocol.SignatureHelp, error)
- func (s *Server) Start(stream jsonrpc2.ObjectStream) <-chan struct{}
- func (s *Server) Stop() error
- func (s *Server) WorkspaceFolderRootForPath(absPath string) string
- type StdinStdoutReadWriterCloser
- type StringImportResolver
Constants ¶
const GetContractInitializerParametersCommand = "cadence.server.getContractInitializerParameters"
const GetEntryPointParametersCommand = "cadence.server.getEntryPointParameters"
const ParseEntryPointArgumentsCommand = "cadence.server.parseEntryPointArguments"
Variables ¶
This section is empty.
Functions ¶
func CheckCommandArgumentCount ¶
func CheckCommandArgumentCount(args []json.RawMessage, expectedCount int) error
Types ¶
type AddressContractNamesResolver ¶
AddressContractNamesResolver is a function that is used to resolve contract names of an address
type AddressImportResolver ¶
type AddressImportResolver func(projectID string, location common.AddressLocation) (string, error)
AddressImportResolver resolves address imports, scoped by project ID projectID identifies the project configuration (e.g., flow.json path)
type CadenceCheckCompletedParams ¶
type CadenceCheckCompletedParams struct {
/*URI defined:
* The URI which was checked.
*/
URI protocol.DocumentURI `json:"uri"`
Valid bool `json:"valid"`
}
type CheckerCache ¶ added in v1.6.0
type CheckerCache interface {
Get(key CheckerKey) (*sema.Checker, bool)
Put(key CheckerKey, checker *sema.Checker)
Delete(key CheckerKey)
}
CheckerCache is a storage for checkers keyed by CheckerKey.
type CheckerKey ¶ added in v1.6.0
checkerKey scopes a cached checker by its originating document URI and the imported location. This prevents collisions for name-based imports (e.g., common.StringLocation) across projects. CheckerKey identifies a cached checker instance.
type CheckerKeyResolver ¶ added in v1.6.0
type CheckerKeyResolver interface {
KeyForRoot(projectID string, rootURI protocol.DocumentURI) CheckerKey
KeyForImport(parent CheckerKey, imported common.Location) CheckerKey
}
CheckerKeyResolver composes keys for root and imported checkers.
type CodeActionResolver ¶ added in v0.32.0
type CodeActionResolver func() []*protocol.CodeAction
type CodeLensProvider ¶
type CodeLensProvider func(uri protocol.DocumentURI, version int32, checker *sema.Checker) ([]*protocol.CodeLens, error)
CodeLensProvider is a function that is used to provide code lenses for the given checker
type Command ¶
type Command struct {
Name string
Handler CommandHandler
}
type CommandHandler ¶
type CommandHandler func(args ...json2.RawMessage) (interface{}, error)
CommandHandler represents the form of functions that handle commands submitted from the client using workspace/executeCommand.
type CompletionItemData ¶
type CompletionItemData struct {
URI protocol.DocumentURI `json:"uri"`
ID string `json:"id"`
}
type DiagnosticProvider ¶
type DiagnosticProvider func(uri protocol.DocumentURI, version int32, checker *sema.Checker) ([]protocol.Diagnostic, error)
DiagnosticProvider is a function that is used to provide diagnostics for the given checker
type Document ¶
Document represents an open document on the client. It contains all cached information about each document that is used to support CodeLens, transaction submission, and script execution.
func (Document) HasAnyPrecedingStringsAtPosition ¶
type DocumentSymbolProvider ¶
type DocumentSymbolProvider func(uri protocol.DocumentURI, version int32, checker *sema.Checker) ([]*protocol.DocumentSymbol, error)
DocumentSymbolProvider is a function that is used to provide document symbols for the given checker
type InitializationOptionsHandler ¶
InitializationOptionsHandler is a function that is used to handle initialization options sent by the client
type MemberAccountAccessHandler ¶ added in v1.7.2
type MemberAccountAccessHandler func(projectID string, checker *sema.Checker, memberLocation common.Location) bool
MemberAccountAccessHandler determines if access(account) is allowed, scoped by project ID projectID identifies the project configuration (e.g., flow.json path)
type ObjectStream ¶
type ObjectStream struct {
// contains filtered or unexported fields
}
func NewObjectStream ¶
func (ObjectStream) Close ¶
func (o ObjectStream) Close() error
func (ObjectStream) ReadObject ¶
func (o ObjectStream) ReadObject(v any) (err error)
func (ObjectStream) WriteObject ¶
func (o ObjectStream) WriteObject(obj any) error
type Option ¶
func WithAddressContractNamesResolver ¶
func WithAddressContractNamesResolver(resolver AddressContractNamesResolver) Option
WithAddressContractNamesResolver returns a server option that sets the given function as the function that is used to resolve contract names of an address
func WithAddressImportResolver ¶
func WithAddressImportResolver(resolver AddressImportResolver) Option
WithAddressImportResolver returns a server option that sets the given function as the function that is used to resolve address imports
func WithCheckerCache ¶ added in v1.6.0
func WithCheckerCache(c CheckerCache) Option
WithCheckerCache sets a custom checker cache implementation
func WithCheckerKeyResolver ¶ added in v1.6.0
func WithCheckerKeyResolver(r CheckerKeyResolver) Option
WithCheckerKeyResolver sets the resolver that builds checker cache keys
func WithCodeLensProvider ¶
func WithCodeLensProvider(provider CodeLensProvider) Option
WithCodeLensProvider returns a server option that adds the given function as a function that is used to generate code lenses
func WithCommand ¶
WithCommand returns a server options that adds the given command to the set of commands provided by the server to the client.
If a command with the given name already exists, the option fails.
func WithDiagnosticProvider ¶
func WithDiagnosticProvider(provider DiagnosticProvider) Option
WithDiagnosticProvider returns a server option that adds the given function as a function that is used to generate diagnostics
func WithDidOpenHook ¶ added in v1.6.0
WithDidOpenHook registers a callback invoked after a document is opened.
func WithExtendedStandardLibraryValues ¶ added in v1.0.0
func WithExtendedStandardLibraryValues(values ...stdlib.StandardLibraryValue) Option
WithStandardLibraryValues returns a server option that adds the given function as a function that is used to resolve standard library values (in addition to the default standard library)
This is used to provide parts of the standard library that are present in some given environment but are not native to the language.
func WithIdentifierImportResolver ¶ added in v1.2.1
func WithIdentifierImportResolver(resolver func(projectID string, location common.IdentifierLocation) (string, error)) Option
WithIdentifierImportResolver returns a server option that sets the given function as the function that is used to resolve identifier imports
func WithInitializationOptionsHandler ¶
func WithInitializationOptionsHandler(handler InitializationOptionsHandler) Option
WithInitializationOptionsHandler returns a server option that adds the given function as a function that is used to handle initialization options sent by the client
func WithMemberAccountAccessHandler ¶ added in v0.6.0
func WithMemberAccountAccessHandler(handler MemberAccountAccessHandler) Option
WithMemberAccountAccessHandler returns a server option that adds the given function as a function that is used to determine access for accounts.
When we have a syntax like access(account) this handler is called and determines whether the access is allowed based on the location of program and the called member.
func WithProjectIdentityProvider ¶ added in v1.6.0
func WithProjectIdentityProvider(p ProjectIdentityProvider) Option
WithProjectIdentityProvider sets the project identity provider used for cache scoping
func WithStringImportResolver ¶
func WithStringImportResolver(resolver StringImportResolver) Option
WithStringImportResolver returns a server option that sets the given function as the function that is used to resolve string imports
type ProjectIdentityProvider ¶ added in v1.6.0
type ProjectIdentityProvider interface {
ProjectIDForURI(uri protocol.DocumentURI) string
}
ProjectIdentityProvider maps a document URI to a stable project identity (e.g., abs flow.json path).
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) CodeAction ¶
func (s *Server) CodeAction( _ protocol.Conn, params *protocol.CodeActionParams, ) ( codeActions []*protocol.CodeAction, err error, )
func (*Server) CodeLens ¶
func (s *Server) CodeLens( _ protocol.Conn, params *protocol.CodeLensParams, ) ( codeLenses []*protocol.CodeLens, err error, )
CodeLens is called every time the document contents change and returns a list of actions to be injected into the source as inline buttons.
func (*Server) Completion ¶
func (s *Server) Completion( _ protocol.Conn, params *protocol.CompletionParams, ) ( items []*protocol.CompletionItem, err error, )
Completion is called to compute completion items at a given cursor position.
func (*Server) Definition ¶
func (s *Server) Definition( _ protocol.Conn, params *protocol.TextDocumentPositionParams, ) ( *protocol.Location, error, )
Definition finds the definition of the type at the given location.
func (*Server) DidChangeConfiguration ¶ added in v0.6.0
func (s *Server) DidChangeConfiguration(_ protocol.Conn, params *protocol.DidChangeConfigurationParams) (any, error)
DidChangeConfiguration is called to propagate new values set in the client configuration.
func (*Server) DidChangeTextDocument ¶
func (s *Server) DidChangeTextDocument( conn protocol.Conn, params *protocol.DidChangeTextDocumentParams, ) error
DidChangeTextDocument is called whenever the current document changes. We parse and check the text and publish diagnostics about the document.
func (*Server) DidOpenTextDocument ¶
func (s *Server) DidOpenTextDocument(conn protocol.Conn, params *protocol.DidOpenTextDocumentParams) error
DidOpenTextDocument is called whenever a new file is opened. We parse and check the text and publish diagnostics about the document.
func (*Server) DocumentHighlight ¶
func (s *Server) DocumentHighlight( _ protocol.Conn, params *protocol.TextDocumentPositionParams, ) ( []*protocol.DocumentHighlight, error, )
func (*Server) DocumentLink ¶
func (s *Server) DocumentLink( _ protocol.Conn, _ *protocol.DocumentLinkParams, ) ( symbols []*protocol.DocumentLink, err error, )
func (*Server) DocumentSymbol ¶
func (s *Server) DocumentSymbol( _ protocol.Conn, params *protocol.DocumentSymbolParams, ) ( symbols []*protocol.DocumentSymbol, err error, )
DocumentSymbol is called every time the document contents change and returns a tree of known document symbols, which can be shown in outline panel
func (*Server) ExecuteCommand ¶
func (s *Server) ExecuteCommand(conn protocol.Conn, params *protocol.ExecuteCommandParams) (any, error)
ExecuteCommand is called to execute a custom, server-defined command.
We register all the commands we support in registerCommands and populate their corresponding handler at server initialization.
func (*Server) GetDocument ¶
func (s *Server) GetDocument(uri protocol.DocumentURI) (doc Document, ok bool)
func (*Server) Hover ¶
func (s *Server) Hover( _ protocol.Conn, params *protocol.TextDocumentPositionParams, ) (*protocol.Hover, error)
Hover returns contextual type information about the variable at the given location.
func (*Server) Initialize ¶
func (s *Server) Initialize( conn protocol.Conn, params *protocol.InitializeParams, ) ( *protocol.InitializeResult, error, )
func (*Server) Rename ¶
func (s *Server) Rename( _ protocol.Conn, params *protocol.RenameParams, ) ( *protocol.WorkspaceEdit, error, )
func (*Server) ResolveCompletionItem ¶
func (s *Server) ResolveCompletionItem( _ protocol.Conn, item *protocol.CompletionItem, ) ( result *protocol.CompletionItem, err error, )
ResolveCompletionItem is called to compute completion items at a given cursor position.
func (*Server) SetOptions ¶
func (*Server) Shutdown ¶
Shutdown tells the server to stop accepting any new requests. This can only be followed by a call to Exit, which exits the process.
func (*Server) SignatureHelp ¶
func (s *Server) SignatureHelp( _ protocol.Conn, params *protocol.TextDocumentPositionParams, ) (*protocol.SignatureHelp, error)
func (*Server) Start ¶
func (s *Server) Start(stream jsonrpc2.ObjectStream) <-chan struct{}
func (*Server) WorkspaceFolderRootForPath ¶ added in v1.6.0
WorkspaceFolderRootForPath returns the workspace folder root directory for the given absolute file system path. If no configured workspace folder contains the path, it returns an empty string.
type StdinStdoutReadWriterCloser ¶
type StdinStdoutReadWriterCloser struct{}
StdinStdoutReadWriterCloser implements an io.ReadWriter and io.Closer around STDIN and STDOUT.
func (StdinStdoutReadWriterCloser) Close ¶
func (StdinStdoutReadWriterCloser) Close() error
Close closes STDIN and STDOUT.
type StringImportResolver ¶
type StringImportResolver func(projectID string, location common.StringLocation) (string, error)
StringImportResolver resolves string imports, scoped by project ID projectID identifies the project configuration (e.g., flow.json path)