rbs 1.6.2 → 1.7.0.beta.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +18 -3
  3. data/.gitignore +10 -1
  4. data/CHANGELOG.md +21 -6
  5. data/Gemfile +1 -0
  6. data/Rakefile +22 -22
  7. data/core/kernel.rbs +4 -4
  8. data/core/trace_point.rbs +1 -1
  9. data/ext/rbs_extension/constants.c +139 -0
  10. data/ext/rbs_extension/constants.h +72 -0
  11. data/ext/rbs_extension/extconf.rb +3 -0
  12. data/ext/rbs_extension/lexer.c +2533 -0
  13. data/ext/rbs_extension/lexer.h +161 -0
  14. data/ext/rbs_extension/lexer.re +140 -0
  15. data/ext/rbs_extension/lexstate.c +139 -0
  16. data/ext/rbs_extension/location.c +295 -0
  17. data/ext/rbs_extension/location.h +59 -0
  18. data/ext/rbs_extension/main.c +9 -0
  19. data/ext/rbs_extension/parser.c +2390 -0
  20. data/ext/rbs_extension/parser.h +18 -0
  21. data/ext/rbs_extension/parserstate.c +313 -0
  22. data/ext/rbs_extension/parserstate.h +141 -0
  23. data/ext/rbs_extension/rbs_extension.h +40 -0
  24. data/ext/rbs_extension/ruby_objs.c +521 -0
  25. data/ext/rbs_extension/ruby_objs.h +46 -0
  26. data/ext/rbs_extension/unescape.c +65 -0
  27. data/goodcheck.yml +1 -1
  28. data/lib/rbs/ast/comment.rb +0 -12
  29. data/lib/rbs/buffer.rb +4 -0
  30. data/lib/rbs/cli.rb +5 -8
  31. data/lib/rbs/collection/installer.rb +1 -0
  32. data/lib/rbs/collection/sources/git.rb +18 -3
  33. data/lib/rbs/errors.rb +28 -1
  34. data/lib/rbs/location.rb +221 -217
  35. data/lib/rbs/location_aux.rb +121 -0
  36. data/lib/rbs/locator.rb +10 -7
  37. data/lib/rbs/parser_aux.rb +63 -0
  38. data/lib/rbs/parser_compat/lexer_error.rb +4 -0
  39. data/lib/rbs/parser_compat/located_value.rb +5 -0
  40. data/lib/rbs/parser_compat/semantics_error.rb +4 -0
  41. data/lib/rbs/parser_compat/syntax_error.rb +4 -0
  42. data/lib/rbs/types.rb +2 -3
  43. data/lib/rbs/version.rb +1 -1
  44. data/lib/rbs/writer.rb +4 -2
  45. data/lib/rbs.rb +14 -7
  46. data/rbs.gemspec +2 -1
  47. data/sig/ancestor_builder.rbs +2 -2
  48. data/sig/annotation.rbs +2 -2
  49. data/sig/comment.rbs +7 -7
  50. data/sig/constant_table.rbs +1 -1
  51. data/sig/declarations.rbs +9 -9
  52. data/sig/definition.rbs +1 -1
  53. data/sig/definition_builder.rbs +2 -2
  54. data/sig/errors.rbs +40 -25
  55. data/sig/location.rbs +46 -78
  56. data/sig/locator.rbs +2 -2
  57. data/sig/members.rbs +7 -7
  58. data/sig/method_types.rbs +3 -3
  59. data/sig/parser.rbs +15 -20
  60. data/sig/rbs.rbs +4 -0
  61. data/sig/types.rbs +45 -27
  62. data/sig/writer.rbs +1 -1
  63. data/stdlib/io-console/0/io-console.rbs +137 -0
  64. data/stdlib/json/0/json.rbs +3 -3
  65. data/stdlib/net-http/0/net-http.rbs +2 -1
  66. data/stdlib/tempfile/0/tempfile.rbs +4 -6
  67. metadata +31 -6
  68. data/lib/rbs/parser.rb +0 -3614
