diff --git a/Gemfile.lock b/Gemfile.lock index 0d6edc19..ae348371 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -3,7 +3,7 @@ PATH specs: spoom (1.3.2) erubi (>= 1.10.0) - prism (>= 0.19.0) + prism (>= 0.28.0) sorbet-static-and-runtime (>= 0.5.10187) thor (>= 0.19.2) diff --git a/lib/spoom/deadcode/indexer.rb b/lib/spoom/deadcode/indexer.rb index b52ca6e5..cf33c777 100644 --- a/lib/spoom/deadcode/indexer.rb +++ b/lib/spoom/deadcode/indexer.rb @@ -151,10 +151,19 @@ def visit_constant_or_write_node(node) visit(node.value) end + sig { override.params(node: Prism::ConstantPathNode).void } + def visit_constant_path_node(node) + parent = node.parent + + visit(parent) if parent + reference_constant(node.name.to_s, node) + end + sig { override.params(node: Prism::ConstantPathWriteNode).void } def visit_constant_path_write_node(node) - parent = node.target.parent - name = node.target.child.slice + const_path_node = node.target + parent = const_path_node.parent + name = const_path_node.name.to_s if parent visit(parent) diff --git a/spoom.gemspec b/spoom.gemspec index 0cb1a90a..7dcbb7c3 100644 --- a/spoom.gemspec +++ b/spoom.gemspec @@ -30,7 +30,7 @@ Gem::Specification.new do |spec| spec.add_development_dependency("rake", "~> 13.2.1") spec.add_dependency("erubi", ">= 1.10.0") - spec.add_dependency("prism", ">= 0.19.0") + spec.add_dependency("prism", ">= 0.28.0") spec.add_dependency("sorbet-static-and-runtime", ">= 0.5.10187") spec.add_dependency("thor", ">= 0.19.2") diff --git a/test/spoom/deadcode/index_definitions_test.rb b/test/spoom/deadcode/index_definitions_test.rb index 982ea38f..35a9eed3 100644 --- a/test/spoom/deadcode/index_definitions_test.rb +++ b/test/spoom/deadcode/index_definitions_test.rb @@ -21,7 +21,7 @@ def foo( puts exception.message assert_equal(<<~ERRORS, exception.message) Error while parsing foo.rb: - - expected a `)` to close the parameters (at 1:8) + - unexpected end of file; expected a `)` to close the parameters (at 2:0) - unexpected end of file, assuming it is closing the parent top level context (at 2:0) - expected an `end` to close the `def` statement (at 1:8) ERRORS