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)
| 47 | // |
| 48 | // This method is not meant to be used directly by templates. |
| 49 | func (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 |
no test coverage detected