Skip to content
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
58 changes: 29 additions & 29 deletions lib/spoom/sorbet/lsp/structures.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,6 @@ module PrintableSymbol
def accept_printer(printer) = raise NotImplementedError, "Abstract method called"
end

class Hover < T::Struct
include PrintableSymbol

const :contents, String
const :range, T.nilable(Range)

class << self
#: (Hash[untyped, untyped] json) -> Hover
def from_json(json)
Hover.new(
contents: json["contents"]["value"],
range: json["range"] ? Range.from_json(json["range"]) : nil,
)
end
end

# @override
#: (SymbolPrinter printer) -> void
def accept_printer(printer)
printer.print("#{contents}\n")
printer.print_object(range) if range
end

#: -> String
def to_s
"#{contents} (#{range})."
end
end

class Position < T::Struct
include PrintableSymbol

Expand Down Expand Up @@ -100,6 +71,35 @@ def to_s
end
end

class Hover < T::Struct
include PrintableSymbol

const :contents, String
const :range, T.nilable(Range)

class << self
#: (Hash[untyped, untyped] json) -> Hover
def from_json(json)
Hover.new(
contents: json["contents"]["value"],
range: json["range"] ? Range.from_json(json["range"]) : nil,
)
end
end

# @override
#: (SymbolPrinter printer) -> void
def accept_printer(printer)
printer.print("#{contents}\n")
printer.print_object(range) if range
end

#: -> String
def to_s
"#{contents} (#{range})."
end
end

class Location < T::Struct
include PrintableSymbol

Expand Down
2 changes: 1 addition & 1 deletion rbi/spoom.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -1836,7 +1836,7 @@ class Spoom::LSP::Hover < ::T::Struct
include ::Spoom::LSP::PrintableSymbol

const :contents, ::String
const :range, T.nilable(T::Range[T.untyped])
const :range, T.nilable(::Spoom::LSP::Range)

sig { override.params(printer: ::Spoom::LSP::SymbolPrinter).void }
def accept_printer(printer); end
Expand Down
Loading