golang

package
v0.8.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package golang defines the LSP features for navigation, analysis, and refactoring of Go source code.

Index

Constants

View Source
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

func IsGenerated(ctx context.Context, snapshot *cache.Snapshot, uri protocol.DocumentURI) bool

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.

func SemanticTokens

func SemanticTokens(ctx context.Context, snapshot *cache.Snapshot, fh file.Handle, rng *protocol.Range) (*protocol.SemanticTokens, error)

Types

type ImportPath

type ImportPath = metadata.ImportPath

type PackageID

type PackageID = metadata.PackageID

type PackageName

type PackageName = metadata.PackageName

type PackagePath

type PackagePath = metadata.PackagePath

type ParsedGoFile

type ParsedGoFile = parsego.File

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL