fillstruct

package
v0.15.0-pre.1 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2024 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Overview

Package fillstruct defines an Analyzer that automatically fills in a struct declaration with zero value elements for each field.

The analyzer's diagnostic is merely a prompt. The actual fix is created by a separate direct call from gopls to the SuggestedFixes function. Tests of Analyzer.Run can be found in ./testdata/src. Tests of the SuggestedFixes logic live in ../../testdata/fillstruct.

Index

Constants

View Source
const Doc = `` /* 286-byte string literal not displayed */

Variables

View Source
var Analyzer = &analysis.Analyzer{
	Name:             "fillstruct",
	Doc:              Doc,
	Requires:         []*analysis.Analyzer{inspect.Analyzer},
	Run:              run,
	URL:              "https://pkg.go.dev/golang.org/x/tools/gopls/internal/analysis/fillstruct",
	RunDespiteErrors: true,
}

Functions

func DiagnoseFillableStructs

func DiagnoseFillableStructs(inspect *inspector.Inspector, start, end token.Pos, pkg *types.Package, info *types.Info) []analysis.Diagnostic

DiagnoseFillableStructs computes diagnostics for fillable struct composite literals overlapping with the provided start and end position.

If either start or end is invalid, it is considered an unbounded condition.

func SuggestedFix

func SuggestedFix(fset *token.FileSet, start, end token.Pos, content []byte, file *ast.File, pkg *types.Package, info *types.Info) (*token.FileSet, *analysis.SuggestedFix, error)

SuggestedFix computes the suggested fix for the kinds of diagnostics produced by the Analyzer above.

Types

This section is empty.

Jump to

Keyboard shortcuts

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