8000 Support rbs v3.8 by ksss · Pull Request #101 · ksss/orthoses · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Support rbs v3.8 #101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 12, 2025
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
32 changes: 17 additions & 15 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ PATH
GEM
remote: https://rubygems.org/
specs:
activesupport (7.2.2)
activesupport (7.2.2.1)
base64
benchmark (>= 0.3)
bigdecimal
Expand All @@ -22,31 +22,31 @@ GEM
ast (2.4.2)
base64 (0.2.0)
benchmark (0.4.0)
bigdecimal (3.1.8)
bigdecimal (3.1.9)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
csv (3.3.0)
connection_pool (2.5.0)
csv (3.3.2)
debug (1.9.2)
irb (~> 1.10)
reline (>= 0.3.8)
drb (2.2.1)
ffi (1.17.0-arm64-darwin)
ffi (1.17.0-x86_64-darwin)
ffi (1.17.0-x86_64-linux-gnu)
ffi (1.17.1-arm64-darwin)
ffi (1.17.1-x86_64-darwin)
ffi (1.17.1-x86_64-linux-gnu)
fileutils (1.7.3)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
io-console (0.7.2)
irb (1.14.1)
rdoc (>= 4.0.0)
reline (>= 0.4.2)
json (2.8.2)
json (2.9.1)
language_server-protocol (3.17.0.3)
listen (3.9.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
logger (1.6.1)
minitest (5.25.1)
logger (1.6.5)
minitest (5.25.4)
parser (3.3.6.0)
ast (~> 2.4.1)
racc
Expand All @@ -58,15 +58,15 @@ GEM
rb-fsevent (0.11.2)
rb-inotify (0.11.1)
ffi (~> 1.0)
rbs (3.6.1)
rbs (3.8.1)
logger
rdoc (6.8.1)
psych (>= 4.0.0)
reline (0.5.11)
io-console (~> 0.5)
rgot (1.4.0)
securerandom (0.3.2)
steep (1.8.3)
securerandom (0.4.1)
steep (1.9.3)
activesupport (>= 5.1)
concurrent-ruby (>= 1.1.10)
csv (>= 3.0.9)
Expand All @@ -77,17 +77,19 @@ GEM
logger (>= 1.3.0)
parser (>= 3.1)
rainbow (>= 2.2.2, < 4.0)
rbs (~> 3.6.0)
rbs (~> 3.8)
securerandom (>= 0.1)
strscan (>= 1.0.0)
terminal-table (>= 2, < 4)
uri (>= 0.12.0)
stringio (3.1.2)
strscan (3.1.0)
strscan (3.1.2)
terminal-table (3.0.2)
unicode-display_width (>= 1.1.1, < 3)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.6.0)
uri (1.0.2)

PLATFORMS
arm64-darwin-22
Expand Down
1 change: 1 addition & 0 deletions lib/orthoses.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'rbs'
require 'pathname'
require 'stringio'
require_relative 'orthoses/shims'

require 'orthoses/utils'

Expand Down
2 changes: 1 addition & 1 deletion lib/orthoses/content.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def original_rbs

def auto_header
env = Utils.rbs_environment
if entry = env.class_decls[TypeName(name).absolute!]
if entry = env.class_decls[RBS::TypeName.parse(name).absolute!]
@header = Content::HeaderBuilder.new(env: env).build(entry: entry)
return
end
Expand Down
6 changes: 3 additions & 3 deletions lib/orthoses/content/header_builder_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module Baz
["Foo::Bar", "module Foo::Bar"],
["Foo::Bar::Baz", "module Foo::Bar::Baz"],
].each do |input_name, expect_header|
entry = env.class_decls[TypeName(input_name).absolute!] or raise "#{input_name} not found"
entry = env.class_decls[RBS::TypeName.parse(input_name).absolute!] or raise "#{input_name} not found"
output_header = header_builder.build(entry: entry)
unless expect_header == output_header
t.error("expect=#{expect_header}, but got #{output_header}")
Expand Down Expand Up @@ -77,7 +77,7 @@ class SuperIsClassAlias < ClassAlias
["Aaa", "class Aaa < Bbb"],
["SuperIsClassAlias", "class SuperIsClassAlias < ClassAlias"],
].each do |input_name, expect_header|
entry = env.class_decls[TypeName(input_name).absolute!] or raise "#{input_name} not found"
entry = env.class_decls[RBS::TypeName.parse(input_name).absolute!] or raise "#{input_name} not found"
output_header = header_builder.build(entry: entry)
unless expect_header == output_header
t.error("expect=#{expect_header}, but got #{output_header}")
Expand Down Expand Up @@ -109,7 +109,7 @@ module Mod
["_Foo", "interface _Foo"],
["_Bar", "interface _Bar[T]"],
].each do |input_name, expect_header|
entry = env.interface_decls[TypeName(input_name).absolute!] or raise "#{input_name} not found"
entry = env.interface_decls[RBS::TypeName.parse(input_name).absolute!] or raise "#{input_name} not found"
output_header = header_builder.build(entry: entry)
unless expect_header == output_header
t.error("expect=#{expect_header}, but got #{output_header}")
Expand Down
2 changes: 1 addition & 1 deletion lib/orthoses/content_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ module Mod[T]
env.add_signature(buffer: buffer, directives: directives, decls: decls)

