• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

stephenafamo / bob / 14939098091

09 May 2025 10:59PM UTC coverage: 36.868% (-4.6%) from 41.506%
14939098091

push

github

stephenafamo
Move reusable sqlite parser components to antlrhelpers package

0 of 758 new or added lines in 12 files covered. (0.0%)

547 existing lines in 8 files now uncovered.

6533 of 17720 relevant lines covered (36.87%)

212.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/gen/bobgen-helpers/parser/antlrhelpers/node_info.go
1
package antlrhelpers
2

3
import (
4
        "slices"
5

6
        "github.com/antlr4-go/antlr/v4"
7
        "github.com/stephenafamo/bob/gen/drivers"
8
)
9

10
type Node interface {
11
        GetStart() antlr.Token
12
        GetStop() antlr.Token
13
        GetParent() antlr.Tree
14
        GetText() string
15
        GetParser() antlr.Parser
16
}
17

18
type NodeKey struct {
19
        start int
20
        stop  int
21
}
22

NEW
23
func Key(ctx Node) NodeKey {
×
NEW
24
        return NodeKey{
×
NEW
25
                start: ctx.GetStart().GetStart(),
×
NEW
26
                stop:  ctx.GetStop().GetStop(),
×
NEW
27
        }
×
NEW
28
}
×
29

30
type NodeInfo struct {
31
        Node                 Node
32
        ExprDescription      string
33
        Type                 NodeTypes
34
        ExprRef              Node
35
        IgnoreRefNullability bool
36

37
        // Go Info
38
        ArgKey         string // Positional or named arg in the query
39
        IsGroup        bool
40
        EditedPosition [2]int
41
        CanBeMultiple  bool
42
        Config         drivers.QueryCol
43
}
44

NEW
45
func GetDBType(exprs map[NodeKey]NodeInfo, e NodeInfo) NodeTypes {
×
NEW
46
        DBType := e.Type
×
NEW
47
        ignoreRefNullability := false
×
NEW
48

×
NEW
49
        keys := make(map[NodeKey]struct{})
×
NEW
50

×
NEW
51
        for DBType == nil && e.ExprRef != nil {
×
NEW
52
                key := Key(e.ExprRef)
×
NEW
53
                if _, ok := keys[key]; ok {
×
NEW
54
                        break
×
55
                }
56

NEW
57
                e = exprs[key]
×
NEW
58
                DBType = e.Type
×
NEW
59
                ignoreRefNullability = e.IgnoreRefNullability
×
NEW
60

×
NEW
61
                keys[key] = struct{}{}
×
62
        }
63

NEW
64
        if ignoreRefNullability {
×
NEW
65
                DBType = slices.Clone(DBType)
×
NEW
66
                for i := range DBType {
×
NEW
67
                        DBType[i].NullableF = nil
×
NEW
68
                }
×
69
        }
70

NEW
71
        return DBType
×
72
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc