From 645145ed062d20a9fbb7e0bd7fc22bdfb619a950 Mon Sep 17 00:00:00 2001 From: Varun Gandhi Date: Mon, 18 Nov 2024 14:58:48 +0800 Subject: [PATCH 1/2] fix: Correctly emit occurrences for tests --- scip_indexer/SCIPIndexer.cc | 29 +++++++++++++++++++++++- test/scip/testdata/minitest.rb | 4 +++- test/scip/testdata/minitest.snapshot.rb | 23 ++++++++++++++++++- test/scip/testdata/test_case.snapshot.rb | 10 ++++++++ 4 files changed, 63 insertions(+), 3 deletions(-) diff --git a/scip_indexer/SCIPIndexer.cc b/scip_indexer/SCIPIndexer.cc index 614f2dc3d..d3dafd0af 100644 --- a/scip_indexer/SCIPIndexer.cc +++ b/scip_indexer/SCIPIndexer.cc @@ -1270,6 +1270,30 @@ struct IndexWriter { using LocalSymbolTable = UnorderedMap; +bool isSyntheticMethodWithHandwrittenBody(const core::GlobalState &gs, core::NameRef name) { + // The list of names is taken from: + // 1. The test case rewriter/minitest.rb. + // 2. https://ruby-doc.org/stdlib-3.0.1/libdoc/minitest/rdoc/Minitest/Spec/DSL/InstanceMethods.html + // 3. The code in Minitest.cc + // 4. The code in TestCase.cc + if (name == core::NameRef::noName()) { + return false; + } + bool special = name == core::Names::describe() || name == core::Names::it() || name == core::Names::before() || + name == core::Names::beforeAngles() || name == core::Names::after() || + name == core::Names::afterAngles() || name == core::Names::testEach() || + name == core::Names::let() || name == core::Names::test() || name == core::Names::setup() || + name == core::Names::teardown(); + if (special) { + return true; + } + if (name.kind() == core::NameKind::UTF8) { + auto nameText = name.dataUtf8(gs)->utf8; + return absl::StartsWith(nameText, "`(). - outside_method + x = outside_method +# ^ definition local 1~#1914741329 +# ^^^^^^^^^^^^^^ reference [..] MyTest#outside_method(). + x = x + 1 +# ^ reference (write) local 1~#1914741329 +# ^ reference local 1~#1914741329 + return end it "allows constants inside of IT" do @@ -16,6 +22,7 @@ def outside_method # ^^^^^ definition [..] MyTest#CONST. # ^^^^^^^^^^ reference [..] Kernel# # ^^^^^^^^^^ reference [..] Kernel#raise(). +# ^^^^^^^^^^ reference [..] Module# end it "allows let-ed constants inside of IT" do @@ -24,6 +31,8 @@ def outside_method # ^^ definition [..] MyTest#C2. # ^^^^^^^^^^^^^^^^^^^^^^^ reference [..] Kernel# # ^^^^^^^^^^^^^^^^^^^^^^^ reference [..] Kernel#raise(). +# ^^^^^^^^^^^^^^^^^^^^^^^ reference [..] Module# +# ^^^^^^^ definition local 1~#95163902 # ^^^^^^^ definition local 3~#119448696 # ^^^^^^^ reference [..] Integer# end @@ -36,6 +45,8 @@ def outside_method # ^^^ reference [..] Mod# # ^ reference [..] Mod#C# C3.new +# ^^ reference [..] MyTest#C3. +# ^^^ reference [..] Class#new(). end describe "some inner tests" do @@ -48,7 +59,9 @@ def inside_method it "works inside" do # ^^^^^^^^^^^^^^ definition [..] MyTest#``#``(). outside_method +# ^^^^^^^^^^^^^^ reference [..] MyTest#outside_method(). inside_method +# ^^^^^^^^^^^^^ reference [..] MyTest#``#inside_method(). end end @@ -58,13 +71,21 @@ def instance_helper; end before do # ^^^^^^ definition [..] MyTest#``(). @foo = T.let(3, Integer) +# ^^^^ definition [..] MyTest#`@foo`. +# ^^^^^^^ definition local 1~#2938098190 +# ^^^^^^^ reference [..] Integer# instance_helper +# ^^^^^^^^^^^^^^^ reference [..] MyTest#instance_helper(). end it 'can read foo' do # ^^^^^^^^^^^^^^ definition [..] MyTest#``(). T.assert_type!(@foo, Integer) +# ^^^^ reference [..] MyTest#`@foo`. +# ^^^^^^^ definition local 1~#3909275672 +# ^^^^^^^ reference [..] Integer# instance_helper +# ^^^^^^^^^^^^^^^ reference [..] MyTest#instance_helper(). end def self.random_method diff --git a/test/scip/testdata/test_case.snapshot.rb b/test/scip/testdata/test_case.snapshot.rb index 2a7601792..d9325dd70 100644 --- a/test/scip/testdata/test_case.snapshot.rb +++ b/test/scip/testdata/test_case.snapshot.rb @@ -29,6 +29,10 @@ def self.test(*args, &block) setup do # ^^^^^ definition [..] MyTest#``(). @a = T.let(1, Integer) +# ^^ definition [..] MyTest#`@a`. +# ^^^^^^^^^^^^^^^^^^^^^^ reference [..] MyTest#`@a`. +# ^^^^^^^ definition local 1~#2938098190 +# ^^^^^^^ reference [..] Integer# end test "valid method call" do @@ -77,6 +81,10 @@ def assert_equal(a, b); end setup do # ^^^^^ definition [..] NoParentClass#``(). @a = T.let(1, Integer) +# ^^ definition [..] NoParentClass#`@a`. +# ^^^^^^^^^^^^^^^^^^^^^^ reference [..] NoParentClass#`@a`. +# ^^^^^^^ definition local 1~#2938098190 +# ^^^^^^^ reference [..] Integer# end test "it works" do @@ -87,5 +95,7 @@ def assert_equal(a, b); end teardown do # ^^^^^^^^ definition [..] NoParentClass#teardown(). @a = 5 +# ^^ definition [..] NoParentClass#`@a`. +# ^^^^^^ reference [..] NoParentClass#`@a`. end end From aa22e2fce4b758be22bb9f14fe90b0c0896cd45c Mon Sep 17 00:00:00 2001 From: Varun Gandhi Date: Mon, 18 Nov 2024 17:04:43 +0800 Subject: [PATCH 2/2] Temporarily disable actionlint --- .github/workflows/lint.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index b7988f1e2..80202c135 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -26,7 +26,7 @@ jobs: - uses: actions/setup-go@v3 with: go-version: '>=1.19' - - name: Lint workflow files - run: | - go install github.com/rhysd/actionlint/cmd/actionlint@latest - actionlint .github/workflows/*.yml + # - name: Lint workflow files + # run: | + # go install github.com/rhysd/actionlint/cmd/actionlint@latest + # actionlint .github/workflows/*.yml