rbs 2.8.4 → 3.0.0.dev.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +0 -28
  3. data/Gemfile +1 -1
  4. data/Gemfile.lock +16 -16
  5. data/Rakefile +1 -9
  6. data/ext/rbs_extension/constants.c +2 -0
  7. data/ext/rbs_extension/constants.h +1 -0
  8. data/ext/rbs_extension/extconf.rb +1 -1
  9. data/ext/rbs_extension/parser.c +23 -13
  10. data/ext/rbs_extension/ruby_objs.c +15 -3
  11. data/ext/rbs_extension/ruby_objs.h +2 -1
  12. data/lib/rbs/ast/members.rb +49 -15
  13. data/lib/rbs/cli.rb +6 -1
  14. data/lib/rbs/collection/config/lockfile.rb +115 -0
  15. data/lib/rbs/collection/config/lockfile_generator.rb +89 -48
  16. data/lib/rbs/collection/config.rb +11 -39
  17. data/lib/rbs/collection/installer.rb +9 -13
  18. data/lib/rbs/collection/sources/base.rb +2 -2
  19. data/lib/rbs/collection/sources/git.rb +135 -62
  20. data/lib/rbs/collection/sources/rubygems.rb +10 -12
  21. data/lib/rbs/collection/sources/stdlib.rb +10 -13
  22. data/lib/rbs/collection/sources.rb +7 -1
  23. data/lib/rbs/collection.rb +1 -0
  24. data/lib/rbs/definition.rb +1 -1
  25. data/lib/rbs/definition_builder/method_builder.rb +3 -3
  26. data/lib/rbs/definition_builder.rb +449 -572
  27. data/lib/rbs/environment.rb +5 -3
  28. data/lib/rbs/environment_loader.rb +11 -10
  29. data/lib/rbs/locator.rb +2 -2
  30. data/lib/rbs/prototype/helpers.rb +29 -13
  31. data/lib/rbs/prototype/node_usage.rb +99 -0
  32. data/lib/rbs/prototype/rb.rb +3 -2
  33. data/lib/rbs/prototype/rbi.rb +6 -4
  34. data/lib/rbs/prototype/runtime.rb +25 -12
  35. data/lib/rbs/substitution.rb +19 -0
  36. data/lib/rbs/types.rb +1 -5
  37. data/lib/rbs/validator.rb +2 -1
  38. data/lib/rbs/version.rb +1 -1
  39. data/lib/rbs/writer.rb +26 -17
  40. data/lib/rbs.rb +1 -0
  41. data/lib/rdoc_plugin/parser.rb +1 -1
  42. data/rbs.gemspec +1 -1
  43. data/schema/members.json +15 -10
  44. data/sig/collection/config/lockfile.rbs +80 -0
  45. data/sig/collection/config/lockfile_generator.rbs +55 -0
  46. data/sig/collection/config.rbs +5 -48
  47. data/sig/collection/installer.rbs +1 -1
  48. data/sig/collection/sources.rbs +66 -29
  49. data/sig/definition_builder.rbs +94 -81
  50. data/sig/environment_loader.rbs +1 -1
  51. data/sig/errors.rbs +21 -0
  52. data/sig/members.rbs +31 -7
  53. data/sig/prototype/node_usage.rbs +20 -0
  54. data/sig/shims/bundler.rbs +13 -0
  55. data/sig/shims/rubygems.rbs +9 -0
  56. data/sig/shims.rbs +0 -22
  57. data/sig/substitution.rbs +6 -0
  58. data/sig/writer.rbs +2 -0
  59. data/steep/Gemfile +3 -0
  60. data/steep/Gemfile.lock +61 -0
  61. metadata +13 -4
@@ -12,25 +12,22 @@ module RBS
12
12
 
13
13
  REPO = Repository.default
14
14
 
15
- def has?(config_entry)
16
- lookup(config_entry)
15
+ def has?(name, version)
16
+ lookup(name, version)
17
17
  end
