Skip to content

Commit f8aab12

Browse files
authored
Merge pull request #911 from otama-jaccy/fix-hover-forward-range-reference
Fix forward reference to Range in Hover causing load-time crash
2 parents 1f5e075 + 2788f11 commit f8aab12

2 files changed

Lines changed: 30 additions & 30 deletions

File tree

lib/spoom/sorbet/lsp/structures.rb

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,6 @@ module PrintableSymbol
1313
def accept_printer(printer) = raise NotImplementedError, "Abstract method called"
1414
end
1515

16-
class Hover < T::Struct
17-
include PrintableSymbol
18-
19-
const :contents, String
20-
const :range, T.nilable(Range)
21-
22-
class << self
23-
#: (Hash[untyped, untyped] json) -> Hover
24-
def from_json(json)
25-
Hover.new(
26-
contents: json["contents"]["value"],
27-
range: json["range"] ? Range.from_json(json["range"]) : nil,
28-
)
29-
end
30-
end
31-
32-
# @override
33-
#: (SymbolPrinter printer) -> void
34-
def accept_printer(printer)
35-
printer.print("#{contents}\n")
36-
printer.print_object(range) if range
37-
end
38-
39-
#: -> String
40-
def to_s
41-
"#{contents} (#{range})."
42-
end
43-
end
44-
4516
class Position < T::Struct
4617
include PrintableSymbol
4718

@@ -100,6 +71,35 @@ def to_s
10071
end
10172
end
10273

74+
class Hover < T::Struct
75+
include PrintableSymbol
76+
77+
const :contents, String
78+
const :range, T.nilable(Range)
79+
80+
class << self
81+
#: (Hash[untyped, untyped] json) -> Hover
82+
def from_json(json)
83+
Hover.new(
84+
contents: json["contents"]["value"],
85+
range: json["range"] ? Range.from_json(json["range"]) : nil,
86+
)
87+
end
88+
end
89+
90+
# @override
91+
#: (SymbolPrinter printer) -> void
92+
def accept_printer(printer)
93+
printer.print("#{contents}\n")
94+
printer.print_object(range) if range
95+
end
96+
97+
#: -> String
98+
def to_s
99+
"#{contents} (#{range})."
100+
end
101+
end
102+
103103
class Location < T::Struct
104104
include PrintableSymbol
105105

rbi/spoom.rbi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1836,7 +1836,7 @@ class Spoom::LSP::Hover < ::T::Struct
18361836
include ::Spoom::LSP::PrintableSymbol
18371837

18381838
const :contents, ::String
1839-
const :range, T.nilable(T::Range[T.untyped])
1839+
const :range, T.nilable(::Spoom::LSP::Range)
18401840

18411841
sig { override.params(printer: ::Spoom::LSP::SymbolPrinter).void }
18421842
def accept_printer(printer); end

0 commit comments

Comments
 (0)