-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ranking: standardize ctags kind names before scoring (#674)
SCIP ctags can output different kind names than universal-ctags (for example `typeAlias` instead of `talias`). This change makes sure we handle different names for the same kind. To do so, it refactors the logic so we first match strings to standard kinds, then decide how these are scored for each language. That way, you don't need to remember to cover all the possible kind names each time you adjust scoring for a new language. Also added basic tests for Ruby and Python to ensure we don't accidentally change the scoring.
- Loading branch information
1 parent
39e647c
commit ebf3aed
Showing
5 changed files
with
423 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
# v py.f def | ||
# v py.f.x def | ||
def f(x): | ||
|
||
# v py.f.g def | ||
def g(): | ||
y = 5 | ||
|
||
if True: | ||
# v py.f.x ref | ||
y = x # < "y" py.f.y def | ||
else: | ||
l1 = 3 # < "l1" py.f.l1 def | ||
|
||
# v py.f.i def | ||
for i in range(10): | ||
# v py.f.i ref | ||
l2 = i # < "l2" py.f.l2 def | ||
|
||
while False: | ||
l3 = 3 # < "l3" py.f.l3 def | ||
|
||
try: | ||
l4 = 3 # < "l4" py.f.l4 def | ||
# v py.f.e def | ||
except Exception as e: | ||
l5 = 3 # < "l5" py.f.l5 def | ||
# v py.f.e ref | ||
_ = e | ||
|
||
# vvvv py.f.file def | ||
with open("file.txt") as file: | ||
# vvvv py.f.file fef | ||
print(file) | ||
|
||
# vvv py.f.lam def | ||
# vvv py.f.lam ref | ||
_ = lambda lam: lam | ||
|
||
# v py.f.y ref | ||
# vv py.f.l1 ref | ||
# vv py.f.l2 ref | ||
# vv py.f.l3 ref | ||
# vv py.f.l4 ref | ||
# vv py.f.l5 ref | ||
# v py.f.g ref | ||
_ = y + l1 + l2 + l3 + l4 + l5 + g() | ||
|
||
# vvv recursive.foo ref,nodef | ||
recursive = recursive.foo | ||
|
||
|
||
# vv py.C1 def | ||
class C1: | ||
x = 5 # < "x" py.C1.x def | ||
|
||
def __init__(self, y): | ||
# v py.C1.y def | ||
self.y = y | ||
|
||
def f(self): | ||
# v py.C1.x ref | ||
# v py.C1.g ref | ||
self.x = self.g() | ||
|
||
# v py.C1.g def | ||
def g(self): | ||
# v py.C1.y ref | ||
return self.y | ||
|
||
|
||
class C2(C1): | ||
y = C1() | ||
|
||
def f(self, c1: C1): | ||
c = c1 | ||
# v py.C1.g ref | ||
# v py.C1.x ref | ||
return self.g() + c.x | ||
|
||
|
||
def newC1() -> C1: | ||
return C1() | ||
|
||
|
||
# v py.C1.x ref | ||
_ = newC1().x | ||
|
||
# v py.C1.x ref | ||
# v py.C1.x ref | ||
_ = C1().x + C2().y.x | ||
|
||
if False: | ||
f(3) # < "f" py.f ref |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
SOME_CONSTANT = 2.718 | ||
|
||
if true | ||
a = 1 | ||
elsif false | ||
b = 2 | ||
else | ||
c = 3 | ||
end | ||
|
||
(1..5).each do |counter| | ||
z = 3 | ||
end | ||
|
||
for counter in 1..5 | ||
y = 10 | ||
end | ||
|
||
counter = 1 | ||
while counter <= 5 do | ||
no = true | ||
counter += 1 | ||
end | ||
|
||
begin | ||
raise NoMemoryError, 'Z.' | ||
rescue NoMemoryError => exception_variable | ||
puts 'A', exception_variable | ||
rescue RuntimeError => other_exception_variable | ||
puts 'K' | ||
else | ||
puts 'L' | ||
ensure | ||
puts 'O' | ||
end | ||
|
||
grade = 42 | ||
case grade | ||
when 0.100 | ||
shouldntgetcaptured = true | ||
puts 'you got a grade i guess' | ||
end | ||
|
||
module MyModule | ||
def self.abc(base) | ||
end | ||
|
||
class MyClass | ||
def yay | ||
end | ||
|
||
def self.woo(base) | ||
end | ||
end | ||
end | ||
|
||
class Foo | ||
attr_accessor :bar | ||
attr_reader :baz | ||
attr_writer :qux | ||
end | ||
|
||
class Aliased | ||
def bar | ||
end | ||
|
||
alias_method :baz, :bar | ||
end | ||
|
||
class Parental | ||
def parental_func() | ||
end | ||
end | ||
|
||
class Composed | ||
include Parental | ||
end |
Oops, something went wrong.