Skip to content

Commit 948b6fa

Browse files
Jilleandrewmbenton
authored andcommitted
chore: Remove a bunch of dead code (#2360)
Found by staticcheck
1 parent 8d616db commit 948b6fa

File tree

10 files changed

+0
-165
lines changed

10 files changed

+0
-165
lines changed

Diff for: internal/compiler/compile.go

-28
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"io"
77
"os"
88
"path/filepath"
9-
"regexp"
109
"strings"
1110

1211
"github.com/kyleconroy/sqlc/internal/metadata"
@@ -25,33 +24,6 @@ type Parser interface {
2524
IsReservedKeyword(string) bool
2625
}
2726

28-
// copied over from gen.go
29-
func structName(name string) string {
30-
out := ""
31-
for _, p := range strings.Split(name, "_") {
32-
if p == "id" {
33-
out += "ID"
34-
} else {
35-
out += strings.Title(p)
36-
}
37-
}
38-
return out
39-
}
40-
41-
var identPattern = regexp.MustCompile("[^a-zA-Z0-9_]+")
42-
43-
func enumValueName(value string) string {
44-
name := ""
45-
id := strings.Replace(value, "-", "_", -1)
46-
id = strings.Replace(id, ":", "_", -1)
47-
id = strings.Replace(id, "/", "_", -1)
48-
id = identPattern.ReplaceAllString(id, "")
49-
for _, part := range strings.Split(id, "_") {
50-
name += strings.Title(part)
51-
}
52-
return name
53-
}
54-
5527
// end copypasta
5628
func (c *Compiler) parseCatalog(schemas []string) error {
5729
files, err := sqlpath.Glob(schemas)

Diff for: internal/engine/dolphin/utils.go

-58
Original file line numberDiff line numberDiff line change
@@ -7,64 +7,6 @@ import (
77
"github.com/kyleconroy/sqlc/internal/sql/ast"
88
)
99

10-
type nodeSearch struct {
11-
list []pcast.Node
12-
check func(pcast.Node) bool
13-
}
14-
15-
func (s *nodeSearch) Enter(n pcast.Node) (pcast.Node, bool) {
16-
if s.check(n) {
17-
s.list = append(s.list, n)
18-
}
19-
return n, false // skipChildren
20-
}
21-
22-
func (s *nodeSearch) Leave(n pcast.Node) (pcast.Node, bool) {
23-
return n, true // ok
24-
}
25-
26-
func collect(root pcast.Node, f func(pcast.Node) bool) []pcast.Node {
27-
if root == nil {
28-
return nil
29-
}
30-
ns := &nodeSearch{check: f}
31-
root.Accept(ns)
32-
return ns.list
33-
}
34-
35-
type nodeVisit struct {
36-
fn func(pcast.Node)
37-
}
38-
39-
func (s *nodeVisit) Enter(n pcast.Node) (pcast.Node, bool) {
40-
s.fn(n)
41-
return n, false // skipChildren
42-
}
43-
44-
func (s *nodeVisit) Leave(n pcast.Node) (pcast.Node, bool) {
45-
return n, true // ok
46-
}
47-
48-
func visit(root pcast.Node, f func(pcast.Node)) {
49-
if root == nil {
50-
return
51-
}
52-
ns := &nodeVisit{fn: f}
53-
root.Accept(ns)
54-
}
55-
56-
// Maybe not useful?
57-
func text(nodes []pcast.Node) []string {
58-
str := make([]string, len(nodes))
59-
for i := range nodes {
60-
if nodes[i] == nil {
61-
continue
62-
}
63-
str[i] = nodes[i].Text()
64-
}
65-
return str
66-
}
67-
6810
func parseTableName(n *pcast.TableName) *ast.TableName {
6911
return &ast.TableName{
7012
Schema: identifier(n.Schema.String()),

Diff for: internal/engine/postgresql/catalog.go

-9
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,3 @@ func NewCatalog() *catalog.Catalog {
1717
c.LoadExtension = loadExtension
1818
return c
1919
}
20-
21-
// The generated pg_catalog is very slow to compare because it has so
22-
// many entries. For testing, don't include it.
23-
func newTestCatalog() *catalog.Catalog {
24-
c := catalog.New("public")
25-
c.Schemas = append(c.Schemas, pgTemp())
26-
c.LoadExtension = loadExtension
27-
return c
28-
}

Diff for: internal/engine/postgresql/convert.go

-12
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,6 @@ func convertSlice(nodes []*pg.Node) *ast.List {
8484
return out
8585
}
8686

87-
func convertValuesList(l [][]*pg.Node) *ast.List {
88-
out := &ast.List{}
89-
for _, outer := range l {
90-
o := &ast.List{}
91-
for _, inner := range outer {
92-
o.Items = append(o.Items, convertNode(inner))
93-
}
94-
out.Items = append(out.Items, o)
95-
}
96-
return out
97-
}
98-
9987
func convert(node *pg.Node) (ast.Node, error) {
10088
return convertNode(node), nil
10189
}

Diff for: internal/engine/postgresql/parse.go

-4
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,6 @@ func parseColName(node *nodes.Node) (*ast.ColumnRef, *ast.TableName, error) {
136136
}
137137
}
138138

139-
func join(list *nodes.List, sep string) string {
140-
return strings.Join(stringSlice(list), sep)
141-
}
142-
143139
func joinNodes(list []*nodes.Node, sep string) string {
144140
return strings.Join(stringSliceFromNodes(list), sep)
145141
}

Diff for: internal/engine/postgresql/pg_temp.go

-19
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,9 @@
11
package postgresql
22

33
import (
4-
"github.com/kyleconroy/sqlc/internal/sql/ast"
54
"github.com/kyleconroy/sqlc/internal/sql/catalog"
65
)
76

87
func pgTemp() *catalog.Schema {
98
return &catalog.Schema{Name: "pg_temp"}
109
}
11-
12-
func typeName(name string) *ast.TypeName {
13-
return &ast.TypeName{Name: name}
14-
}
15-
16-
func argN(name string, n int) *catalog.Function {
17-
var args []*catalog.Argument
18-
for i := 0; i < n; i++ {
19-
args = append(args, &catalog.Argument{
20-
Type: &ast.TypeName{Name: "any"},
21-
})
22-
}
23-
return &catalog.Function{
24-
Name: name,
25-
Args: args,
26-
ReturnType: &ast.TypeName{Name: "any"},
27-
}
28-
}

Diff for: internal/engine/sqlite/utils.go

-4
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ type tableNamer interface {
1010
Schema_name() parser.ISchema_nameContext
1111
}
1212

13-
type multiselect interface {
14-
AllSelect_core() []parser.ISelect_coreContext
15-
}
16-
1713
func parseTableName(c tableNamer) *ast.TableName {
1814
name := ast.TableName{
1915
Name: c.Table_name().GetText(),

Diff for: internal/sql/ast/varatt_external.go

-12
This file was deleted.

Diff for: internal/sql/ast/vartag_external.go

-7
This file was deleted.

Diff for: internal/sql/catalog/func.go

-12
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,6 @@ func (f *Function) InArgs() []*Argument {
3939
return args
4040
}
4141

42-
func (c *Catalog) getFunc(rel *ast.FuncName, tns []*ast.TypeName) (*Function, int, error) {
43-
ns := rel.Schema
44-
if ns == "" {
45-
ns = c.DefaultSchema
46-
}
47-
s, err := c.getSchema(ns)
48-
if err != nil {
49-
return nil, -1, err
50-
}
51-
return s.getFunc(rel, tns)
52-
}
53-
5442
func (c *Catalog) createFunction(stmt *ast.CreateFunctionStmt) error {
5543
ns := stmt.Func.Schema
5644
if ns == "" {

0 commit comments

Comments
 (0)