package globals

import "gvisor.dev/gvisor/tools/go_generics/globals"

Package globals provides an AST visitor that calls the visit function for all global identifiers.

Index

Functions

func GetIdent

func GetIdent(expr ast.Expr) *ast.Ident

GetIdent returns the identifier associated with the given expression by removing parentheses if needed.

func Visit

func Visit(fset *token.FileSet, file *ast.File, f func(*ast.Ident, SymKind), processAnon bool)

Visit traverses the provided AST and calls f() for each identifier that refers to global names. The global name must be defined in the file itself.

The function f() is allowed to modify the identifier, for example, to rename uses of global references.

Types

type SymKind

type SymKind int

SymKind specifies the kind of a global symbol. For example, a variable, const function, etc.

const (
	KindUnknown SymKind = iota
	KindImport
	KindType
	KindVar
	KindConst
	KindFunction
	KindReceiver
	KindParameter
	KindResult
	KindTag
)

Constants for different kinds of symbols.

Source Files

globals_visitor.go scope.go

Version
v0.0.0-20250605235530-a6711d1e1dc6 (latest)
Published
Jun 5, 2025
Platform
linux/amd64
Imports
5 packages
Last checked
4 hours ago

Tools for package owners.