rbs-inline 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f73d1f3ac7e111f773fe9b2d034dc5ccc3a8732f50aacf1a07655ad3450e24f4
4
- data.tar.gz: '082c1f8a6ef85a239f29563f1e95d6af0ac0af89c5860a6c552d56505a0a27ba'
3
+ metadata.gz: 3e5b1f22a68a9b238d2e620d2694a3296b58ced7435e8e8035f000beb1ce40f6
4
+ data.tar.gz: c81ba9017a9a54e2d8d4401d1ad8d6640fcfac87dd99ab060daad38df8fb3977
5
5
  SHA512:
6
- metadata.gz: 6002e610f1440abbfe351ee3c746e6c4c1f6dcae1a885fc9a5f60d701ebd0548620d8c6ffc6211bffd5830fd9c65901f7d7155d6de049a8670f0b72749f55b0c
7
- data.tar.gz: 61041de88fbc0048f48fc46c012e1d1a7ff66760aef73e288f60351705425f466d84a4d50488feac54bb58e50fb504916596a8ceaf8ee5f99c76919227ee431e
6
+ metadata.gz: 0f54053824e26053cb0c229c06c1cb8987af68fae1e5340747cc4424f1b549ead53c6ec10cfc4287aaa0aea350848bbccd8c8baa70311c791d5b7300ae9b431b
7
+ data.tar.gz: 52e6463d2240a0cc1373a15a326f18c1fd2c50ff22df210ed90e3dfd5cd635b43190e11321f8f903593b406b4ee7d3842f9ef3d3cc49a5a8735710b8e5f06901
data/README.md CHANGED
@@ -2,9 +2,6 @@
2
2
 
3
3
  RBS::Inline allows embedding RBS type declarations into Ruby code as comments. You can declare types, write the implementation, and verifies they are consistent without leaving the editor opening the Ruby code.
4
4
 
5
- > [!IMPORTANT]
6
- > The syntax is experimental. We are still seeking the best syntax with your feedbacks.
7
-
8
5
  > [!IMPORTANT]
9
6
  > This gem is a prototype for testing. We plan to merge this feature to rbs-gem and deprecate rbs-inline gem after that.
10
7
 
@@ -41,6 +41,10 @@ module RBS
41
41
  # ```
42
42
  attr_reader :visibility #: RBS::AST::Members::visibility?
43
43
 
44
+ # The function is defined as singleton and instance method (as known as module_function)
45
+ #
46
+ attr_accessor :singleton_instance #: bool
47
+
44
48
  # Assertion given at the end of the method name
45
49
  #
46
50
  attr_reader :assertion #: Annotations::TypeAssertion?
@@ -48,11 +52,13 @@ module RBS
48
52
  # @rbs node: Prism::DefNode
49
53
  # @rbs comments: AnnotationParser::ParsingResult?
50
54
  # @rbs visibility: RBS::AST::Members::visibility?
55
+ # @rbs singleton_instance: bool
51
56
  # @rbs assertion: Annotations::TypeAssertion?
52
- def initialize(node, comments, visibility, assertion) #: void
57
+ def initialize(node, comments, visibility, singleton_instance, assertion) #: void
53
58
  @node = node
54
59
  @comments = comments
55
60
  @visibility = visibility
61
+ @singleton_instance = singleton_instance
56
62
  @assertion = assertion
57
63
 
58
64
  super(node.location)
@@ -37,10 +37,14 @@ module RBS
37
37
  #
38
38
  attr_reader :current_visibility #: RBS::AST::Members::visibility?
39
39
 
40
+ # The current module_function applied to single `def` node
41
+ attr_reader :current_module_function #: bool
42
+
40
43
  def initialize() #: void
41
44
  @decls = []
42
45
  @surrounding_decls = []
43
46
  @comments = {}
47
+ @current_module_function = false
44
48
  end
45
49
 
46
50
  # Parses the given Prism result to a three tuple
@@ -253,9 +257,7 @@ module RBS
253
257
 
254
258
  assertion = assertion_annotation(node.rparen_loc || node&.parameters&.location || node.name_loc)
255
259
 
256
- current_decl.members << AST::Members::RubyDef.new(node, associated_comment, current_visibility, assertion)
257
-
258
- super
260
+ current_decl.members << AST::Members::RubyDef.new(node, associated_comment, current_visibility, current_module_function, assertion)
259
261
  end
260
262
  end
261
263
 
@@ -331,6 +333,30 @@ module RBS
331
333
  end
