Permalink
Browse files

Big refactoring, CamelCase -> words_with_underscores.

Also some minor code reorganizations.
  • Loading branch information...
1 parent 956f4c2 commit fff16d190ba5ea4eff9c364402e150377a09ee5a @nsf committed Feb 24, 2012
Showing with 1,371 additions and 1,417 deletions.
  1. +30 −30 apropos.go
  2. +188 −190 autocompletecontext.go
  3. +132 −132 autocompletefile.go
  4. +53 −74 config.go
  5. +386 −398 decl.go
  6. +72 −72 declcache.go
  7. +96 −97 gocode.go
  8. +32 −32 goremote/goremote.go
  9. +3 −3 os_posix.go
  10. +2 −2 os_windows.go
  11. +197 −195 package.go
  12. +33 −30 ripper.go
  13. +46 −46 rpc.go
  14. +20 −20 scope.go
  15. +81 −96 server.go
  16. 0 {testing → testdata}/DESC
  17. 0 {testing → testdata}/README
  18. 0 {testing → testdata}/all.bash
  19. 0 {testing → testdata}/run.py
  20. 0 {testing → testdata}/run.rb
  21. 0 {testing → testdata}/test.0001/cursor.47
  22. 0 {testing/test.0023 → testdata/test.0001}/out.expected
  23. 0 {testing → testdata}/test.0001/test.go
  24. 0 {testing → testdata}/test.0002/cursor.105
  25. 0 {testing → testdata}/test.0002/out.expected
  26. 0 {testing → testdata}/test.0002/test.go
  27. 0 {testing → testdata}/test.0003/cursor.552
  28. 0 {testing/test.0021 → testdata/test.0003}/out.expected
  29. 0 {testing → testdata}/test.0003/test.go
  30. 0 {testing → testdata}/test.0004/cursor.1348
  31. 0 {testing → testdata}/test.0004/out.expected
  32. 0 {testing → testdata}/test.0004/test.go
  33. 0 {testing/test.0006 → testdata/test.0005}/b.go
  34. 0 {testing → testdata}/test.0005/cursor.327
  35. 0 {testing → testdata}/test.0005/out.expected
  36. 0 {testing → testdata}/test.0005/test.go
  37. 0 {testing/test.0005 → testdata/test.0006}/b.go
  38. 0 {testing → testdata}/test.0006/cursor.286
  39. 0 {testing → testdata}/test.0006/out.expected
  40. 0 {testing → testdata}/test.0006/test.go
  41. 0 {testing → testdata}/test.0007/cursor.58
  42. 0 {testing → testdata}/test.0007/out.expected
  43. 0 {testing → testdata}/test.0007/test.go
  44. 0 {testing → testdata}/test.0008/cursor.120
  45. 0 {testing → testdata}/test.0008/out.expected
  46. 0 {testing → testdata}/test.0008/test.go
  47. 0 {testing → testdata}/test.0009/cursor.126
  48. 0 {testing/test.0020 → testdata/test.0009}/out.expected
  49. 0 {testing → testdata}/test.0009/test.go
  50. 0 {testing → testdata}/test.0010/cursor.104
  51. 0 {testing → testdata}/test.0010/out.expected
  52. 0 {testing → testdata}/test.0010/test.go
  53. 0 {testing → testdata}/test.0011/cursor.76
  54. 0 {testing → testdata}/test.0011/out.expected
  55. 0 {testing → testdata}/test.0011/test.go
  56. 0 {testing → testdata}/test.0012/cursor.114
  57. 0 {testing → testdata}/test.0012/out.expected
  58. 0 {testing → testdata}/test.0012/test.go
  59. 0 {testing → testdata}/test.0013/cursor.359
  60. 0 {testing → testdata}/test.0013/out.expected
  61. 0 {testing → testdata}/test.0013/test.go
  62. 0 {testing → testdata}/test.0014/cursor.191
  63. 0 {testing → testdata}/test.0014/out.expected
  64. 0 {testing → testdata}/test.0014/test.go
  65. 0 {testing → testdata}/test.0015/cursor.130
  66. 0 {testing → testdata}/test.0015/out.expected
  67. 0 {testing → testdata}/test.0015/test.go
  68. 0 {testing → testdata}/test.0016/cursor.122
  69. 0 {testing → testdata}/test.0016/out.expected
  70. 0 {testing → testdata}/test.0016/test.go
  71. 0 {testing → testdata}/test.0017/cursor.70
  72. 0 {testing → testdata}/test.0017/out.expected
  73. 0 {testing → testdata}/test.0017/test.go
  74. 0 {testing → testdata}/test.0018/cursor.355
  75. 0 {testing → testdata}/test.0018/out.expected
  76. 0 {testing → testdata}/test.0018/test.go
  77. 0 {testing → testdata}/test.0019/cursor.72
  78. 0 {testing → testdata}/test.0019/out.expected
  79. 0 {testing → testdata}/test.0019/test.go
  80. 0 {testing → testdata}/test.0020/cursor.174
  81. 0 {testing/test.0009 → testdata/test.0020}/out.expected
  82. 0 {testing → testdata}/test.0020/test.go
  83. 0 {testing/test.0034 → testdata/test.0021}/cursor.82
  84. 0 {testing/test.0003 → testdata/test.0021}/out.expected
  85. 0 {testing → testdata}/test.0021/test.go
  86. 0 {testing → testdata}/test.0022/cursor.79
  87. 0 {testing → testdata}/test.0022/out.expected
  88. 0 {testing → testdata}/test.0022/test.go
  89. 0 {testing → testdata}/test.0023/cursor.88
  90. 0 {testing/test.0001 → testdata/test.0023}/out.expected
  91. 0 {testing → testdata}/test.0023/test.go
  92. 0 {testing → testdata}/test.0024/cursor.71
  93. 0 {testing → testdata}/test.0024/out.expected
  94. 0 {testing → testdata}/test.0024/test.go
  95. 0 {testing → testdata}/test.0025/cursor.53
  96. 0 {testing → testdata}/test.0025/out.expected
  97. 0 {testing → testdata}/test.0025/test.go
  98. 0 {testing → testdata}/test.0026/cursor.164
  99. 0 {testing → testdata}/test.0026/out.expected
  100. 0 {testing → testdata}/test.0026/test.go
  101. 0 {testing → testdata}/test.0027/cursor.84
  102. 0 {testing → testdata}/test.0027/out.expected
  103. 0 {testing → testdata}/test.0027/test.go
  104. 0 {testing → testdata}/test.0028/cursor.129
  105. 0 {testing → testdata}/test.0028/out.expected
  106. 0 {testing → testdata}/test.0028/test.go
  107. 0 {testing → testdata}/test.0029/cursor.62
  108. 0 {testing → testdata}/test.0029/out.expected
  109. 0 {testing → testdata}/test.0029/test.go
  110. 0 {testing → testdata}/test.0030/cursor.85
  111. 0 {testing → testdata}/test.0030/out.expected
  112. 0 {testing → testdata}/test.0030/test.go
  113. 0 {testing → testdata}/test.0031/cursor.80
  114. 0 {testing → testdata}/test.0031/out.expected
  115. 0 {testing → testdata}/test.0031/test.go
  116. 0 {testing → testdata}/test.0032/cursor.1991
  117. 0 {testing → testdata}/test.0032/out.expected
  118. 0 {testing → testdata}/test.0032/test.go
  119. 0 {testing → testdata}/test.0033/cursor.138
  120. 0 {testing → testdata}/test.0033/out.expected
  121. 0 {testing → testdata}/test.0033/test.go
  122. 0 {testing/test.0021 → testdata/test.0034}/cursor.82
  123. 0 {testing → testdata}/test.0034/out.expected
  124. 0 {testing → testdata}/test.0034/test.go
  125. 0 {testing → testdata}/test.0035/cursor.91
  126. 0 {testing → testdata}/test.0035/out.expected
  127. 0 {testing → testdata}/test.0035/test.go
