Skip to content

Commit 2cd222a

Browse files
committed
Avoid exception when hovering RBS-annotated params
1 parent ee137fb commit 2cd222a

2 files changed

Lines changed: 12 additions & 2 deletions

File tree

lib/typeprof/code_range.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ def initialize(first, last)
5656
end
5757

5858
def self.from_node(node, encoding = Encoding::UTF_16LE)
59-
node = node.location if node.is_a?(Prism::Node)
60-
node = node.location if node.is_a?(RBS::MethodType)
59+
node = node.location if node.respond_to?(:location)
6160
if node.is_a?(Prism::Location)
6261
pos1 = CodePosition.new(node.start_line, node.start_code_units_column(encoding))
6362
pos2 = CodePosition.new(node.end_line, node.end_code_units_column(encoding))

scenario/rbs/inline-hover.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## update: test.rb
2+
#: (Integer) -> void
3+
def check(var) # TODO: fix "??? no type ???"
4+
var
5+
end
6+
7+
## hover: test.rb:2:11
8+
??? no type ???
9+
10+
## hover: test.rb:3:3
11+
Integer

0 commit comments

Comments
 (0)