Skip to content

Commit fff16d1

Browse files
committed
Big refactoring, CamelCase -> words_with_underscores.
Also some minor code reorganizations.
1 parent 956f4c2 commit fff16d1

File tree

127 files changed

+1371
-1417
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+1371
-1417
lines changed

apropos.go

+30-30
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import (
66
"unicode/utf8"
77
)
88

9-
type DeclApropos struct {
10-
Decl *Decl
11-
Partial string
9+
type decl_apropos struct {
10+
decl *decl
11+
partial string
1212
}
1313

14-
func utf8MoveBackwards(file []byte, cursor int) int {
14+
func utf8_move_backwards(file []byte, cursor int) int {
1515
for {
1616
cursor--
1717
if cursor <= 0 {
@@ -24,32 +24,32 @@ func utf8MoveBackwards(file []byte, cursor int) int {
2424
return 0
2525
}
2626

27-
func isIdent(r rune) bool {
27+
func is_ident(r rune) bool {
2828
return unicode.IsDigit(r) || unicode.IsLetter(r) || r == '_'
2929
}
3030

31-
func skipIdent(file []byte, cursor int) int {
31+
func skip_ident(file []byte, cursor int) int {
3232
for {
3333
letter, _ := utf8.DecodeRune(file[cursor:])
34-
if !isIdent(letter) {
34+
if !is_ident(letter) {
3535
return cursor
3636
}
37-
cursor = utf8MoveBackwards(file, cursor)
37+
cursor = utf8_move_backwards(file, cursor)
3838
if cursor <= 0 {
3939
return 0
4040
}
4141
}
4242
return 0
4343
}
4444

45-
var pairs = map[byte]byte{
45+
var g_bracket_pairs = map[byte]byte{
4646
')': '(',
4747
']': '[',
4848
}
4949

50-
func skipToPair(file []byte, cursor int) int {
50+
func skip_to_pair(file []byte, cursor int) int {
5151
right := file[cursor]
52-
left := pairs[file[cursor]]
52+
left := g_bracket_pairs[file[cursor]]
5353
balance := 1
5454
for balance != 0 {
5555
cursor--
@@ -66,7 +66,7 @@ func skipToPair(file []byte, cursor int) int {
6666
return cursor
6767
}
6868

69-
func findExpr(file []byte) []byte {
69+
func find_expr(file []byte) []byte {
7070
const (
7171
LAST_NONE = iota
7272
LAST_DOT
@@ -75,24 +75,24 @@ func findExpr(file []byte) []byte {
7575
)
7676
last := LAST_NONE
7777
cursor := len(file)
78-
cursor = utf8MoveBackwards(file, cursor)
78+
cursor = utf8_move_backwards(file, cursor)
7979
loop:
8080
for {
8181
c := file[cursor]
8282
letter, _ := utf8.DecodeRune(file[cursor:])
8383
switch c {
8484
case '.':
85-
cursor = utf8MoveBackwards(file, cursor)
85+
cursor = utf8_move_backwards(file, cursor)
8686
last = LAST_DOT
8787
case ')', ']':
8888
if last == LAST_IDENT {
8989
break loop
9090
}
91-
cursor = utf8MoveBackwards(file, skipToPair(file, cursor))
91+
cursor = utf8_move_backwards(file, skip_to_pair(file, cursor))
9292
last = LAST_PAREN
9393
default:
94-
if isIdent(letter) {
95-
cursor = skipIdent(file, cursor)
94+
if is_ident(letter) {
95+
cursor = skip_ident(file, cursor)
9696
last = LAST_IDENT
9797
} else {
9898
break loop
@@ -102,49 +102,49 @@ loop:
102102
return file[cursor+1:]
103103
}
104104

105-
func (c *AutoCompleteContext) deduceExpr(file []byte, partial string) *DeclApropos {
106-
e := string(findExpr(file))
105+
func (c *auto_complete_context) deduce_expr(file []byte, partial string) *decl_apropos {
106+
e := string(find_expr(file))
107107
expr, err := parser.ParseExpr(e)
108108
if err != nil {
109109
return nil
110110
}
111-
typedecl := exprToDecl(expr, c.current.scope)
111+
typedecl := expr_to_decl(expr, c.current.scope)
112112
if typedecl != nil {
113-
return &DeclApropos{typedecl, partial}
113+
return &decl_apropos{typedecl, partial}
114114
}
115115
return nil
116116
}
117117

118-
func (c *AutoCompleteContext) deduceDecl(file []byte, cursor int) *DeclApropos {
118+
func (c *auto_complete_context) deduce_decl(file []byte, cursor int) *decl_apropos {
119119
orig := cursor
120120

121121
if cursor < 0 {
122122
return nil
123123
}
124124
if cursor == 0 {
125-
return &DeclApropos{nil, ""}
125+
return &decl_apropos{nil, ""}
126126
}
127127

128128
// figure out what is just before the cursor
129-
cursor = utf8MoveBackwards(file, cursor)
129+
cursor = utf8_move_backwards(file, cursor)
130130
if file[cursor] == '.' {
131131
// we're '<whatever>.'
132132
// figure out decl, Parital is ""
133-
return c.deduceExpr(file[:cursor], "")
133+
return c.deduce_expr(file[:cursor], "")
134134
} else {
135135
letter, _ := utf8.DecodeRune(file[cursor:])
136-
if isIdent(letter) {
136+
if is_ident(letter) {
137137
// we're '<whatever>.<ident>'
138138
// parse <ident> as Partial and figure out decl
139-
cursor = skipIdent(file, cursor)
139+
cursor = skip_ident(file, cursor)
140140
partial := string(file[cursor+1 : orig])
141141
if file[cursor] == '.' {
142-
return c.deduceExpr(file[:cursor], partial)
142+
return c.deduce_expr(file[:cursor], partial)
143143
} else {
144-
return &DeclApropos{nil, partial}
144+
return &decl_apropos{nil, partial}
145145
}
146146
}
147147
}
148148

149-
return &DeclApropos{nil, ""}
149+
return &decl_apropos{nil, ""}
150150
}

0 commit comments

Comments
 (0)