Documentation ¶
Overview ¶
Package golang defines the LSP features for navigation, analysis, and refactoring of Go source code.
Index ¶
- Constants
- func ComputeOneImportFixEdits(snapshot *cache.Snapshot, pgf *ParsedGoFile, fix *imports.ImportFix) ([]protocol.TextEdit, error)
- func Format(ctx context.Context, snapshot *cache.Snapshot, fh file.Handle) ([]protocol.TextEdit, error)
- func IsGenerated(ctx context.Context, snapshot *cache.Snapshot, uri protocol.DocumentURI) bool
- func NarrowestMetadataForFile(ctx context.Context, snapshot *cache.Snapshot, uri protocol.DocumentURI) (*metadata.Package, error)
- func SemanticTokens(ctx context.Context, snapshot *cache.Snapshot, fh file.Handle, ...) (*protocol.SemanticTokens, error)
- type ImportPath
- type PackageID
- type PackageName
- type PackagePath
- type ParsedGoFile
Constants ¶
const ( ParseHeader = parsego.ParseHeader ParseFull = parsego.ParseFull )
Variables ¶
This section is empty.
Functions ¶
func ComputeOneImportFixEdits ¶
func ComputeOneImportFixEdits(snapshot *cache.Snapshot, pgf *ParsedGoFile, fix *imports.ImportFix) ([]protocol.TextEdit, error)
ComputeOneImportFixEdits returns text edits for a single import fix.
func Format ¶
func Format(ctx context.Context, snapshot *cache.Snapshot, fh file.Handle) ([]protocol.TextEdit, error)
Format formats a file with a given range.
func IsGenerated ¶
IsGenerated gets and reads the file denoted by uri and reports whether it contains a "generated file" comment as described at https://golang.org/s/generatedcode.
TODO(adonovan): opt: this function does too much. Move snapshot.ReadFile into the caller (most of which have already done it).
func NarrowestMetadataForFile ¶
func NarrowestMetadataForFile(ctx context.Context, snapshot *cache.Snapshot, uri protocol.DocumentURI) (*metadata.Package, error)
NarrowestMetadataForFile returns metadata for the narrowest package (the one with the fewest files) that encloses the specified file. The result may be a test variant, but never an intermediate test variant.
Types ¶
type ImportPath ¶
type ImportPath = metadata.ImportPath
type PackageName ¶
type PackageName = metadata.PackageName
type PackagePath ¶
type PackagePath = metadata.PackagePath
type ParsedGoFile ¶
func NarrowestPackageForFile ¶
func NarrowestPackageForFile(ctx context.Context, snapshot *cache.Snapshot, uri protocol.DocumentURI) (*cache.Package, *ParsedGoFile, error)
NarrowestPackageForFile is a convenience function that selects the narrowest non-ITV package to which this file belongs, type-checks it in the requested mode (full or workspace), and returns it, along with the parse tree of that file.
The "narrowest" package is the one with the fewest number of files that includes the given file. This solves the problem of test variants, as the test will have more files than the non-test package.
An intermediate test variant (ITV) package has identical source to a regular package but resolves imports differently. gopls should never need to type-check them.
Type-checking is expensive. Call snapshot.ParseGo if all you need is a parse tree, or snapshot.MetadataForFile if you only need metadata.
func WidestPackageForFile ¶
func WidestPackageForFile(ctx context.Context, snapshot *cache.Snapshot, uri protocol.DocumentURI) (*cache.Package, *ParsedGoFile, error)
WidestPackageForFile is a convenience function that selects the widest non-ITV package to which this file belongs, type-checks it in the requested mode (full or workspace), and returns it, along with the parse tree of that file.
The "widest" package is the one with the most number of files that includes the given file. Which is the test variant if one exists.
An intermediate test variant (ITV) package has identical source to a regular package but resolves imports differently. gopls should never need to type-check them.
Type-checking is expensive. Call snapshot.ParseGo if all you need is a parse tree, or snapshot.MetadataForFile if you only need metadata.