Skip to content

Commit 956f4c2

Browse files
committed
Merge branch 'for-nsf' of git://github.com/DanielMorsing/gocode
2 parents cb4bc04 + afeb82d commit 956f4c2

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

gocode.go

+12-13
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"os"
1010
"path/filepath"
1111
"strconv"
12+
"strings"
1213
"time"
1314
"unicode/utf8"
1415
)
@@ -37,11 +38,8 @@ func filterOutShebang(data []byte) ([]byte, int) {
3738
// Formatter interfaces
3839
//-------------------------------------------------------------------------
3940

40-
type FormatterEmpty interface {
41+
type Formatter interface {
4142
WriteEmpty()
42-
}
43-
44-
type FormatterCandidates interface {
4543
WriteCandidates(names, types, classes []string, num int)
4644
}
4745

@@ -82,7 +80,7 @@ func (*VimFormatter) WriteCandidates(names, types, classes []string, num int) {
8280
word := names[i]
8381
if classes[i] == "func" {
8482
word += "("
85-
if len(types[i]) == 6 {
83+
if strings.HasPrefix(types[i], "func()") {
8684
word += ")"
8785
}
8886
}
@@ -106,6 +104,9 @@ func (*VimFormatter) WriteCandidates(names, types, classes []string, num int) {
106104

107105
type EmacsFormatter struct{}
108106

107+
func (*EmacsFormatter) WriteEmpty() {
108+
}
109+
109110
func (*EmacsFormatter) WriteCandidates(names, types, classes []string, num int) {
110111
for i := 0; i < len(names); i++ {
111112
name := names[i]
@@ -123,6 +124,9 @@ func (*EmacsFormatter) WriteCandidates(names, types, classes []string, num int)
123124

124125
type CSVFormatter struct{}
125126

127+
func (*CSVFormatter) WriteEmpty() {
128+
}
129+
126130
func (*CSVFormatter) WriteCandidates(names, types, classes []string, num int) {
127131
for i := 0; i < len(names); i++ {
128132
fmt.Printf("%s,,%s,,%s\n", classes[i], names[i], types[i])
@@ -153,7 +157,7 @@ func (*JSONFormatter) WriteCandidates(names, types, classes []string, num int) {
153157

154158
//-------------------------------------------------------------------------
155159

156-
func getFormatter() interface{} {
160+
func getFormatter() Formatter {
157161
switch *format {
158162
case "vim":
159163
return new(VimFormatter)
@@ -260,15 +264,10 @@ func cmdAutoComplete(c *rpc.Client) {
260264
formatter := getFormatter()
261265
names, types, classes, partial := Client_AutoComplete(c, file, filename, cursor)
262266
if names == nil {
263-
if f, ok := formatter.(FormatterEmpty); ok {
264-
f.WriteEmpty()
265-
}
267+
formatter.WriteEmpty()
266268
return
267269
}
268-
269-
if f, ok := formatter.(FormatterCandidates); ok {
270-
f.WriteCandidates(names, types, classes, partial)
271-
}
270+
formatter.WriteCandidates(names, types, classes, partial)
272271
}
273272

274273
func cmdClose(c *rpc.Client) {

0 commit comments

Comments
 (0)