rbs 4.0.3 → 4.1.0.pre.1

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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +34 -6
  3. data/.github/workflows/rust.yml +0 -2
  4. data/.github/workflows/windows.yml +0 -3
  5. data/CHANGELOG.md +0 -8
  6. data/Rakefile +2 -2
  7. data/config.yml +24 -0
  8. data/core/builtin.rbs +1 -0
  9. data/core/class.rbs +5 -3
  10. data/core/kernel.rbs +26 -11
  11. data/core/ruby_vm.rbs +40 -0
  12. data/docs/inline.md +29 -1
  13. data/ext/rbs_extension/ast_translation.c +21 -0
  14. data/ext/rbs_extension/class_constants.c +2 -0
  15. data/ext/rbs_extension/class_constants.h +1 -0
  16. data/ext/rbs_extension/extconf.rb +1 -0
  17. data/include/rbs/ast.h +314 -297
  18. data/include/rbs/defines.h +13 -0
  19. data/include/rbs/lexer.h +1 -0
  20. data/lib/rbs/annotate/rdoc_annotator.rb +27 -31
  21. data/lib/rbs/ast/ruby/annotations.rb +42 -0
  22. data/lib/rbs/ast/ruby/declarations.rb +11 -1
  23. data/lib/rbs/ast/ruby/members.rb +28 -0
  24. data/lib/rbs/cli.rb +3 -5
  25. data/lib/rbs/collection/config/lockfile_generator.rb +14 -1
  26. data/lib/rbs/environment.rb +6 -0
  27. data/lib/rbs/inline_parser.rb +49 -25
  28. data/lib/rbs/rewriter.rb +70 -0
  29. data/lib/rbs/test/type_check.rb +6 -1
  30. data/lib/rbs/version.rb +1 -1
  31. data/lib/rbs.rb +1 -0
  32. data/sig/annotate/rdoc_annotater.rbs +12 -9
  33. data/sig/ast/ruby/annotations.rbs +49 -0
  34. data/sig/ast/ruby/members.rbs +15 -0
  35. data/sig/collection/config/lockfile_generator.rbs +2 -0
  36. data/sig/inline_parser.rbs +2 -0
  37. data/sig/manifest.yaml +0 -1
  38. data/sig/rewriter.rbs +45 -0
  39. data/src/ast.c +109 -85
  40. data/src/lexer.c +137 -114
  41. data/src/lexer.re +1 -0
  42. data/src/lexstate.c +1 -0
  43. data/src/parser.c +55 -5
  44. data/stdlib/openssl/0/openssl.rbs +2 -2
  45. metadata +3 -1
@@ -16,6 +16,7 @@ module RBS
16
16
  | IncludeMember | ExtendMember | PrependMember
17
17
  | AttrReaderMember | AttrWriterMember | AttrAccessorMember
18
18
  | InstanceVariableMember
19
+ | ModuleSelfMember
19
20
 
20
21
  class MethodTypeAnnotation
21
22
  class DocStyle
@@ -172,6 +173,20 @@ module RBS
172
173
 
173
174
  def type_fingerprint: () -> untyped
174
175
  end
176
+
177
+ class ModuleSelfMember < Base
178
+ attr_reader annotation: Annotations::ModuleSelfAnnotation
179
+
180
+ def initialize: (Buffer, Annotations::ModuleSelfAnnotation) -> void
181
+
182
+ def name: () -> TypeName
183
+
184
+ def args: () -> Array[Types::t]
185
+
186
+ def location: () -> Location
187
+
188
+ def type_fingerprint: () -> untyped
189
+ end
175
190
  end
176
191
  end
177
192
  end
@@ -6,6 +6,8 @@ module RBS
6
6
  #
7
7
  ALUMNI_STDLIBS: Hash[String, String?]
8
8
 
9
+ NONGEM_STDLIBS: Set[String]
10
+
9
11
  class GemfileLockMismatchError < StandardError
10
12
  @expected: Pathname
11
13
 
@@ -110,6 +110,8 @@ module RBS
110
110
 
111
111
  def report_unused_block: (AST::Ruby::CommentBlock) -> void
112
112
 
113
+ def visit_class_or_module_body: (module_context, Prism::ClassNode | Prism::ModuleNode) -> void
114
+
113
115
  private
114
116
 
115
117
  def parse_mixin_call: (Prism::CallNode) -> void
data/sig/manifest.yaml CHANGED
@@ -1,5 +1,4 @@
1
1
  dependencies:
2
- - name: logger
3
2
  - name: json
4
3
  - name: optparse
5
4
  - name: tsort
data/sig/rewriter.rbs ADDED
@@ -0,0 +1,45 @@
1
+ module RBS
2
+ # Rewriter performs targeted character-range replacements on Buffer content.
3
+ #
4
+ # Unlike Writer which regenerates entire source from AST, Rewriter preserves
5
+ # everything outside the rewritten ranges, including non-documentation comments.
6
+ #
7
+ # Rewrite requests are buffered and applied all at once when `#string` is called.
8
+ #
9
+ class Rewriter
10
+ attr_reader buffer: Buffer
11
+
12
+ # Initialize with a toplevel buffer.
13
+ # Raises if the buffer has a parent (non-toplevel).
14
+ #
15
+ def initialize: (Buffer buffer) -> void
16
+
17
+ # Register a rewrite request for the given location.
18
+ #
19
+ def rewrite: (Location[untyped, untyped] location, String string) -> self
20
+
21
+ # Add a new comment before the earliest of the given locations.
22
+ #
23
+ def add_comment: (*Location[untyped, untyped] locations, content: String) -> self
24
+
25
+ # Replace an existing comment's content.
26
+ #
27
+ def replace_comment: (AST::Comment comment, content: String) -> self
28
+
29
+ # Delete an existing comment.
30
+ #
31
+ def delete_comment: (AST::Comment comment) -> self
32
+
33
+ # Apply all buffered rewrites and return the resulting string.
34
+ #
35
+ # Raises if any rewrite ranges overlap.
36
+ #
37
+ def string: () -> String
38
+
39
+ private
40
+
41
+ def format_comment: (String content, String indent) -> String
42
+
43
+ @rewrites: Array[[Location[untyped, untyped], String]]
44
+ end
45
+ end