Skip to content

Commit 1223666

Browse files
authored
Merge pull request #53 from ReconfigureIO/feature/empty-funcs
Add support for empty func definitions.
2 parents a30b3f8 + 1fb9d9c commit 1223666

File tree

5 files changed

+81
-1
lines changed

5 files changed

+81
-1
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fmt:
1919
go fmt -x ./...
2020

2121
test: fmt
22-
go test -v $$(go list ./... | grep -v /vendor/ | grep -v /cmd/)
22+
go test -v $$(go list ./... | grep -v /vendor/ | grep -v /cmd/ | grep -v /fixtures/)
2323

2424
PACKAGES := $(shell find ./* -type d | grep -v vendor)
2525

fixtures/packages/emptyfunc/empty.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package main
2+
3+
func foo()
4+
5+
func main() {
6+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
{
2+
"kind" : "file",
3+
"name" : {
4+
"position" : {
5+
"filename" : "fixtures/packages/emptyfunc/empty.go",
6+
"offset" : 8,
7+
"line" : 1,
8+
"column" : 9
9+
},
10+
"value" : "main",
11+
"kind" : "ident"
12+
},
13+
"imports" : [],
14+
"declarations" : [
15+
{
16+
"type" : "function",
17+
"position" : {
18+
"filename" : "fixtures/packages/emptyfunc/empty.go",
19+
"column" : 1,
20+
"line" : 3,
21+
"offset" : 14
22+
},
23+
"body" : null,
24+
"comments" : [],
25+
"name" : {
26+
"position" : {
27+
"column" : 6,
28+
"line" : 3,
29+
"offset" : 19,
30+
"filename" : "fixtures/packages/emptyfunc/empty.go"
31+
},
32+
"kind" : "ident",
33+
"value" : "foo"
34+
},
35+
"params" : [],
36+
"kind" : "decl",
37+
"results" : null
38+
},
39+
{
40+
"comments" : [],
41+
"params" : [],
42+
"kind" : "decl",
43+
"name" : {
44+
"position" : {
45+
"filename" : "fixtures/packages/emptyfunc/empty.go",
46+
"offset" : 31,
47+
"line" : 5,
48+
"column" : 6
49+
},
50+
"value" : "main",
51+
"kind" : "ident"
52+
},
53+
"results" : null,
54+
"type" : "function",
55+
"position" : {
56+
"filename" : "fixtures/packages/emptyfunc/empty.go",
57+
"column" : 1,
58+
"line" : 5,
59+
"offset" : 26
60+
},
61+
"body" : []
62+
}
63+
],
64+
"all-comments" : [],
65+
"comments" : []
66+
}

goblin.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -905,6 +905,9 @@ func DumpStmt(s ast.Stmt, fset *token.FileSet) interface{} {
905905
}
906906

907907
func DumpBlock(b *ast.BlockStmt, fset *token.FileSet) []interface{} {
908+
if b == nil {
909+
return nil
910+
}
908911
results := make([]interface{}, len(b.List))
909912
for i, v := range b.List {
910913
results[i] = DumpStmt(v, fset)

goblin_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,11 @@ func TestPackageFixtures(t *testing.T) {
7171
"fixtures/packages/interface_type/interface.go",
7272
"fixtures/packages/interface_type/interface.json",
7373
},
74+
Fixture{
75+
"empty function",
76+
"fixtures/packages/emptyfunc/empty.go",
77+
"fixtures/packages/emptyfunc/empty.json",
78+
},
7479
}
7580

7681
for _, fix := range fixtures {

0 commit comments

Comments
 (0)