@@ -0,0 +1,137 @@
1
+ class IO
2
+ class ConsoleMode
3
+ def echo=: (bool) -> bool
4
+ def raw: (?min: int, ?time: int, ?intr: bool) -> self
5
+ def raw!: (?min: int, ?time: int, ?intr: bool) -> self
6
+ end
7
+
8
+ # Returns an File instance opened console.
9
+ #
10
+ # If `sym` is given, it will be sent to the opened console with `args` and the
11
+ # result will be returned instead of the console IO itself.
12
+ def self.console: () -> File?
13
+ | (:close) -> nil
14
+ | (Symbol sym, *untyped args) -> untyped
15
+
16
+ # returns console window size
17
+ #
18
+ # You must require 'io/console/size' to use this method.
19
+ def self.console_size: () -> [Integer, Integer]
20
+
21
+ # fallback to console window size
22
+ #
23
+ # You must require 'io/console/size' to use this method.
24
+ def self.default_console_size: -> [Integer, Integer]
25
+
26
+ def beep: () -> self
27
+
28
+ def check_winsize_changed: () { () -> void } -> self
29
+ def clear_screen: () -> self
30
+
31
+ # Returns a data represents the current console mode.
32
+ def console_mode: () -> IO::ConsoleMode
33
+
34
+ # Sets the console mode to `mode`.
35
+ def console_mode=: (IO::ConsoleMode mode) -> IO::ConsoleMode
36
+
37
+ # Yields `self` within cooked mode.
38
+ #
39
+ # STDIN.cooked(&:gets)
40
+ #
41
+ # will read and return a line with echo back and line editing.
42
+ def cooked: [T] () { (self) -> T } -> T
43
+
44
+ # Enables cooked mode.
45
+ #
46
+ # If the terminal mode needs to be back, use io.cooked { ... }.
47
+ def cooked!: () -> self
48
+
49
+ def cursor: () -> [Integer, Integer]
50
+ def cursor=: ([Integer, Integer]) -> [Integer, Integer]
51
+
52
+ def cursor_down: (int) -> self
53
+ def cursor_left: (int) -> self
54
+ def cursor_right: (int) -> self
55
+ def cursor_up: (int) -> self
56
+
57
+ # Enables/disables echo back. On some platforms, all combinations of this flags
58
+ # and raw/cooked mode may not be valid.
59
+ def echo=: (bool flag) -> bool
60
+
61
+ # Returns `true` if echo back is enabled.
62
+ def echo?: () -> bool
63
+
64
+ def erase_line: (0 | 1 | 2 | nil) -> self
65
+ def erase_screen: (0 | 1 | 2 | 3 | nil) -> self
66
+
67
+ # Reads and returns a character in raw mode.
68
+ #
69
+ # See IO#raw for details on the parameters.
70
+ def getch: (?min: int, ?time: int, ?intr: bool) -> String
71
+
72
+ # Reads and returns a line without echo back.
73
+ # Prints +prompt+ unless it is +nil+.
74
+ #
75
+ # The newline character that terminates the
76
+ # read line is removed from the returned string,
77
+ # see String#chomp!.
78
+ def getpass: (?String) -> String
79
+
80
+ def goto: (int, int) -> self
81
+
82
+ def goto_column: (int) -> self
83
+
84
+ # Flushes input buffer in kernel.
85
+ def iflush: () -> self
86
+
87
+ # Flushes input and output buffers in kernel.
88
+ def ioflush: () -> self
89
+
90
+ # Yields `self` with disabling echo back.
91
+ #
92
+ # STDIN.noecho(&:gets)
93
+ #
94
+ # will read and return a line without echo back.
95
+ def noecho: [T] () { (self) -> T } -> T
96
+
97
+ # Flushes output buffer in kernel.
98
+ def oflush: () -> self
99
+
100
+ def pressed?: (Integer | Symbol | String) -> bool
101
+
102
+ # Yields `self` within raw mode, and returns the result of the block.
103
+ #
104
+ # STDIN.raw(&:gets)
105
+ #
106
+ # will read and return a line without echo back and line editing.
107
+ #
108
+ # The parameter `min` specifies the minimum number of bytes that should be
109
+ # received when a read operation is performed. (default: 1)
110
+ #
111
+ # The parameter `time` specifies the timeout in *seconds* with a precision of
112
+ # 1/10 of a second. (default: 0)
113
+ #
114
+ # If the parameter `intr` is `true`, enables break, interrupt, quit, and suspend
115
+ # special characters.
116
+ #
117
+ # Refer to the manual page of termios for further details.
118
+ def raw: [T] (?min: int, ?time: int, ?intr: bool) { (self) -> T } -> T
119
+
120
+ # Enables raw mode, and returns `io`.
121
+ #
122
+ # If the terminal mode needs to be back, use `io.raw { ... }`.
123
+ #
124
+ # See IO#raw for details on the parameters.
125
+ def raw!: (?min: int, ?time: int, ?intr: bool) -> self
126
+
127
+ def scroll_backward: (int) -> self
128
+ def scroll_forward: (int) -> self
129
+
130
+ # Returns console size.
131
+ def winsize: () -> [Integer, Integer]
132
+
133
+ # Tries to set console size. The effect depends on the platform and the running
134
+ # environment.
135
+ def winsize=: ([Integer, Integer]) -> [Integer, Integer]
136
+ | ([Integer, Integer, Integer, Integer]) -> [Integer, Integer, Integer, Integer]
137
+ end
@@ -512,7 +512,7 @@ class Range[out Elem]
512
512
  # Deserializes JSON string by constructing new Range object with arguments `a`
