MCPcopy
hub / github.com/vektra/mockery / ResolveVariableNameCollisions

Method ResolveVariableNameCollisions

template/method_scope.go:49–60  ·  view source on GitHub ↗

ResolveVariableNameCollisions modifies argument names if they are found to collide with any other names visible to the scope. This method is not meant to be used directly by templates.

(ctx context.Context)

Source from the content-addressed store, hash-verified

47//
48// This method is not meant to be used directly by templates.
49func (m *MethodScope) ResolveVariableNameCollisions(ctx context.Context) {
50 log := zerolog.Ctx(ctx)
51 for _, v := range m.vars {
52 varLog := log.With().Str("variable-name", v.Name).Logger()
53 newName := m.SuggestName(v.Name)
54 if newName != v.Name {
55 varLog.Debug().Str("new-name", newName).Msg("variable was found to conflict with previously allocated name. Giving new name.")
56 }
57 v.Name = newName
58 m.AddName(v.Name)
59 }
60}
61
62// SuggestName creates a new variable name in the lexical scope of the method.
63// It ensures the returned name does not conflict with any other name visible

Callers 1

GenerateMethod · 0.80

Calls 2

SuggestNameMethod · 0.95
AddNameMethod · 0.95

Tested by

no test coverage detected