View
@@ -6,12 +6,12 @@ import (
"unicode/utf8"
)
-type DeclApropos struct {
- Decl *Decl
- Partial string
+type decl_apropos struct {
+ decl *decl
+ partial string
}
-func utf8MoveBackwards(file []byte, cursor int) int {
+func utf8_move_backwards(file []byte, cursor int) int {
for {
cursor--
if cursor <= 0 {
@@ -24,32 +24,32 @@ func utf8MoveBackwards(file []byte, cursor int) int {
return 0
}
-func isIdent(r rune) bool {
+func is_ident(r rune) bool {
return unicode.IsDigit(r) || unicode.IsLetter(r) || r == '_'
}
-func skipIdent(file []byte, cursor int) int {
+func skip_ident(file []byte, cursor int) int {
for {
letter, _ := utf8.DecodeRune(file[cursor:])
- if !isIdent(letter) {
+ if !is_ident(letter) {
return cursor
}
- cursor = utf8MoveBackwards(file, cursor)
+ cursor = utf8_move_backwards(file, cursor)
if cursor <= 0 {
return 0
}
}
return 0
}
-var pairs = map[byte]byte{
+var g_bracket_pairs = map[byte]byte{
')': '(',
']': '[',
}
-func skipToPair(file []byte, cursor int) int {
+func skip_to_pair(file []byte, cursor int) int {
right := file[cursor]
- left := pairs[file[cursor]]
+ left := g_bracket_pairs[file[cursor]]
balance := 1
for balance != 0 {
cursor--
@@ -66,7 +66,7 @@ func skipToPair(file []byte, cursor int) int {
return cursor
}
-func findExpr(file []byte) []byte {
+func find_expr(file []byte) []byte {
const (
LAST_NONE = iota
LAST_DOT
@@ -75,24 +75,24 @@ func findExpr(file []byte) []byte {
)
last := LAST_NONE
cursor := len(file)
- cursor = utf8MoveBackwards(file, cursor)
+ cursor = utf8_move_backwards(file, cursor)
loop:
for {
c := file[cursor]
letter, _ := utf8.DecodeRune(file[cursor:])
switch c {
case '.':
- cursor = utf8MoveBackwards(file, cursor)
+ cursor = utf8_move_backwards(file, cursor)
last = LAST_DOT
case ')', ']':
if last == LAST_IDENT {
break loop
}
- cursor = utf8MoveBackwards(file, skipToPair(file, cursor))
+ cursor = utf8_move_backwards(file, skip_to_pair(file, cursor))
last = LAST_PAREN
default:
- if isIdent(letter) {
- cursor = skipIdent(file, cursor)
+ if is_ident(letter) {
+ cursor = skip_ident(file, cursor)
last = LAST_IDENT
} else {
break loop
@@ -102,49 +102,49 @@ loop:
return file[cursor+1:]
}
-func (c *AutoCompleteContext) deduceExpr(file []byte, partial string) *DeclApropos {
- e := string(findExpr(file))
+func (c *auto_complete_context) deduce_expr(file []byte, partial string) *decl_apropos {
+ e := string(find_expr(file))
expr, err := parser.ParseExpr(e)
if err != nil {
return nil
}
- typedecl := exprToDecl(expr, c.current.scope)
+ typedecl := expr_to_decl(expr, c.current.scope)
if typedecl != nil {
- return &DeclApropos{typedecl, partial}
+ return &decl_apropos{typedecl, partial}
}
return nil
}
-func (c *AutoCompleteContext) deduceDecl(file []byte, cursor int) *DeclApropos {
+func (c *auto_complete_context) deduce_decl(file []byte, cursor int) *decl_apropos {
orig := cursor
if cursor < 0 {
return nil
}
if cursor == 0 {
- return &DeclApropos{nil, ""}
+ return &decl_apropos{nil, ""}
}
// figure out what is just before the cursor
- cursor = utf8MoveBackwards(file, cursor)
+ cursor = utf8_move_backwards(file, cursor)
if file[cursor] == '.' {
// we're '<whatever>.'
// figure out decl, Parital is ""
- return c.deduceExpr(file[:cursor], "")
+ return c.deduce_expr(file[:cursor], "")
} else {
letter, _ := utf8.DecodeRune(file[cursor:])
- if isIdent(letter) {
+ if is_ident(letter) {
// we're '<whatever>.<ident>'
// parse <ident> as Partial and figure out decl
- cursor = skipIdent(file, cursor)
+ cursor = skip_ident(file, cursor)
partial := string(file[cursor+1 : orig])
if file[cursor] == '.' {
- return c.deduceExpr(file[:cursor], partial)
+ return c.deduce_expr(file[:cursor], partial)
} else {
- return &DeclApropos{nil, partial}
+ return &decl_apropos{nil, partial}
}
}
}
- return &DeclApropos{nil, ""}
+ return &decl_apropos{nil, ""}
}
Oops, something went wrong.

2 comments on commit fff16d1

@nsf
Owner
nsf commented on fff16d1 Mar 9, 2012

no reason, I was boring

@nsf
Owner
nsf commented on fff16d1 Mar 9, 2012

I simply hate the way camelCaseWithFirstLowerCaseLetter looks. It's just so broken.. I think CamelCase for exported and lower_case_letters_with_underscore for unexported look better.

Please sign in to comment.