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)
- func Highlight(ctx context.Context, f File, pos token.Pos) []span.Span
- type Action
- type CompletionItem
- type CompletionItemKind
- type Diagnostic
- type DiagnosticSeverity
- type File
- type IdentifierInfo
- type Package
- type ParameterInformation
- type SignatureInformation
- type Symbol
- type SymbolKind
- type TextEdit
- type View
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Diagnostics ¶
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 GetTypesSizes() types.Sizes 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 Symbol ¶
type SymbolKind ¶
type SymbolKind int
const ( PackageSymbol SymbolKind = iota StructSymbol VariableSymbol ConstantSymbol FunctionSymbol MethodSymbol InterfaceSymbol )
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 { Logger() xlog.Logger FileSet() *token.FileSet GetFile(ctx context.Context, uri span.URI) (File, error) SetContent(ctx context.Context, uri span.URI, content []byte) error }
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.