Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scip_indexer/SCIPIndexer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,7 @@ class CFGTraversal final {
recv = core::cast_type_nonnull<core::AppliedType>(send->recv.type).klass;
}
if (recv.exists()) {
auto funSym = gs.lookupMethodSymbol(recv, send->fun);
auto funSym = recv.data(gs)->findMethodTransitive(gs, send->fun);
if (funSym.exists()) {
// TODO(varun): For arrays, hashes etc., try to identify if the function
// matches a known operator (e.g. []=), and emit an appropriate
Expand Down
6 changes: 4 additions & 2 deletions test/scip/testdata/alias.snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,19 @@
class X
# ^ definition [..] X#
alias_method :am_aaa, :aaa
# ^^^^^^^^^^^^ reference [..] Module#alias_method().
alias :a_aaa :aaa

def aaa
# ^^^ definition [..] X#aaa().
puts "AAA"
# ^^^^ reference [..] Kernel#puts().
end

def check_alias
# ^^^^^^^^^^^ definition [..] X#check_alias().
return [am_aaa, a_aaa]
# ^^^^^^ reference [..] X#am_aaa().
# ^^^^^ reference [..] X#a_aaa().
# ^^^^^^ reference [..] X#aaa().
# ^^^^^ reference [..] X#aaa().
end
end
1 change: 1 addition & 0 deletions test/scip/testdata/args.snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def args(x, y)
# ^ reference local 2~#2634721084
if x == 2
# ^ reference local 1~#2634721084
# ^^ reference [..] BasicObject#`==`().
z += y
# ^ reference local 3~#2634721084
# ^ reference (write) local 3~#2634721084
Expand Down
6 changes: 6 additions & 0 deletions test/scip/testdata/blocks_lambdas_procs.snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def lam
l1 = ->(x) {
# ^^ definition local 4~#1499497673
# ^^ reference [..] Kernel#
# ^^ reference [..] Kernel#lambda().
# ^ definition local 3~#1499497673
y += x
# ^ reference local 1~#1499497673
Expand All @@ -38,6 +39,7 @@ def lam
}
l2 = lambda { |x|
# ^^ definition local 6~#1499497673
# ^^^^^^ reference [..] Kernel#lambda().
# ^ definition local 5~#1499497673
y += x
# ^ reference (write) local 1~#1499497673
Expand All @@ -48,6 +50,7 @@ def lam
l3 = ->(x:) {
# ^^ definition local 9~#1499497673
# ^^ reference [..] Kernel#
# ^^ reference [..] Kernel#lambda().
# ^^ definition local 8~#1499497673
y += x
# ^ reference local 1~#1499497673
Expand All @@ -57,6 +60,7 @@ def lam
}
l4 = lambda { |x:|
# ^^ definition local 11~#1499497673
# ^^^^^^ reference [..] Kernel#lambda().
# ^^ definition local 10~#1499497673
y += x
# ^ reference local 1~#1499497673
Expand Down Expand Up @@ -95,6 +99,7 @@ def prc
}
p2 = proc { |x|
# ^^ definition local 6~#1283111692
# ^^^^ reference [..] Kernel#proc().
# ^ definition local 5~#1283111692
y += x
# ^ reference local 1~#1283111692
Expand All @@ -115,6 +120,7 @@ def prc
}
p4 = proc { |x:|
# ^^ definition local 11~#1283111692
# ^^^^ reference [..] Kernel#proc().
# ^^ definition local 10~#1283111692
y += x
# ^ reference local 1~#1283111692
Expand Down
7 changes: 5 additions & 2 deletions test/scip/testdata/cattr.snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
class CR
# ^^ definition [..] CR#
extend T::Sig
# ^^^^^^ reference [..] Kernel#extend().
cattr_reader :both, :foo
# ^^^^^ definition [..] CR#both().
# ^^^^^ definition [..] `<Class:CR>`#both().
Expand Down Expand Up @@ -32,6 +33,7 @@ def usages
class CW
# ^^ definition [..] CW#
extend T::Sig
# ^^^^^^ reference [..] Kernel#extend().
cattr_writer :both, :foo
# ^^^^^ definition [..] CW#`both=`().
# ^^^^^ definition [..] `<Class:CW>`#`both=`().
Expand Down Expand Up @@ -61,11 +63,12 @@ def usages
class CA
# ^^ definition [..] CA#
extend T::Sig
# ^^^^^^ reference [..] Kernel#extend().
cattr_accessor :both, :foo
# ^^^^^ definition [..] CA#`both=`().
# ^^^^^ definition [..] `<Class:CA>`#both().
# ^^^^^ definition [..] CA#both().
# ^^^^^ definition [..] `<Class:CA>`#`both=`().
# ^^^^^ definition [..] CA#both().
# ^^^^ definition [..] CA#foo().
# ^^^^ definition [..] `<Class:CA>`#foo().
# ^^^^ definition [..] CA#`foo=`().
Expand All @@ -81,9 +84,9 @@ class CA
# ^^^^ definition [..] CA#bar().
# ^^^^ definition [..] `<Class:CA>`#bar().
# ^^^^ definition [..] `<Class:CA>`#`bar=`().
# ^^^^^^^^^^^^^^^^^^^ definition [..] CA#no_instance_writer().
# ^^^^^^^^^^^^^^^^^^^ definition [..] `<Class:CA>`#no_instance_writer().
# ^^^^^^^^^^^^^^^^^^^ definition [..] `<Class:CA>`#`no_instance_writer=`().
# ^^^^^^^^^^^^^^^^^^^ definition [..] CA#no_instance_writer().

sig {void}
def usages
Expand Down
4 changes: 4 additions & 0 deletions test/scip/testdata/classes.snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ def f()
_a = C1.new
# ^^ definition local 1~#3809224601
# ^^ reference [..] C1#
# ^^^ reference [..] Class#new().
_b = M2::C2.new
# ^^ definition local 3~#3809224601
# ^^ reference [..] M2#
# ^^ reference [..] M2#C2#
# ^^^ reference [..] Class#new().
return
end
end
Expand All @@ -35,6 +37,7 @@ def local_class()
localClass = Class.new
# ^^^^^^^^^^ definition local 1~#552113551
# ^^^^^ reference [..] Class#
# ^^^ reference [..] Class#new().
# Technically, this is not supported by Sorbet (https://srb.help/3001),
# but make sure we don't crash or do something weird.
def localClass.myMethod()
Expand All @@ -49,6 +52,7 @@ def localClass.myMethod()
_m = localClass.myMethod
# ^^ definition local 4~#552113551
# ^^^^^^^^^^ reference local 1~#552113551
# ^^^^^^^^ reference [..] Object#myMethod().
return
end

Expand Down
11 changes: 11 additions & 0 deletions test/scip/testdata/def_delegator.snapshot.rb
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
# typed: true

require 'forwardable'
#^^^^^^^ reference [..] Kernel#require().

class MyArray1
# ^^^^^^^^ definition [..] MyArray1#
attr_accessor :inner_array
# ^^^^^^^^^^^ definition [..] MyArray1#inner_array().
# ^^^^^^^^^^^ definition [..] MyArray1#`inner_array=`().
extend Forwardable
# ^^^^^^ reference [..] Kernel#extend().
# ^^^^^^^^^^^ reference [..] Forwardable#
def_delegator :@inner_array, :[], :get_at_index
# ^^^^^^^^^^^^^ reference [..] Forwardable#def_delegator().
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference [..] Proc#
# ^^^^^^^^^^^^^ definition [..] MyArray1#get_at_index().
end

class MyArray2
# ^^^^^^^^ definition [..] MyArray2#
extend T::Sig
# ^^^^^^ reference [..] Kernel#extend().
attr_accessor :inner_array
# ^^^^^^^^^^^ definition [..] MyArray2#inner_array().
# ^^^^^^^^^^^ definition [..] MyArray2#`inner_array=`().
extend Forwardable
# ^^^^^^ reference [..] Kernel#extend().
# ^^^^^^^^^^^ reference [..] Forwardable#
def_delegator :@inner_array, :[], :get_at_index
# ^^^^^^^^^^^^^ reference [..] Forwardable#def_delegator().
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference [..] Proc#
# ^^^^^^^^^^^^^ definition [..] MyArray2#get_at_index().
end
Expand All @@ -33,8 +39,10 @@ class MyArray3
# ^^^^^^^^^^^ definition [..] MyArray3#inner_array().
# ^^^^^^^^^^^ definition [..] MyArray3#`inner_array=`().
extend Forwardable
# ^^^^^^ reference [..] Kernel#extend().
# ^^^^^^^^^^^ reference [..] Forwardable#
def_delegators :@inner_array, :size, :<<, :map
# ^^^^^^^^^^^^^^ reference [..] Forwardable#def_delegators().
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference [..] Proc#
# ^^^^^ definition [..] MyArray3#size().
# ^^^ definition [..] MyArray3#`<<`().
Expand All @@ -44,12 +52,15 @@ class MyArray3
class MyArray4
# ^^^^^^^^ definition [..] MyArray4#
extend T::Sig
# ^^^^^^ reference [..] Kernel#extend().
attr_accessor :inner_array
# ^^^^^^^^^^^ definition [..] MyArray4#inner_array().
# ^^^^^^^^^^^ definition [..] MyArray4#`inner_array=`().
extend Forwardable
# ^^^^^^ reference [..] Kernel#extend().
# ^^^^^^^^^^^ reference [..] Forwardable#
def_delegators :@inner_array, :size, :<<, :map
# ^^^^^^^^^^^^^^ reference [..] Forwardable#def_delegators().
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference [..] Proc#
# ^^^^^ definition [..] MyArray4#size().
# ^^^ definition [..] MyArray4#`<<`().
Expand Down
1 change: 1 addition & 0 deletions test/scip/testdata/delegate.snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
class MethodNameManipulation
# ^^^^^^^^^^^^^^^^^^^^^^ definition [..] MethodNameManipulation#
extend T::Sig
# ^^^^^^ reference [..] Kernel#extend().
delegate :ball, to: :thing, private: true, allow_nil: true
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reference [..] Proc#
# ^^^^^ definition [..] MethodNameManipulation#ball().
Expand Down
4 changes: 4 additions & 0 deletions test/scip/testdata/encrypted_prop.snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class Opus::DB::Model::Mixins::Encryptable::EncryptedValue < Chalk::ODM::Documen
class EncryptedProp
# ^^^^^^^^^^^^^ definition [..] EncryptedProp#
include T::Props
# ^^^^^^^ reference [..] Module#include().
def self.encrypted_prop(opts={}); end
# ^^^^^^^^^^^^^^ definition [..] `<Class:EncryptedProp>`#encrypted_prop().
encrypted_prop :foo
Expand All @@ -40,11 +41,14 @@ def f
# ^ definition [..] Object#f().
EncryptedProp.new.foo = "hello"
# ^^^^^^^^^^^^^ reference [..] EncryptedProp#
# ^^^ reference [..] Class#new().
# ^^^^^ reference [..] EncryptedProp#`foo=`().
EncryptedProp.new.foo = nil
# ^^^^^^^^^^^^^ reference [..] EncryptedProp#
# ^^^ reference [..] Class#new().
# ^^^^^ reference [..] EncryptedProp#`foo=`().
return EncryptedProp.new.encrypted_foo
# ^^^^^^^^^^^^^ reference [..] EncryptedProp#
# ^^^ reference [..] Class#new().
# ^^^^^^^^^^^^^ reference [..] EncryptedProp#encrypted_foo().
end
5 changes: 5 additions & 0 deletions test/scip/testdata/fields_and_attrs.snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ def m2
# ^^ definition [..] L#m2().
# FIXME: Missing references
self.class.y = self.class.x
# ^^^^^ reference [..] Object#class().
# ^^^^^ reference [..] Object#class().
return
end
end
Expand Down Expand Up @@ -85,6 +87,8 @@ def m3
# ^^ definition [..] N#m3().
# FIXME: Missing references
self.class.b = self.class.a
# ^^^^^ reference [..] Object#class().
# ^^^^^ reference [..] Object#class().
end
end

Expand Down Expand Up @@ -127,6 +131,7 @@ def useP
p = P.new
# ^ definition local 1~#2121829932
# ^ reference [..] P#
# ^^^ reference [..] Class#new().
p.a = p.r
# ^ reference local 1~#2121829932
# ^^^ reference [..] P#`a=`().
Expand Down
7 changes: 6 additions & 1 deletion test/scip/testdata/flatfile_dsl.snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@ class Flatfile < Record
# ^^^^^^^^ definition [..] Flatfile#
# ^^^^^^ definition [..] Record#
flatfile do
# ^^^^^^^^ reference [..] `<Class:Record>`#flatfile().
from 1..2, :foo
# ^^^^ reference [..] `<Class:Record>`#from().
# ^^^^ definition [..] Flatfile#`foo=`().
# ^^^^ definition [..] Flatfile#foo().
pattern(/A-Za-z/, :bar)
# ^^^^^^^ reference [..] `<Class:Record>`#pattern().
# ^^^^^^^^ reference [..] Regexp#
# ^^^^ definition [..] Flatfile#bar().
# ^^^^ definition [..] Flatfile#`bar=`().
# ^^^^ definition [..] Flatfile#bar().
field :baz
# ^^^^^ reference [..] `<Class:Record>`#field().
# ^^^^ definition [..] Flatfile#baz().
# ^^^^ definition [..] Flatfile#`baz=`().
end
Expand All @@ -32,6 +36,7 @@ class Flatfile < Record
t = Flatfile.new
#^ definition local 1~#119448696
# ^^^^^^^^ reference [..] Flatfile#
# ^^^ reference [..] Class#new().
t.foo = t.foo + 1
#^ reference local 1~#119448696
# ^^^^^ reference [..] Flatfile#`foo=`().
Expand Down
3 changes: 3 additions & 0 deletions test/scip/testdata/hoverdocs.snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class C1
# documentation
# | Class doc comment
extend T::Sig
# ^^^^^^ reference [..] Kernel#extend().

def m1
# ^^ definition [..] C1#m1().
Expand Down Expand Up @@ -171,6 +172,7 @@ module M2
# documentation
# | This module is nested inside M1
extend T::Sig
# ^^^^^^ reference [..] Kernel#extend().

# This method is inside M1::M2
sig { returns(T::Boolean) }
Expand Down Expand Up @@ -248,6 +250,7 @@ def f3 # undocumented global function
end

extend T::Sig
#^^^^^^ reference [..] Kernel#extend().
# ^ reference [..] T#
# ^^^ reference [..] T#Sig#

Expand Down
6 changes: 6 additions & 0 deletions test/scip/testdata/inheritance.snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
class Z1
# ^^ definition [..] Z1#
extend T::Sig
# ^^^^^^ reference [..] Kernel#extend().

sig { params(a: T::Boolean).void }
# ^^^^^^^ reference [..] T#Boolean.
Expand All @@ -27,6 +28,7 @@ def read_f?
class Z2
# ^^ definition [..] Z2#
extend T::Sig
# ^^^^^^ reference [..] Kernel#extend().

sig { returns(T::Boolean) }
# ^^^^^^^ reference [..] T#Boolean.
Expand All @@ -52,6 +54,7 @@ class Z3 < Z1
# ^^ definition [..] Z3#
# ^^ definition [..] Z1#
extend T::Sig
# ^^^^^^ reference [..] Kernel#extend().

sig { returns(T::Boolean) }
# ^^^^^^^ reference [..] T#Boolean.
Expand All @@ -66,17 +69,20 @@ class Z4 < Z3
# ^^ definition [..] Z4#
# ^^ definition [..] Z3#
extend T::Sig
# ^^^^^^ reference [..] Kernel#extend().

sig { params(a: T::Boolean).void }
# ^^^^^^^ reference [..] T#Boolean.
def write_f_plus_1(a)
# ^^^^^^^^^^^^^^ definition [..] Z4#write_f_plus_1().
# ^ definition local 1~#3337417690
write_f(a)
# ^^^^^^^ reference [..] Z1#write_f().
# ^ reference local 1~#3337417690
@f = read_f_plus_1?
# ^^ definition [..] Z4#`@f`.
# ^^^^^^^^^^^^^^^^^^^ reference [..] Z4#`@f`.
# ^^^^^^^^^^^^^^ reference [..] Z3#`read_f_plus_1?`().
end
end

Loading