18
18
 
19
- def versions(config_entry)
20
- REPO.gems[config_entry['name']].versions.keys.map(&:to_s)
19
+ def versions(name)
20
+ REPO.gems[name].versions.keys.map(&:to_s)
21
21
  end
22
22
 
23
- def install(dest:, config_entry:, stdout:)
23
+ def install(dest:, name:, version:, stdout:)
24
24
  # Do nothing because stdlib RBS is available by default
25
- name = config_entry['name']
26
- version = config_entry['version'] or raise
27
- from = lookup(config_entry)
25
+ from = lookup(name, version)
28
26
  stdout.puts "Using #{name}:#{version} (#{from})"
29
27
  end
30
28
 
31
- def manifest_of(config_entry)
32
- config_entry['version'] or raise
33
- manifest_path = (lookup(config_entry) or raise).join('manifest.yaml')
29
+ def manifest_of(name, version)
30
+ manifest_path = (lookup(name, version) or raise).join('manifest.yaml')
34
31
  YAML.safe_load(manifest_path.read) if manifest_path.exist?
35
32
  end
36
33
 
@@ -40,8 +37,8 @@ module RBS
40
37
  }
41
38
  end
42
39
 
43
- private def lookup(config_entry)
44
- REPO.lookup(config_entry['name'], config_entry['version'])
40
+ private def lookup(name, version)
41
+ REPO.lookup(name, version)
45
42
  end
46
43
  end
47
44
  end
@@ -11,7 +11,13 @@ module RBS
11
11
  def self.from_config_entry(source_entry)
12
12
  case source_entry['type']
13
13
  when 'git', nil # git source by default
14
- __skip__ = Git.new(**source_entry.slice('name', 'revision', 'remote', 'repo_dir').transform_keys(&:to_sym))
14
+ # @type var source_entry: Git::source_entry
15
+ Git.new(
16
+ name: source_entry["name"],
17
+ revision: source_entry["revision"],
18
+ remote: source_entry["remote"],
19
+ repo_dir: source_entry["repo_dir"]
20
+ )
15
21
  when 'stdlib'
16
22
  Stdlib.instance
17
23
  when 'rubygems'
@@ -5,6 +5,7 @@ require 'bundler'
5
5
 
6
6
  require_relative './collection/sources'
7
7
  require_relative './collection/config'
8
+ require_relative './collection/config/lockfile'
8
9
  require_relative './collection/config/lockfile_generator'
9
10
  require_relative './collection/installer'
10
11
  require_relative './collection/cleaner'
@@ -65,7 +65,7 @@ module RBS
65
65
  def overload?
66
66
  case mem = member
67
67
  when AST::Members::MethodDefinition
68
- mem.overload?
68
+ mem.overloading?
69
69
  else
70
70
  false
71
71
  end
@@ -113,14 +113,14 @@ module RBS
113
113
  build_method(
114
114
  methods,
115
115
  type,
116
- member: member.update(types: member.types.map {|type| type.sub(subst) }),
116
+ member: member.update(overloads: member.overloads.map {|overload| overload.sub(subst) }),
117
117
  accessibility: member.visibility || accessibility
118
118
  )
119
119
  when :singleton_instance
120
120
  build_method(
121
121
  methods,
122
122
  type,
123
- member: member.update(types: member.types.map {|type| type.sub(subst) }),
123
+ member: member.update(overloads: member.overloads.map {|overload| overload.sub(subst) }),
124
124
  accessibility: :private
125
125
  )
126
126
  end
@@ -215,7 +215,7 @@ module RBS
215
215
  def build_method(methods, type, member:, accessibility:)
216
216
  defn = methods.methods[member.name] ||= Methods::Definition.empty(type: type, name: member.name)
217
217
 
218
- if member.overload?
218
+ if member.overloading?
219
219
  defn.overloads << member
220
220
  else
221
221
  defn.accessibilities << accessibility