@@ -6,41 +6,14 @@ import (
6
6
"github.com/quasilyte/gogrep"
7
7
)
8
8
9
- // matchData is used to handle both regexp and AST match sets in the same way.
10
- type matchData interface {
11
- // TODO: don't use gogrep.CapturedNode type here.
12
-
13
- Node () ast.Node
14
- CaptureList () []gogrep.CapturedNode
15
- CapturedByName (name string ) (ast.Node , bool )
16
- }
17
-
18
- type commentMatchData struct {
19
- node ast.Node
20
- capture []gogrep.CapturedNode
21
- }
22
-
23
- func (m commentMatchData ) Node () ast.Node { return m .node }
24
-
25
- func (m commentMatchData ) CaptureList () []gogrep.CapturedNode { return m .capture }
26
-
27
- func (m commentMatchData ) CapturedByName (name string ) (ast.Node , bool ) {
28
- for _ , c := range m .capture {
29
- if c .Name == name {
30
- return c .Node , true
31
- }
32
- }
33
- return nil , false
34
- }
35
-
36
- type astMatchData struct {
9
+ type matchData struct {
37
10
match gogrep.MatchData
38
11
}
39
12
40
- func (m astMatchData ) Node () ast.Node { return m .match .Node }
13
+ func (m matchData ) Node () ast.Node { return m .match .Node }
41
14
42
- func (m astMatchData ) CaptureList () []gogrep.CapturedNode { return m .match .Capture }
15
+ func (m matchData ) CaptureList () []gogrep.CapturedNode { return m .match .Capture }
43
16
44
- func (m astMatchData ) CapturedByName (name string ) (ast.Node , bool ) {
17
+ func (m matchData ) CapturedByName (name string ) (ast.Node , bool ) {
45
18
return m .match .CapturedByName (name )
46
19
}
0 commit comments