Skip to content

Commit a490368

Browse files
committed
chore: factorize formatFile
1 parent d28f450 commit a490368

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

shorten/format.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ import (
1010
"github.com/golangci/golines/shorten/internal/tags"
1111
)
1212

13+
// formatFile formats the provided AST file starting at the top-level declarations.
14+
func (s *Shortener) formatFile(file *dst.File) {
15+
for _, decl := range file.Decls {
16+
s.formatNode(decl)
17+
}
18+
}
19+
1320
// formatNode formats the provided AST node.
1421
// The appropriate helper function is called based on
1522
// whether the node is a declaration, expression, statement, or spec.

shorten/shortener.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,8 @@ func (s *Shortener) Process(content []byte) ([]byte, error) {
155155
}
156156
}
157157

158-
// Process the file starting at the top-level declarations
159-
for _, decl := range result.Decls {
160-
s.formatNode(decl)
161-
}
158+
// Process the file.
159+
s.formatFile(result)
162160

163161
// Materialize output
164162
output := bytes.NewBuffer([]byte{})

0 commit comments

Comments
 (0)