Skip to content

Commit

Permalink
scoring: score methods and funcs the same (#666)
Browse files Browse the repository at this point in the history
I don't remember if there was a good reason to score methods and
functions differently, but I have found examples where the difference
between the two scores causes the better result to be lower ranked,
although it has better file-order boost.

Scip-ctags distinguishes between methods and functions, universal-ctags
does not.

Test plan:
updated score tests
  • Loading branch information
stefanhengl authored Oct 20, 2023
1 parent d3fc0dc commit c869a24
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
13 changes: 12 additions & 1 deletion build/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1015,13 +1015,24 @@ type aStruct struct {}
`),
query: &query.Substring{Content: true, Pattern: "aStruct"},
wantLanguage: "Go",
// 7000 (full base match) + 900 (Go interface) + 500 (word) + 10 (file order)
// 7000 (full base match) + 900 (Go struct) + 500 (word) + 10 (file order)
wantScore: 8410,
},
{
fileName: "src/net/http/client.go",
content: []byte(`
package http
func aFunc() bool {}
`),
query: &query.Substring{Content: true, Pattern: "aFunc"},
wantLanguage: "Go",
// 7000 (full base match) + 800 (Go function) + 500 (word) + 10 (file order)
wantScore: 8310,
},
{
fileName: "src/net/http/client.go",
content: []byte(`
package http
func Get() {
panic("")
}
Expand Down
8 changes: 2 additions & 6 deletions contentprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -669,10 +669,8 @@ func scoreKind(language string, kind string) float64 {
factor = 9
case "interface":
factor = 8
case "function", "func":
case "function", "func", "method":
factor = 7
case "method":
factor = 6
case "member", "field":
factor = 5.5
case "constant", "const":
Expand Down Expand Up @@ -730,9 +728,7 @@ func scoreKind(language string, kind string) float64 {
// for each case a description of the fields in ctags in the comment
case "type": // interface struct talias
factor = 10
case "method": // methodSpec
factor = 8.5
case "function": // func
case "method", "function": // methodSpec
factor = 8
case "variable": // var member
factor = 7
Expand Down

0 comments on commit c869a24

Please sign in to comment.