rbs 3.0.3 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/sig/parser.rbs CHANGED
@@ -2,8 +2,7 @@ module RBS
2
2
  class Parser
3
3
  # Parse a method type and return it
4
4
  #
5
- # When `pos` keyword is specified, skips the first `pos` characters from the input.
6
- # If no token is left in the input, it returns `nil`.
5
+ # When `range` keyword is specified, it starts parsing from the `begin` to the `endo` the range.
7
6
  #
8
7
  # ```ruby
9
8
  # RBS::Parser.parse_method_type("() -> void") # => `() -> void`
@@ -12,12 +11,21 @@ module RBS
12
11
  # RBS::Parser.parse_method_type("() -> void () -> String", range: 23...) # => nil
13
12
  # ```
14
13
  #
15
- def self.parse_method_type: (Buffer | String, ?range: Range[Integer?], ?variables: Array[Symbol]) -> MethodType?
14
+ # When `require_eof` is `true`, an error is raised if more tokens are left in the input.
15
+ # (Defaults to `false`.)
16
+ #
17
+ # ```ruby
18
+ # RBS::Parser.parse_method_type("() -> void () -> String", require_eof: false) # => `() -> void`
19
+ # RBS::Parser.parse_method_type("() -> void () -> String", require_eof: true) # => Raises an error
20
+ #
21
+ # RBS::Parser.parse_method_type("", require_eof: true) # => nil
22
+ # ```
23
+ #
24
+ def self.parse_method_type: (Buffer | String, ?range: Range[Integer?], ?variables: Array[Symbol], ?require_eof: bool) -> MethodType?
16
25
 
17
26
  # Parse a type and return it
18
27
  #
19
- # When `pos` keyword is specified, skips the first `pos` characters from the input.
20
- # If no token is left in the input, it returns `nil`.
28
+ # When `range` keyword is specified, it starts parsing from the `begin` to the `endo` the range.
21
29
  #
22
30
  # ```ruby
23
31
  # RBS::Parser.parse_type("String") # => `String`
@@ -26,7 +34,17 @@ module RBS
26
34
  # RBS::Parser.parse_type("String Integer", pos: 14...) # => nil
27
35
  # ```
28
36
  #
29
- def self.parse_type: (Buffer | String, ?range: Range[Integer?], ?variables: Array[Symbol]) -> Types::t?
37
+ # When `require_eof` is `true`, an error is raised if more tokens are left in the input.
38
+ # (Defaults to `false`.)
39
+ #
40
+ # ```ruby
41
+ # RBS::Parser.parse_type("String untyped", require_eof: false) # => `String`
42
+ # RBS::Parser.parse_type("String untyped", require_eof: true) # => Raises an error
43
+ #
44
+ # RBS::Parser.parse_type("", require_eof: true) # => nil
45
+ # ```
46
+ #
47
+ def self.parse_type: (Buffer | String, ?range: Range[Integer?], ?variables: Array[Symbol], ?require_eof: bool) -> Types::t?
30
48
 
31
49
  # Parse whole RBS file and return an array of declarations
32
50
  #
@@ -38,9 +56,9 @@ module RBS
38
56
 
39
57
  def self.buffer: (String | Buffer source) -> Buffer
40
58
 
41
- def self._parse_type: (Buffer, Integer start_pos, Integer end_pos, Array[Symbol] variables) -> Types::t?
59
+ def self._parse_type: (Buffer, Integer start_pos, Integer end_pos, Array[Symbol] variables, bool require_eof) -> Types::t?
42
60
 
43
- def self._parse_method_type: (Buffer, Integer start_pos, Integer end_pos, Array[Symbol] variables) -> MethodType?
61
+ def self._parse_method_type: (Buffer, Integer start_pos, Integer end_pos, Array[Symbol] variables, bool require_eof) -> MethodType?
44
62
 
45
63
  def self._parse_signature: (Buffer, Integer end_pos) -> [Array[AST::Directives::t], Array[AST::Declarations::t]]
46
64
 
data/sig/repository.rbs CHANGED
@@ -3,12 +3,14 @@ module RBS
3
3
  #
4
4
  # A repository object can handle multiple repository roots.
5
5
  #
6
- # repo = RBS::Repository.new()
7
- # repo.add(Pathname("vendor/rbs/gem-rbs"))
8
- # repo.add(Pathname("vendor/rbs/internal-rbs"))
9
- # repo.add(Pathname("vendor/rbs/definitely-rbs"))
6
+ # ```ruby
7
+ # repo = RBS::Repository.new()
8
+ # repo.add(Pathname("vendor/rbs/gem-rbs"))
9
+ # repo.add(Pathname("vendor/rbs/internal-rbs"))
10
+ # repo.add(Pathname("vendor/rbs/definitely-rbs"))
10
11
  #
11
- # repo.lookup("minitest", "2.1.3") => Pathname or nil
12
+ # repo.lookup("minitest", "2.1.3") # => Pathname or nil
13
+ # ```
12
14
  #
13
15
  # If one gem version can resolve to several directories, the last added dir wins.
14
16
  #
@@ -15,6 +15,8 @@ module Bundler
15
15
 
16
16
  class Dependency < Gem::Dependency
17
17
  attr_reader autorequire: Array[String]?
18
+
19
+ attr_reader source: untyped
18
20
  end
19
21
 
20
22
  class Definition
@@ -0,0 +1,33 @@
1
+ module RBS
2
+ class Subtractor
3
+ type decl_with_members = AST::Declarations::Class | AST::Declarations::Module
4
+
5
+ @minuend: Array[AST::Declarations::t]
6
+ @subtrahend: Environment
7
+
8
+ def initialize: (Array[AST::Declarations::t] minuend, Environment subtrahend) -> void
9
+
10
+ def call: (?Array[AST::Declarations::t], ?context: Resolver::context) -> Array[AST::Declarations::t]
11
+
12
+ private def filter_members: (decl_with_members, context: Resolver::context) -> decl_with_members?
13
+
14
+ private def member_exist?: (TypeName owner, AST::Members::t, context: Resolver::context) -> boolish
15
+
16
+ private def method_exist?: (TypeName owner, Symbol method_name, AST::Members::MethodDefinition::kind) -> boolish
17
+
18
+ private def ivar_exist?: (TypeName owner, Symbol ivar_name, AST::Members::Attribute::kind) -> boolish
19
+
20
+ private def cvar_exist?: (TypeName owner, Symbol cvar_name) -> boolish
21
+
22
+ private def each_member: (TypeName owner) { (AST::Members::t | AST::Declarations::t) -> void } -> void
23
+ | (TypeName owner) -> Enumerator[(AST::Members::t | AST::Declarations::t), void]
24
+
25
+ private def mixin_exist?: (TypeName owner, AST::Members::Include | AST::Members::Extend | AST::Members::Prepend, context: Resolver::context) -> boolish
26
+
27
+ private def update_decl: (decl_with_members, members: Array[AST::Declarations::t | AST::Members::t]) -> decl_with_members
28
+
29
+ private def absolute_typename: (TypeName, context: Resolver::context) -> TypeName
30
+
31
+ private def typename_candidates: (TypeName, context: Resolver::context) -> Array[TypeName]
32
+ end
33
+ end
data/sig/types.rbs CHANGED
@@ -18,9 +18,11 @@ module RBS
18
18
  # Yields all direct sub types included in the type.
19
19
  # It doesn't yield the type itself.
20
20
  #
21
- # parse("Hash[String, Array[Symbol]]").each_type do |ty|
22
- # ... # Yields String and Array[Symbol]
23
- # end
21
+ # ```ruby
22
+ # parse("Hash[String, Array[Symbol]]").each_type do |ty|
23
+ # ... # Yields String and Array[Symbol]
24
+ # end
25
+ # ```
24
26
  #
25
27
  def each_type: () { (t) -> void } -> void
26
28
  | () -> Enumerator[t, void]
@@ -32,9 +34,11 @@ module RBS
32
34
  # Returns a String representation.
33
35
  # `level` is used internally.
34
36
  #
35
- # parse("String").to_s # => "String"
36
- # parse("String | Integer").to_s() # => "String | Integer"
37
- # parse("String | Integer").to_s(1) # => "(String | Integer)"
37
+ # ```ruby
38
+ # parse("String").to_s # => "String"
39
+ # parse("String | Integer").to_s() # => "String | Integer"
40
+ # parse("String | Integer").to_s(1) # => "(String | Integer)"
41
+ # ```
38
42
  #
39
43
  def to_s: (?Integer level) -> String
40
44
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbs
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.3
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Soutaro Matsumoto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-07 00:00:00.000000000 Z
11
+ date: 2023-04-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: RBS is the language for type signatures for Ruby and standard library
14
14
  definitions.
@@ -182,6 +182,7 @@ files:
182
182
  - lib/rbs/environment_walker.rb
183
183
  - lib/rbs/errors.rb
184
184
  - lib/rbs/factory.rb
185
+ - lib/rbs/file_finder.rb
185
186
  - lib/rbs/location_aux.rb
186
187
  - lib/rbs/locator.rb
187
188
  - lib/rbs/method_type.rb
@@ -201,6 +202,7 @@ files:
201
202
  - lib/rbs/resolver/type_name_resolver.rb
202
203
  - lib/rbs/sorter.rb
203
204
  - lib/rbs/substitution.rb
205
+ - lib/rbs/subtractor.rb
204
206
  - lib/rbs/test.rb
205
207
  - lib/rbs/test/errors.rb
206
208
  - lib/rbs/test/hook.rb
@@ -259,6 +261,7 @@ files:
259
261
  - sig/environment_walker.rbs
260
262
  - sig/errors.rbs
261
263
  - sig/factory.rbs
264
+ - sig/file_finder.rbs
262
265
  - sig/location.rbs
263
266
  - sig/locator.rbs
264
267
  - sig/manifest.yaml
@@ -284,6 +287,7 @@ files:
284
287
  - sig/shims/rubygems.rbs
285
288
  - sig/sorter.rbs
286
289
  - sig/substitution.rbs
290
+ - sig/subtractor.rbs
287
291
  - sig/type_alias_dependency.rbs
288
292
  - sig/type_alias_regularity.rbs
289
293
  - sig/type_param.rbs