332
334
  end
333
335
  end
336
+ when :module_function
337
+ if node.arguments && node.arguments.arguments.size > 0
338
+ args = node.arguments.arguments.filter_map do |arg|
339
+ case arg
340
+ when Prism::SymbolNode
341
+ arg.unescaped.to_sym
342
+ end
343
+ end
344
+
345
+ current_decl = current_class_module_decl
346
+
347
+ if current_decl
348
+ node.arguments.arguments.each do |arg|
349
+ current_decl.members.each do |member|
350
+ if member.is_a?(AST::Members::RubyDef) && args.include?(member.node.name)
351
+ member.singleton_instance = true
352
+ break
353
+ end
354
+ end
355
+ end
356
+ end
357
+ else
358
+ @current_module_function = true
359
+ end
334
360
  end
335
361
 
336
362
  super
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RBS
4
4
  module Inline
5
- VERSION = "0.9.0"
5
+ VERSION = "0.10.0"
6
6
  end
7
7
  end
@@ -1,5 +1,7 @@
1
1
  # rbs_inline: enabled
2
2
 
3
+ require 'stringio'
4
+
3
5
  module RBS
4
6
  module Inline
5
7
  class Writer
@@ -542,6 +544,7 @@ module RBS
542
544
  # @rbs return: RBS::AST::Members::MethodDefinition::kind
543
545
  def method_kind(member, decl)
544
546
  return :singleton if decl
547
+ return :singleton_instance if member.singleton_instance
545
548
 
546
549
  case member.node.receiver
547
550
  when Prism::SelfNode
@@ -34,7 +34,7 @@ gems:
34
34
  source:
35
35
  type: stdlib
36
36
  - name: prism
37
- version: 1.0.0
37
+ version: 1.2.0
38
38
  source:
39
39
  type: rubygems
40
40
  - name: rake
@@ -42,11 +42,11 @@ gems:
42
42
  source:
43
43
  type: git
44
44
  name: ruby/gem_rbs_collection
45
- revision: 25b8cf2135233e112d93d6b64083ee5e419875b6
45
+ revision: 218cf130d31f63e110e350efc3fa265311b0f238
46
46
  remote: https://github.com/ruby/gem_rbs_collection.git
47
47
  repo_dir: gems
48
48
  - name: rbs
49
- version: 3.6.0
49
+ version: 3.6.1
50
50
  source:
51
51
  type: rubygems
52
52
  - name: rdoc
@@ -37,14 +37,18 @@ module RBS
37
37
  # ```
38
38
  attr_reader visibility: RBS::AST::Members::visibility?
39
39
 
40
+ # The function is defined as singleton and instance method (as known as module_function)
41
+ attr_accessor singleton_instance: bool
42
+
40
43
  # Assertion given at the end of the method name
41
44
  attr_reader assertion: Annotations::TypeAssertion?
42
45
 
43
46
  # @rbs node: Prism::DefNode
44
47
  # @rbs comments: AnnotationParser::ParsingResult?
45
48
  # @rbs visibility: RBS::AST::Members::visibility?
49
+ # @rbs singleton_instance: bool
46
50
  # @rbs assertion: Annotations::TypeAssertion?
47
- def initialize: (Prism::DefNode node, AnnotationParser::ParsingResult? comments, RBS::AST::Members::visibility? visibility, Annotations::TypeAssertion? assertion) -> void
51
+ def initialize: (Prism::DefNode node, AnnotationParser::ParsingResult? comments, RBS::AST::Members::visibility? visibility, bool singleton_instance, Annotations::TypeAssertion? assertion) -> void
48
52
 
49
53
  # Returns the name of the method
50
54
  def method_name: () -> Symbol
@@ -30,6 +30,9 @@ module RBS
30
30
  # `nil` when the `def` node is not inside `private` or `public` calls.
31
31
  attr_reader current_visibility: RBS::AST::Members::visibility?
32
32
 
33
+ # The current module_function applied to single `def` node
34
+ attr_reader current_module_function: bool
35
+
33
36
  def initialize: () -> void
34
37
 
35
38
  # Parses the given Prism result to a three tuple
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbs-inline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.10.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: 2024-10-01 00:00:00.000000000 Z
11
+ date: 2024-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prism
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '0.29'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '1.1'
22
+ version: '1.3'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '0.29'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '1.1'
32
+ version: '1.3'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rbs
35
35
  requirement: !ruby/object:Gem::Requirement