Skip to content

Commit 12b7faa

Browse files
authored
refactor: Remove unused tempImports concept (#2215)
1 parent 9cfde65 commit 12b7faa

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

internal/sidekick/internal/dart/annotate.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ func (annotate *annotateModel) annotateModel(options map[string]string) error {
281281

282282
// Traverse and annotate the messages defined in this API.
283283
for _, m := range model.Messages {
284-
annotate.annotateMessage(m, annotate.imports)
284+
annotate.annotateMessage(m)
285285
}
286286

287287
for _, s := range model.Services {
@@ -436,9 +436,9 @@ func (annotate *annotateModel) annotateService(s *api.Service) {
436436
s.Codec = ann
437437
}
438438

439-
func (annotate *annotateModel) annotateMessage(m *api.Message, imports map[string]bool) {
439+
func (annotate *annotateModel) annotateMessage(m *api.Message) {
440440
// Add the import for the common JSON helpers.
441-
imports[commonHelpersImport] = true
441+
annotate.imports[commonHelpersImport] = true
442442

443443
for _, f := range m.Fields {
444444
annotate.annotateField(f)
@@ -450,7 +450,7 @@ func (annotate *annotateModel) annotateMessage(m *api.Message, imports map[strin
450450
annotate.annotateEnum(e)
451451
}
452452
for _, m := range m.Messages {
453-
annotate.annotateMessage(m, imports)
453+
annotate.annotateMessage(m)
454454
}
455455

456456
constructorBody := ";"
@@ -510,12 +510,11 @@ func createToStringLines(message *api.Message) []string {
510510

511511
func (annotate *annotateModel) annotateMethod(method *api.Method) {
512512
// Ignore imports added from the input and output messages.
513-
tempImports := map[string]bool{}
514513
if method.InputType.Codec == nil {
515-
annotate.annotateMessage(method.InputType, tempImports)
514+
annotate.annotateMessage(method.InputType)
516515
}
517516
if method.OutputType.Codec == nil {
518-
annotate.annotateMessage(method.OutputType, tempImports)
517+
annotate.annotateMessage(method.OutputType)
519518
}
520519

521520
pathInfoAnnotation := &pathInfoAnnotation{

internal/sidekick/internal/dart/annotate_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,7 @@ func TestAnnotateMessageToString(t *testing.T) {
247247
{message: sample.Automatic(), expected: 0},
248248
} {
249249
t.Run(test.message.Name, func(t *testing.T) {
250-
imports := map[string]bool{}
251-
annotate.annotateMessage(test.message, imports)
250+
annotate.annotateMessage(test.message)
252251

253252
codec := test.message.Codec.(*messageAnnotation)
254253
actual := codec.ToStringLines

0 commit comments

Comments
 (0)