Documentation
¶
Index ¶
- type NestedAssign
- type NestedChecker
- type ShadowChecker
- func (sc *ShadowChecker) CheckDeclarationShadowing(scopes scope.UsageScope, variable *types.Var, shadowPos token.Pos)
- func (sc *ShadowChecker) CheckUseAfterShadowed(variable *types.Var, namePos token.Pos, use astutil.NodeIndex)
- func (sc *ShadowChecker) ShadowCheckerEnabled() bool
- func (sc *ShadowChecker) UpdateShadows(v *types.Var, id *ast.Ident, assignmentDone token.Pos)
- func (sc *ShadowChecker) UpdateShadowsWithReachability(v *types.Var, id *ast.Ident, assignmentDone token.Pos)
- func (sc *ShadowChecker) UsedAfterShadow() []ShadowUse
- type ShadowUse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NestedAssign ¶
NestedAssign contains information about a nested variable assign.
type NestedChecker ¶
type NestedChecker struct {
// contains filtered or unexported fields
}
NestedChecker tracks nested variable assignments.
func NewNestedChecker ¶
func NewNestedChecker(enabled bool) NestedChecker
NewNestedChecker creates a new NestedChecker instance.
If enabled is false, nested assignment tracking is disabled, and the checker is a no-op that uses minimal memory.
func (*NestedChecker) NestedAssigned ¶
func (nc *NestedChecker) NestedAssigned() []NestedAssign
NestedAssigned returns the list of variables that were assigned during an assignment.
type ShadowChecker ¶
type ShadowChecker struct {
// Control-flow graph to test reachability
*reachability.Graph
// contains filtered or unexported fields
}
ShadowChecker tracks variable shadowing and usage of variables while they are shadowed.
It is designed to be embedded in other analyzers (like usageCollector) to add shadow detection capabilities.
func NewShadowChecker ¶
func NewShadowChecker(enabled, firstUseOnly bool) ShadowChecker
NewShadowChecker creates a new ShadowChecker instance.
If enabled is false, shadow tracking is disabled, and the checker is a no-op that uses minimal memory.
func (*ShadowChecker) CheckDeclarationShadowing ¶ added in v0.0.5
func (sc *ShadowChecker) CheckDeclarationShadowing(scopes scope.UsageScope, variable *types.Var, shadowPos token.Pos)
CheckDeclarationShadowing checks if the variable shadows another in parent scopes and records it.
func (*ShadowChecker) CheckUseAfterShadowed ¶ added in v0.0.5
func (sc *ShadowChecker) CheckUseAfterShadowed(variable *types.Var, namePos token.Pos, use astutil.NodeIndex)
CheckUseAfterShadowed checks if the variable is used at the given position after shadowed. If it is, it records the usage.
func (*ShadowChecker) ShadowCheckerEnabled ¶ added in v0.0.5
func (sc *ShadowChecker) ShadowCheckerEnabled() bool
ShadowCheckerEnabled reports whether the shadow checker is enabled.
func (*ShadowChecker) UpdateShadows ¶
UpdateShadows updates shadow tracking when variables are assigned at declaration scope. When a shadowed outer variable is reassigned, the shadow "ends" at that point, as the outer variable has a new value.
Note: This is lexically based, not control-flow sensitive.
func (*ShadowChecker) UpdateShadowsWithReachability ¶ added in v0.0.5
func (sc *ShadowChecker) UpdateShadowsWithReachability(v *types.Var, id *ast.Ident, assignmentDone token.Pos)
UpdateShadowsWithReachability updates shadow tracking when variables are assigned in a subscope.
func (*ShadowChecker) UsedAfterShadow ¶
func (sc *ShadowChecker) UsedAfterShadow() []ShadowUse
UsedAfterShadow returns the list of variables that were used after being shadowed.