Documentation
¶
Overview ¶
Package source provides core features for use by Go editors and tools.
Index ¶
- func Diagnostics(ctx context.Context, v View, uri span.URI) (map[span.URI][]Diagnostic, error)
- type Action
- type CompletionItem
- type CompletionItemKind
- type Diagnostic
- type DiagnosticSeverity
- type File
- type IdentifierInfo
- type Package
- type ParameterInformation
- type SignatureInformation
- type TextEdit
- type View
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Action ¶
type Action struct {
Analyzer *analysis.Analyzer
Pkg Package
Deps []*Action
// contains filtered or unexported fields
}
An action represents one unit of analysis work: the application of one analysis to one package. Actions form a DAG, both within a package (as different analyzers are applied, either in sequence or parallel), and across packages (as dependencies are analyzed).
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 Diagnostic struct {
span.Span
Message string
Source string
Severity DiagnosticSeverity
}
type DiagnosticSeverity ¶
type DiagnosticSeverity int
const ( SeverityWarning DiagnosticSeverity = iota SeverityError )
type File ¶
type File interface {
URI() span.URI
GetAST(ctx context.Context) *ast.File
GetFileSet(ctx context.Context) *token.FileSet
GetPackage(ctx context.Context) Package
GetToken(ctx context.Context) *token.File
GetContent(ctx context.Context) []byte
}
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 IdentifierInfo ¶
type IdentifierInfo struct {
Name string
Range span.Range
File File
Type struct {
Range span.Range
Object types.Object
}
Declaration struct {
Range span.Range
Object types.Object
}
// contains filtered or unexported fields
}
IdentifierInfo holds information about an identifier in Go source.
func Identifier ¶
Identifier returns identifier information for a position in a file, accounting for a potentially incomplete selector.
type Package ¶
type Package interface {
GetFilenames() []string
GetSyntax() []*ast.File
GetErrors() []packages.Error
GetTypes() *types.Package
GetTypesInfo() *types.Info
IsIllTyped() bool
GetActionGraph(ctx context.Context, a *analysis.Analyzer) (*Action, error)
}
Package represents a Go package that has been type-checked. It maintains only the relevant fields of a *go/packages.Package.
type ParameterInformation ¶
type ParameterInformation struct {
Label string
}
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 span should be replaced by the supplied new text.
type View ¶
type View interface {
GetFile(ctx context.Context, uri span.URI) (File, error)
SetContent(ctx context.Context, uri span.URI, content []byte) 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.