Documentation ¶
Overview ¶
Package source provides core features for use by Go editors and tools.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Diagnostics ¶
Types ¶
type CompletionItem ¶
type CompletionItem struct {
Label, Detail string
Kind CompletionItemKind
Score float64
}
func Completion ¶
func Completion(ctx context.Context, f File, pos token.Pos) (items []CompletionItem, prefix string, err error)
Completion returns a list of possible candidates for completion, given a a file and a position. The prefix is computed based on the preceding identifier and can be used by the client to score the quality of the completion. For instance, some clients may tolerate imperfect matches as valid completion results, since users may make typos.
type CompletionItemKind ¶
type CompletionItemKind int
const ( Unknown CompletionItemKind = iota InterfaceCompletionItem StructCompletionItem TypeCompletionItem ConstantCompletionItem FieldCompletionItem ParameterCompletionItem VariableCompletionItem FunctionCompletionItem MethodCompletionItem PackageCompletionItem )
type Diagnostic ¶
type File ¶
type File interface { GetAST() (*ast.File, error) GetFileSet() (*token.FileSet, error) GetPackage() (*packages.Package, error) GetToken() (*token.File, error) Read() ([]byte, error) }
File represents a Go source file that has been type-checked. It is the input to most of the exported functions in this package, as it wraps up the building blocks for most queries. Users of the source package can abstract the loading of packages into their own caching systems.
type ParameterInformation ¶
type ParameterInformation struct {
Label string
}
type Range ¶
Range represents a start and end position. Because Range is based purely on two token.Pos entries, it is not self contained. You need access to a token.FileSet to regain the file information.
func Definition ¶
type SignatureInformation ¶
type SignatureInformation struct { Label string Parameters []ParameterInformation ActiveParameter int }
func SignatureHelp ¶
type TextEdit ¶
TextEdit represents a change to a section of a document. The text within the specified range should be replaced by the supplied new text.
type URI ¶
type URI string
URI represents the full URI for a file.
type View ¶
type View interface { GetFile(ctx context.Context, uri URI) (File, error) SetContent(ctx context.Context, uri URI, content []byte) (View, error) FileSet() *token.FileSet }
View abstracts the underlying architecture of the package using the source package. The view provides access to files and their contents, so the source package does not directly access the file system.