Skip to content

Commit

Permalink
Use Prism v0.26.0
Browse files Browse the repository at this point in the history
  • Loading branch information
andyw8 committed Apr 19, 2024
1 parent 22ae132 commit f546a24
Show file tree
Hide file tree
Showing 10 changed files with 11,820 additions and 7,093 deletions.
8 changes: 4 additions & 4 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ PATH
specs:
ruby-lsp (0.16.5)
language_server-protocol (~> 3.17.0)
prism (>= 0.23.0, < 0.25)
prism (>= 0.23.0, < 0.27)
sorbet-runtime (>= 0.5.10782)

GEM
Expand Down Expand Up @@ -45,14 +45,14 @@ GEM
ast (~> 2.4.1)
racc
prettier_print (1.2.1)
prism (0.24.0)
prism (0.26.0)
psych (5.1.2)
stringio
racc (1.7.3)
rainbow (3.1.1)
rake (13.2.1)
rbi (0.1.10)
prism (>= 0.18.0, < 0.25)
rbi (0.1.11)
prism (>= 0.18.0, < 0.27)
sorbet-runtime (>= 0.5.9204)
regexp_parser (2.9.0)
reline (0.5.0)
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby_indexer/lib/ruby_indexer/collector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Collector

LEAVE_EVENT = T.let(Object.new.freeze, Object)

sig { params(index: Index, parse_result: Prism::ParseResult, file_path: String).void }
sig { params(index: Index, parse_result: Prism::ParseResult[Prism::ProgramNode], file_path: String).void }
def initialize(index, parse_result, file_path)
@index = index
@file_path = file_path
Expand Down
6 changes: 3 additions & 3 deletions lib/ruby_lsp/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Document

abstract!

sig { returns(Prism::ParseResult) }
sig { returns(Prism::ParseResult[Prism::ProgramNode]) }
attr_reader :parse_result

sig { returns(String) }
Expand All @@ -31,7 +31,7 @@ def initialize(source:, version:, uri:, encoding: Encoding::UTF_8)
@version = T.let(version, Integer)
@uri = T.let(uri, URI::Generic)
@needs_parsing = T.let(true, T::Boolean)
@parse_result = T.let(parse, Prism::ParseResult)
@parse_result = T.let(parse, Prism::ParseResult[Prism::ProgramNode])
end

sig { returns(Prism::ProgramNode) }
Expand Down Expand Up @@ -93,7 +93,7 @@ def push_edits(edits, version:)
@cache.clear
end

sig { abstract.returns(Prism::ParseResult) }
sig { abstract.returns(Prism::ParseResult[Prism::ProgramNode]) }
def parse; end

sig { returns(T::Boolean) }
Expand Down
8 changes: 8 additions & 0 deletions lib/ruby_lsp/internal.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@
require "prism/visitor"
require "language_server-protocol"

# Prism v0.26.0 introduced generics for ParseResult, but it causes some problems so the intention is to remove it.
# Once that is done, we can remove this patch.
module Prism
class ParseResult
extend T::Generic
end
end

require "ruby-lsp"
require "ruby_lsp/base_server"
require "ruby_indexer/ruby_indexer"
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby_lsp/listeners/document_link.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ def extract_document_link(node)
match = comment.location.slice.match(%r{source://.*#\d+$})
return unless match

uri = T.cast(URI(T.must(match[0])), URI::Source)
uri = T.cast(URI(match[0]), URI::Source)
gem_version = resolve_version(uri)
return if gem_version.nil?

Expand Down
2 changes: 1 addition & 1 deletion lib/ruby_lsp/ruby_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

module RubyLsp
class RubyDocument < Document
sig { override.returns(Prism::ParseResult) }
sig { override.returns(Prism::ParseResult[Prism::ProgramNode]) }
def parse
return @parse_result unless @needs_parsing

Expand Down
2 changes: 1 addition & 1 deletion ruby-lsp.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Gem::Specification.new do |s|
s.require_paths = ["lib"]

s.add_dependency("language_server-protocol", "~> 3.17.0")
s.add_dependency("prism", ">= 0.23.0", "< 0.25")
s.add_dependency("prism", ">= 0.23.0", "< 0.27")
s.add_dependency("sorbet-runtime", ">= 0.5.10782")

s.required_ruby_version = ">= 3.0"
Expand Down
Loading

0 comments on commit f546a24

Please sign in to comment.