513
513
  # serialized by `to_json`.
514
514
  #
515
- def self.json_create: (Hash[String, String | [Elem, Elem, bool]] object) -> instance
515
+ def self.json_create: [A] (Hash[String, String | [A, A, bool]] object) -> Range[A]
516
516
 
517
517
  # Returns a hash, that will be turned into a JSON object and represent this
518
518
  # object.
@@ -565,7 +565,7 @@ class Set[A]
565
565
  #
566
566
  # method used for JSON marshalling support.
567
567
  #
568
- def self.json_create: (Hash[String, String | Array[A]] object) -> instance
568
+ def self.json_create: [A] (Hash[String, String | Array[A]] object) -> Set[A]
569
569
 
570
570
  # Marshal the object to JSON.
571
571
  #
@@ -582,7 +582,7 @@ class Struct[Elem]
582
582
  # Deserializes JSON string by constructing new Struct object with values `v`
583
583
  # serialized by `to_json`.
584
584
  #
585
- def self.json_create: (Hash[String, String | Array[Elem]] object) -> instance
585
+ def self.json_create: [Elem] (Hash[String, String | Array[Elem]] object) -> Struct[Elem]
586
586
 
587
587
  # Returns a hash, that will be turned into a JSON object and represent this
588
588
  # object.
@@ -1204,6 +1204,7 @@ module Net
1204
1204
 
1205
1205
  class HTTPRequest < HTTPGenericRequest
1206
1206
  def initialize: (String path, ?Hash[String, untyped] initheader) -> void
1207
+ | (URI::Generic uri, ?Hash[String, untyped] initheader) -> void
1207
1208
  end
1208
1209
 
1209
1210
  class HTTP::Get < HTTPRequest
@@ -1843,4 +1844,4 @@ module Net
1843
1844
  class HTTPFatalError < ProtoFatalError
1844
1845
  include Net::HTTPExceptions
1845
1846
  end
1846
- end
1847
+ end
@@ -95,8 +95,8 @@ class Tempfile < File
95
95
  # # ... do something with f ...
96
96
  # end
97
97
  #
98
- def self.create: (?String basename, ?String? tmpdir, ?mode: Integer, **untyped) -> File
99
- | [A] (?String basename, ?String? tmpdir, ?mode: Integer, **untyped) { (File) -> A } -> A
98
+ def self.create: (?(String | [String, String]) basename, ?String? tmpdir, ?mode: Integer, **untyped) -> File
99
+ | [A] (?(String | [String, String]) basename, ?String? tmpdir, ?mode: Integer, **untyped) { (File) -> A } -> A
100
100
 
101
101
  # Creates a new Tempfile.
102
102
  #
@@ -220,8 +220,6 @@ class Tempfile < File
220
220
  def initialize: (::Tempfile tmpfile) -> void
221
221
  end
222
222
 
223
- private
224
-
225
223
  # Creates a temporary file with permissions 0600 (= only readable and writable
226
224
  # by the owner) and opens it with mode "w+".
227
225
  #
@@ -265,6 +263,6 @@ class Tempfile < File
265
263
  # If Tempfile.new cannot find a unique filename within a limited number of
