diff --git a/lib/ruby_lsp/event_emitter.rb b/lib/ruby_lsp/event_emitter.rb index 0ac2eb024..61913718c 100644 --- a/lib/ruby_lsp/event_emitter.rb +++ b/lib/ruby_lsp/event_emitter.rb @@ -48,7 +48,7 @@ def emit_for_target(node) # Visit dispatchers are below. Notice that for nodes that create a new scope (e.g.: classes, modules, method defs) # we need both an `on_*` and `after_*` event. This is because some requests must know when we exit the scope - sig { override.params(node: T.nilable(SyntaxTree::Node)).void } + sig { override.params(node: T.nilable(YARP::Node)).void } def visit(node) @listeners[:on_node]&.each { |l| T.unsafe(l).on_node(node) } super @@ -125,8 +125,8 @@ def visit_comment(node) super end - sig { override.params(node: SyntaxTree::Rescue).void } - def visit_rescue(node) + sig { override.params(node: YARP::RescueNode).void } + def visit_rescue_node(node) @listeners[:on_rescue]&.each { |l| T.unsafe(l).on_rescue(node) } super end diff --git a/lib/ruby_lsp/executor.rb b/lib/ruby_lsp/executor.rb index d7bb9f88a..bca6cd3d3 100644 --- a/lib/ruby_lsp/executor.rb +++ b/lib/ruby_lsp/executor.rb @@ -309,7 +309,6 @@ def document_highlight(uri, position) sig { params(uri: URI::Generic, range: Document::RangeShape).returns(T.nilable(T::Array[Interface::InlayHint])) } def inlay_hint(uri, range) document = @store.get(uri) - return if document.syntax_error? start_line = range.dig(:start, :line) end_line = range.dig(:end, :line) diff --git a/lib/ruby_lsp/requests/inlay_hints.rb b/lib/ruby_lsp/requests/inlay_hints.rb index 752580899..6da77baa0 100644 --- a/lib/ruby_lsp/requests/inlay_hints.rb +++ b/lib/ruby_lsp/requests/inlay_hints.rb @@ -39,10 +39,9 @@ def initialize(range, emitter, message_queue) emitter.register(self, :on_rescue) end - sig { params(node: SyntaxTree::Rescue).void } + sig { params(node: YARP::RescueNode).void } def on_rescue(node) - exception = node.exception - return unless exception.nil? || exception.exceptions.nil? + return unless node.exceptions.empty? loc = node.location return unless visible?(node, @range) diff --git a/lib/ruby_lsp/requests/support/common.rb b/lib/ruby_lsp/requests/support/common.rb index 82cfb69c2..eab58bcab 100644 --- a/lib/ruby_lsp/requests/support/common.rb +++ b/lib/ruby_lsp/requests/support/common.rb @@ -43,7 +43,7 @@ def full_constant_name(node) name end - sig { params(node: T.nilable(SyntaxTree::Node), range: T.nilable(T::Range[Integer])).returns(T::Boolean) } + sig { params(node: T.nilable(YARP::Node), range: T.nilable(T::Range[Integer])).returns(T::Boolean) } def visible?(node, range) return true if range.nil? return false if node.nil? diff --git a/sorbet/rbi/shims/yarp.rbi b/sorbet/rbi/shims/yarp.rbi index b6a8b5b59..7c350d4c8 100644 --- a/sorbet/rbi/shims/yarp.rbi +++ b/sorbet/rbi/shims/yarp.rbi @@ -57,4 +57,9 @@ module YARP sig { returns(ConstantPathNode) } def constant_path; end end + + class RescueNode + sig { returns(T::Array[YARP::Node]) } + def exceptions; end + end end