Skip to content

fix: Stop emitting definitions for <static-init>. #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 12, 2022
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
6 changes: 4 additions & 2 deletions scip_indexer/SCIPIndexer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -809,8 +809,10 @@ class SCIPSemanticExtension : public SemanticExtension {
}

auto scipState = this->getSCIPState();
auto status = scipState->saveDefinition(gs, file, core::SymbolRef(methodDef.symbol));
ENFORCE(status.ok());
if (methodDef.name != core::Names::staticInit()) {
auto status = scipState->saveDefinition(gs, file, core::SymbolRef(methodDef.symbol));
ENFORCE(status.ok());
}
// It looks like Sorbet only stores symbols at the granularity of classes and methods
// So we need to recompute local variable information from scratch. The LocalVarFinder
// which is used by the LSP implementation is tailored for finding the local variable
Expand Down
1 change: 0 additions & 1 deletion test/scip/testdata/args.snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

def args(x, y)
#^^^^^^^^^^^^^^ definition scip-ruby gem TODO TODO args().
#^^^^^^^^^^ definition scip-ruby gem TODO TODO <static-init>().
# ^ definition local 1~#2634721084
# ^ definition local 2~#2634721084
z = x + y
Expand Down
1 change: 0 additions & 1 deletion test/scip/testdata/arrays.snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

def arrays(a, i)
#^^^^^^^^^^^^^^^^ definition scip-ruby gem TODO TODO arrays().
#^^^^^^^^ definition scip-ruby gem TODO TODO <static-init>().
# ^ definition local 1~#513334479
# ^ definition local 2~#513334479
a[0] = 0
Expand Down
10 changes: 0 additions & 10 deletions test/scip/testdata/classes.snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

_ = 0
#^ definition local 1~#119448696
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition scip-ruby gem TODO TODO <static-init>().

class C1
#^^^^^^^^^^ definition scip-ruby gem TODO TODO <static-init>().
# ^^ definition scip-ruby gem TODO TODO C1#
def f()
# ^^^^^^^ definition scip-ruby gem TODO TODO f().
Expand All @@ -21,16 +19,13 @@ def f()
end

module M2
#^^^^^^^^^^^^^^^ definition scip-ruby gem TODO TODO <static-init>().
# ^^ definition scip-ruby gem TODO TODO M2#
class C2
# ^^^^^^^^^^^^ definition scip-ruby gem TODO TODO <static-init>().
# ^^ definition scip-ruby gem TODO TODO C2#
end
end

class M3::C3
#^^^^^^^^^^^^^^^^^^ definition scip-ruby gem TODO TODO <static-init>().
# ^^ definition scip-ruby gem TODO TODO M3#
# ^^ definition scip-ruby gem TODO TODO C3#
end
Expand All @@ -57,7 +52,6 @@ def localClass.myMethod()
end

module M4
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition scip-ruby gem TODO TODO <static-init>().
# ^^ definition scip-ruby gem TODO TODO M4#
K = 0
# ^ definition local 1~#119448696
Expand All @@ -74,10 +68,8 @@ def module_access()
end

module M5
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition scip-ruby gem TODO TODO <static-init>().
# ^^ definition scip-ruby gem TODO TODO M5#
module M6
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition scip-ruby gem TODO TODO <static-init>().
# ^^ definition scip-ruby gem TODO TODO M6#
def self.g()
# ^^^^^^^^^^^^ definition scip-ruby gem TODO TODO g().
Expand All @@ -93,10 +85,8 @@ def self.h()
end

class C7
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition scip-ruby gem TODO TODO <static-init>().
# ^^ definition scip-ruby gem TODO TODO C7#
module M8
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition scip-ruby gem TODO TODO <static-init>().
# ^^ definition scip-ruby gem TODO TODO M8#
def self.i()
# ^^^^^^^^^^^^ definition scip-ruby gem TODO TODO i().
Expand Down
1 change: 0 additions & 1 deletion test/scip/testdata/for.snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

def for_loop()
#^^^^^^^^^^^^^^ definition scip-ruby gem TODO TODO for_loop().
#^^^^^^^^^^^ definition scip-ruby gem TODO TODO <static-init>().
y = 0
# ^ definition local 1~#1120785331
for x in [1, 2, 3]
Expand Down
1 change: 0 additions & 1 deletion test/scip/testdata/functions.snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

def globalFn1()
#^^^^^^^^^^^^^^^ definition scip-ruby gem TODO TODO globalFn1().
#^^^^^^^^^ definition scip-ruby gem TODO TODO <static-init>().
x = 10
# ^ definition local 1~#3846536873
x
Expand Down
1 change: 0 additions & 1 deletion test/scip/testdata/hashes.snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

def hashes(h, k)
#^^^^^^^^^^^^^^^^ definition scip-ruby gem TODO TODO hashes().
#^^^^^^ definition scip-ruby gem TODO TODO <static-init>().
# ^ definition local 1~#1685166589
# ^ definition local 2~#1685166589
h["hello"] = "world"
Expand Down
1 change: 0 additions & 1 deletion test/scip/testdata/loops_and_conditionals.snapshot.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

def if_elsif_else()
#^^^^^^^^^^^^^^^^^^^ definition scip-ruby gem TODO TODO if_elsif_else().
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition scip-ruby gem TODO TODO <static-init>().
x = 0
# ^ definition local 1~#2393773952
y = 0
Expand Down