266
264
  # tries, then it will raise an exception.
267
265
  #
268
- def self.new: (?String basename, ?String? tmpdir, ?mode: Integer, **untyped) -> instance
269
- | [A] (?String basename, ?String? tmpdir, ?mode: Integer, **untyped) { (instance) -> A } -> A
266
+ def self.new: (?(String | [String, String]) basename, ?String? tmpdir, ?mode: Integer, **untyped) -> instance
267
+ | [A] (?(String | [String, String]) basename, ?String? tmpdir, ?mode: Integer, **untyped) { (instance) -> A } -> A
270
268
  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: 1.6.2
4
+ version: 1.7.0.beta.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Soutaro Matsumoto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-09 00:00:00.000000000 Z
11
+ date: 2021-09-22 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.
@@ -16,7 +16,8 @@ email:
16
16
  - matsumoto@soutaro.com
17
17
  executables:
18
18
  - rbs
19
- extensions: []
19
+ extensions:
20
+ - ext/rbs_extension/extconf.rb
20
21
  extra_rdoc_files: []
21
22
  files:
22
23
  - ".github/dependabot.yml"
@@ -97,6 +98,24 @@ files:
97
98
  - docs/stdlib.md
98
99
  - docs/syntax.md
99
100
  - exe/rbs
101
+ - ext/rbs_extension/constants.c
102
+ - ext/rbs_extension/constants.h
103
+ - ext/rbs_extension/extconf.rb
104
+ - ext/rbs_extension/lexer.c
105
+ - ext/rbs_extension/lexer.h
106
+ - ext/rbs_extension/lexer.re
107
+ - ext/rbs_extension/lexstate.c
108
+ - ext/rbs_extension/location.c
109
+ - ext/rbs_extension/location.h
110
+ - ext/rbs_extension/main.c
111
+ - ext/rbs_extension/parser.c
112
+ - ext/rbs_extension/parser.h
113
+ - ext/rbs_extension/parserstate.c
114
+ - ext/rbs_extension/parserstate.h
115
+ - ext/rbs_extension/rbs_extension.h
116
+ - ext/rbs_extension/ruby_objs.c
117
+ - ext/rbs_extension/ruby_objs.h
118
+ - ext/rbs_extension/unescape.c
100
119
  - goodcheck.yml
101
120
  - lib/rbs.rb
102
121
  - lib/rbs/ancestor_graph.rb
@@ -129,11 +148,16 @@ files:
129
148
  - lib/rbs/errors.rb
130
149
  - lib/rbs/factory.rb
131
150
  - lib/rbs/location.rb
151
+ - lib/rbs/location_aux.rb
132
152
  - lib/rbs/locator.rb
133
153
  - lib/rbs/method_type.rb
134
154
  - lib/rbs/namespace.rb
135
- - lib/rbs/parser.rb
136
155
  - lib/rbs/parser.y
156
+ - lib/rbs/parser_aux.rb
157
+ - lib/rbs/parser_compat/lexer_error.rb
158
+ - lib/rbs/parser_compat/located_value.rb
159
+ - lib/rbs/parser_compat/semantics_error.rb
160
+ - lib/rbs/parser_compat/syntax_error.rb
137
161
  - lib/rbs/prototype/rb.rb
138
162
  - lib/rbs/prototype/rbi.rb
139
163
  - lib/rbs/prototype/runtime.rb
@@ -227,6 +251,7 @@ files:
227
251
  - stdlib/fileutils/0/fileutils.rbs
228
252
  - stdlib/find/0/find.rbs
229
253
  - stdlib/forwardable/0/forwardable.rbs
254
+ - stdlib/io-console/0/io-console.rbs
230
255
  - stdlib/ipaddr/0/ipaddr.rbs
231
256
  - stdlib/json/0/json.rbs
232
257
  - stdlib/logger/0/formatter.rbs
@@ -315,9 +340,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
315
340
  version: '2.6'
316
341
  required_rubygems_version: !ruby/object:Gem::Requirement
317
342
  requirements:
318
- - - ">="
343
+ - - ">"
319
344
  - !ruby/object:Gem::Version
320
- version: '0'
345
+ version: 1.3.1
321
346
  requirements: []
322
347
  rubygems_version: 3.2.22
323
348
  signing_key: