Documentation
¶
Overview ¶
Package analysisutil contains unsupported syntax and type helpers shared by analyzer implementations and integrations. Its API may change without notice.
Index ¶
- Constants
- func AnalyzeFile(pass *analysis.Pass, file *ast.File) bool
- func DiagnosticSuppressed(pass *analysis.Pass, position token.Pos, analyzer string) bool
- func GeneratedFile(file *ast.File) bool
- func IncludeProductionFilesInTestVariants(analyzer *analysis.Analyzer) *analysis.Analyzer
- func IsErrorType(value types.Type) bool
- func IsPackageCall(pass *analysis.Pass, call *ast.CallExpr, symbol FunctionSymbol) bool
- func IsStringType(value types.Type) bool
- func NamedType(value types.Type, packagePath, name string) bool
- func SameExpression(pass *analysis.Pass, first, second ast.Expr) bool
- func SourceRange(pass *analysis.Pass, position token.Pos) analysis.Range
- type FunctionSymbol
Constants ¶
const BuiltinClose = "close"
BuiltinClose names Go's channel-closing builtin.
Variables ¶
This section is empty.
Functions ¶
func AnalyzeFile ¶
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 ¶
DiagnosticSuppressed reports whether an immediately adjacent comment contains "gohawk:ignore analyzer" for analyzer.
func GeneratedFile ¶
GeneratedFile reports whether file carries Go's generated-file marker.
func IncludeProductionFilesInTestVariants ¶ added in v0.2.1
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 ¶
IsErrorType reports whether value implements Go's predeclared error interface.
func IsPackageCall ¶
IsPackageCall reports whether call statically names symbol.
func IsStringType ¶
IsStringType reports whether value has string as its underlying type.
func NamedType ¶
NamedType reports whether value names packagePath.name, allowing one pointer layer.
func SameExpression ¶ added in v0.2.0
SameExpression reports whether two expressions identify the same syntactic value, using type information to distinguish identifiers with equal names.
func SourceRange ¶
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 ¶
FunctionSymbol identifies one package-level Go function.