blob: c6b590245ddaa4971d488028f9a0cf4d8a434bc1 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
package main
import "github.com/Fuwn/iku/engine"
type CommentMode int
const (
CommentsFollow CommentMode = iota
CommentsPrecede
CommentsStandalone
)
type Formatter struct {
CommentMode CommentMode
}
type lineInformation struct {
statementType string
isTopLevel bool
isScoped bool
isStartLine bool
}
func (f *Formatter) Format(source []byte) ([]byte, error) {
adapter := &GoAdapter{}
_, events, err := adapter.Analyze(source)
if err != nil {
return nil, err
}
formattingEngine := &engine.Engine{CommentMode: MapCommentMode(f.CommentMode)}
return []byte(formattingEngine.FormatToString(events)), nil
}
|