analysisutil

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package analysisutil contains unsupported syntax and type helpers shared by analyzer implementations and integrations. Its API may change without notice.

Index

Constants

View Source
const BuiltinClose = "close"

BuiltinClose names Go's channel-closing builtin.

Variables

This section is empty.

Functions

func AnalyzeFile

func AnalyzeFile(pass *analysis.Pass, file *ast.File) bool

AnalyzeFile reports whether file is the canonical copy to analyze. Package- loading drivers commonly analyze production files once normally and again in a test variant. Other drivers expose the augmented test variant as their only pass, so every file in that pass is canonical.

func DiagnosticSuppressed

func DiagnosticSuppressed(pass *analysis.Pass, position token.Pos, analyzer string) bool

DiagnosticSuppressed reports whether an immediately adjacent comment contains "gohawk:ignore analyzer" for analyzer.

func GeneratedFile

func GeneratedFile(file *ast.File) bool

GeneratedFile reports whether file carries Go's generated-file marker.

func IncludeProductionFilesInTestVariants added in v0.2.1

func IncludeProductionFilesInTestVariants(analyzer *analysis.Analyzer) *analysis.Analyzer

IncludeProductionFilesInTestVariants returns an analyzer copy configured for an embedding driver that does not also run the ordinary production package. Without this marker, production files in the driver's augmented test package would be mistaken for duplicate copies and skipped.

func IsErrorType

func IsErrorType(value types.Type) bool

IsErrorType reports whether value implements Go's predeclared error interface.

func IsPackageCall

func IsPackageCall(pass *analysis.Pass, call *ast.CallExpr, symbol FunctionSymbol) bool

IsPackageCall reports whether call statically names symbol.

func IsStringType

func IsStringType(value types.Type) bool

IsStringType reports whether value has string as its underlying type.

func NamedType

func NamedType(value types.Type, packagePath, name string) bool

NamedType reports whether value names packagePath.name, allowing one pointer layer.

func SameExpression added in v0.2.0

func SameExpression(pass *analysis.Pass, first, second ast.Expr) bool

SameExpression reports whether two expressions identify the same syntactic value, using type information to distinguish identifiers with equal names.

func SourceRange

func SourceRange(pass *analysis.Pass, position token.Pos) analysis.Range

SourceRange returns the smallest useful syntax range that starts at or contains position. SSA instructions often retain an operator position but no full range, so analyzers built on SSA use this helper to recover the corresponding source expression or statement.

Types

type FunctionSymbol

type FunctionSymbol struct {
	Package string
	Name    string
}

FunctionSymbol identifies one package-level Go function.

Directories

Path Synopsis
Package ssautil contains shared helpers for SSA-backed analyzers.
Package ssautil contains shared helpers for SSA-backed analyzers.

Jump to

Keyboard shortcuts

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