begin
RBS::DefinitionBuilder.new(env: env.resolve_type_names).build_instance(TypeName("::ContentTest::Simple"))
RBS::DefinitionBuilder.new(env: env.resolve_type_names).build_instance(RBS::TypeName.parse("::ContentTest::Simple"))
rescue => err
t.error("\n```rbs\n#{store["ContentTest::Simple"].to_rbs}```\n#{err.inspect}")
end
Expand Down
4 changes: 2 additions & 2 deletions lib/orthoses/missing_name.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def recur(content)
if content.header && content.header.include?("<")
_, superclass = content.header.split(/\s*<\s*/, 2)
superclass.sub!(/\[.*/, "")
new_name = TypeName(superclass).relative!.to_s
new_name = RBS::TypeName.parse(superclass).relative!.to_s
recur(@store[new_name])
end
end
Expand All @@ -60,7 +60,7 @@ def call
def split_name(key_name)
ret = []

type_name = TypeName(key_name).relative!
type_name = RBS::TypeName.parse(key_name).relative!
if !Utils.rbs_defined_class?(type_name.to_s) && !@store.has_key?(type_name.to_s)
ret << type_name.to_s
end
Expand Down
2 changes: 1 addition & 1 deletion lib/orthoses/resolve_type_names.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def call
store.each do |name, content|
out = StringIO.new
writer = RBS::Writer.new(out: out)
type_name = TypeName(content.name).absolute!
type_name = RBS::TypeName.parse(content.name).absolute!
entry = env.class_decls[type_name] || raise
content.header = content_header(entry)
entry.decls.each do |decl|
Expand Down
18 changes: 18 additions & 0 deletions lib/orthoses/shims.rb
F438
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# RBS 3.8
unless RBS::TypeName.singleton_class.method_defined?(:parse)
module RBS
class TypeName
def self.parse(string)
absolute = string.start_with?("::")

*path, name = string.delete_prefix("::").split("::").map(&:to_sym)
raise unless name

TypeName.new(
name: name,
namespace: RBS::Namespace.new(path: path, absolute: absolute)
)
end
end
end
end
4 changes: 2 additions & 2 deletions lib/orthoses/utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def self.module_name(mod)
def self.module_to_type_name(mod)
name = Utils.module_name(mod)
if name && !name.empty?
TypeName(name)
RBS::TypeName.parse(name)
else
nil
end
Expand All @@ -186,7 +186,7 @@ def self.known_type_params(name)
type_name =
case name
when String
TypeName(name).absolute!
RBS::TypeName.parse(name).absolute!
when Module
module_to_type_name(name).absolute!
when RBS::TypeName
Expand Down
8 changes: 6 additions & 2 deletions rbs_collection.lock.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,21 @@ gems:
source:
type: git
name: ruby/gem_rbs_collection
revision: 443b2934235be3a76b9022b21764d06429ac6d7e
revision: 7651e7b92c15bd5b4bc11fd3dd455be0ea571fd0
remote: https://github.com/ruby/gem_rbs_collection.git
repo_dir: gems
- name: rbs
version: 3.6.1
version: 3.8.1
source:
type: rubygems
- name: rdoc
version: '0'
source:
type: stdlib
- name: stringio
version: '0'
source:
type: stdlib
- name: tsort
version: '0'
source:
Expand Down
Loading
0