From 1afe3401b30bc4b2cf1712bea2c2bc2b76983631 Mon Sep 17 00:00:00 2001 From: Stefan Hengl Date: Thu, 19 Oct 2023 17:40:07 +0200 Subject: [PATCH] scoring: score methods and funcs the same 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 --- build/e2e_test.go | 13 ++++++++++++- contentprovider.go | 8 ++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/build/e2e_test.go b/build/e2e_test.go index 0d96e2550..b2f25b4e6 100644 --- a/build/e2e_test.go +++ b/build/e2e_test.go @@ -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("") } diff --git a/contentprovider.go b/contentprovider.go index 5f27d2050..edce7e16a 100644 --- a/contentprovider.go +++ b/contentprovider.go @@ -670,10 +670,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": @@ -731,9 +729,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