rbs-inline 0.2.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/rbs/inline/ast/annotations.rb +21 -0
- data/lib/rbs/inline/ast/comment_lines.rb +19 -2
- data/lib/rbs/inline/ast/declarations.rb +6 -13
- data/lib/rbs/inline/ast/members.rb +9 -26
- data/lib/rbs/inline/ast/tree.rb +88 -4
- data/lib/rbs/inline/cli.rb +17 -4
- data/lib/rbs/inline/node_utils.rb +4 -0
- data/lib/rbs/inline/parser.rb +26 -8
- data/lib/rbs/inline/version.rb +1 -1
- data/lib/rbs/inline/writer.rb +81 -9
- data/lib/rbs/inline.rb +3 -0
- data/rbs_collection.lock.yaml +3 -7
- data/rbs_collection.yaml +2 -0
- data/sig/generated/rbs/inline/ast/annotations.rbs +2 -0
- data/sig/{rbs → generated/rbs}/inline/ast/comment_lines.rbs +8 -4
- data/sig/generated/rbs/inline/ast/declarations.rbs +4 -1
- data/sig/generated/rbs/inline/ast/members.rbs +8 -10
- data/sig/{rbs → generated/rbs}/inline/ast/tree.rbs +49 -21
- data/sig/generated/rbs/inline/node_utils.rbs +11 -0
- data/sig/generated/rbs/inline/parser.rbs +8 -4
- data/sig/generated/rbs/inline/version.rbs +7 -0
- data/sig/generated/rbs/inline/writer.rbs +72 -0
- data/sig/generated/rbs/inline.rbs +7 -0
- metadata +20 -16
- data/sig/rbs/inline/annotation_parser.rbs +0 -0
- data/sig/rbs/inline/node_utils.rbs +0 -7
- data/sig/rbs/inline/writer.rbs +0 -27
- data/sig/rbs/inline.rbs +0 -41
- data/yard-samples/hello.rb +0 -6
- data/yard-samples/sample1.rb +0 -26
data/lib/rbs/inline/writer.rb
CHANGED
@@ -1,20 +1,27 @@
|
|
1
|
+
# rbs_inline: enabled
|
2
|
+
|
1
3
|
module RBS
|
2
4
|
module Inline
|
3
5
|
class Writer
|
4
|
-
attr_reader :output
|
5
|
-
attr_reader :writer
|
6
|
+
attr_reader :output #:: String
|
7
|
+
attr_reader :writer #:: RBS::Writer
|
6
8
|
|
9
|
+
# @rbs buffer: String
|
7
10
|
def initialize(buffer = +"")
|
8
11
|
@output = buffer
|
9
12
|
@writer = RBS::Writer.new(out: StringIO.new(buffer))
|
10
13
|
end
|
11
14
|
|
15
|
+
# @rbs uses: Array[AST::Annotations::Use]
|
16
|
+
# @rbs decls: Array[AST::Declarations::t]
|
12
17
|
def self.write(uses, decls)
|
13
18
|
writer = Writer.new()
|
14
19
|
writer.write(uses, decls)
|
15
20
|
writer.output
|
16
21
|
end
|
17
22
|
|
23
|
+
# @rbs lines: Array[String]
|
24
|
+
# @rbs returns void
|
18
25
|
def header(*lines)
|
19
26
|
lines.each do |line|
|
20
27
|
writer.out.puts("# " + line)
|
@@ -22,6 +29,9 @@ module RBS
|
|
22
29
|
writer.out.puts
|
23
30
|
end
|
24
31
|
|
32
|
+
# @rbs uses: Array[AST::Annotations::Use]
|
33
|
+
# @rbs decls: Array[AST::Declarations::t]
|
34
|
+
# @rbs returns void
|
25
35
|
def write(uses, decls)
|
26
36
|
use_dirs = uses.map do |use|
|
27
37
|
RBS::AST::Directives::Use.new(
|
@@ -37,6 +47,8 @@ module RBS
|
|
37
47
|
writer.write(use_dirs + rbs)
|
38
48
|
end
|
39
49
|
|
50
|
+
# @rbs decl: AST::Declarations::t
|
51
|
+
# @rbs returns RBS::AST::Declarations::t?
|
40
52
|
def translate_decl(decl)
|
41
53
|
case decl
|
42
54
|
when AST::Declarations::ClassDecl
|
@@ -48,6 +60,8 @@ module RBS
|
|
48
60
|
end
|
49
61
|
end
|
50
62
|
|
63
|
+
# @rbs decl: AST::Declarations::ClassDecl
|
64
|
+
# @rbs returns RBS::AST::Declarations::Class?
|
51
65
|
def translate_class_decl(decl)
|
52
66
|
return unless decl.class_name
|
53
67
|
|
@@ -59,12 +73,14 @@ module RBS
|
|
59
73
|
|
60
74
|
decl.members.each do |member|
|
61
75
|
if member.is_a?(AST::Members::Base)
|
62
|
-
if rbs_member = translate_member(member)
|
76
|
+
if rbs_member = translate_member(member, decl)
|
63
77
|
members.concat rbs_member
|
64
78
|
end
|
65
79
|
end
|
66
80
|
|
67
|
-
if member.is_a?(AST::Declarations::
|
81
|
+
if member.is_a?(AST::Declarations::SingletonClassDecl)
|
82
|
+
members.concat translate_singleton_decl(member)
|
83
|
+
elsif member.is_a?(AST::Declarations::Base)
|
68
84
|
if rbs = translate_decl(member)
|
69
85
|
members << rbs
|
70
86
|
end
|
@@ -82,6 +98,8 @@ module RBS
|
|
82
98
|
)
|
83
99
|
end
|
84
100
|
|
101
|
+
# @rbs decl: AST::Declarations::ModuleDecl
|
102
|
+
# @rbs returns RBS::AST::Declarations::Module?
|
85
103
|
def translate_module_decl(decl)
|
86
104
|
return unless decl.module_name
|
87
105
|
|
@@ -93,12 +111,14 @@ module RBS
|
|
93
111
|
|
94
112
|
decl.members.each do |member|
|
95
113
|
if member.is_a?(AST::Members::Base)
|
96
|
-
if rbs_member = translate_member(member)
|
114
|
+
if rbs_member = translate_member(member, decl)
|
97
115
|
members.concat rbs_member
|
98
116
|
end
|
99
117
|
end
|
100
118
|
|
101
|
-
if member.is_a?(AST::Declarations::
|
119
|
+
if member.is_a?(AST::Declarations::SingletonClassDecl)
|
120
|
+
members.concat translate_singleton_decl(member)
|
121
|
+
elsif member.is_a?(AST::Declarations::Base)
|
102
122
|
if rbs = translate_decl(member)
|
103
123
|
members << rbs
|
104
124
|
end
|
@@ -118,6 +138,8 @@ module RBS
|
|
118
138
|
)
|
119
139
|
end
|
120
140
|
|
141
|
+
# @rbs decl: AST::Declarations::ConstantDecl
|
142
|
+
# @rbs returns RBS::AST::Declarations::Constant?
|
121
143
|
def translate_constant_decl(decl)
|
122
144
|
return unless decl.constant_name
|
123
145
|
|
@@ -133,18 +155,39 @@ module RBS
|
|
133
155
|
)
|
134
156
|
end
|
135
157
|
|
136
|
-
|
158
|
+
# @rbs decl: AST::Declarations::SingletonClassDecl
|
159
|
+
# @rbs returns Array[RBS::AST::Members::t]
|
160
|
+
def translate_singleton_decl(decl)
|
161
|
+
members = []
|
162
|
+
|
163
|
+
decl.members.each do |member|
|
164
|
+
if member.is_a?(AST::Members::Base)
|
165
|
+
if rbs_member = translate_member(member, decl)
|
166
|
+
members.concat rbs_member
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
members
|
172
|
+
end
|
173
|
+
|
174
|
+
# @rbs member: AST::Members::t
|
175
|
+
# @rbs decl: AST::Declarations::ClassDecl | AST::Declarations::ModuleDecl | AST::Declarations::SingletonClassDecl
|
176
|
+
# @rbs returns Array[RBS::AST::Members::t | RBS::AST::Declarations::t]?
|
177
|
+
def translate_member(member, decl)
|
137
178
|
case member
|
138
179
|
when AST::Members::RubyDef
|
139
180
|
if member.comments
|
140
181
|
comment = RBS::AST::Comment.new(string: member.comments.content, location: nil)
|
141
182
|
end
|
142
183
|
|
184
|
+
kind = method_kind(member, decl)
|
185
|
+
|
143
186
|
if member.override_annotation
|
144
187
|
return [
|
145
188
|
RBS::AST::Members::MethodDefinition.new(
|
146
189
|
name: member.method_name,
|
147
|
-
kind:
|
190
|
+
kind: kind,
|
148
191
|
overloads: [],
|
149
192
|
annotations: [],
|
150
193
|
location: nil,
|
@@ -158,7 +201,7 @@ module RBS
|
|
158
201
|
[
|
159
202
|
RBS::AST::Members::MethodDefinition.new(
|
160
203
|
name: member.method_name,
|
161
|
-
kind:
|
204
|
+
kind: kind,
|
162
205
|
overloads: member.method_overloads,
|
163
206
|
annotations: member.method_annotations,
|
164
207
|
location: nil,
|
@@ -205,6 +248,35 @@ module RBS
|
|
205
248
|
end
|
206
249
|
end
|
207
250
|
end
|
251
|
+
|
252
|
+
private
|
253
|
+
|
254
|
+
# Returns the `kind` of the method definition
|
255
|
+
#
|
256
|
+
# ```rb
|
257
|
+
# def self.foo = () # :singleton
|
258
|
+
# class A
|
259
|
+
# class << self
|
260
|
+
# def bar = () # :singleton
|
261
|
+
# end
|
262
|
+
# end
|
263
|
+
#
|
264
|
+
# def object.foo = () # Not supported (returns :instance)
|
265
|
+
# ```
|
266
|
+
#
|
267
|
+
# @rbs member: AST::Members::RubyDef
|
268
|
+
# @rbs decl: AST::Declarations::ClassDecl | AST::Declarations::ModuleDecl | AST::Declarations::SingletonClassDecl
|
269
|
+
# @rbs returns RBS::AST::Members::MethodDefinition::kind
|
270
|
+
def method_kind(member, decl)
|
271
|
+
return :singleton if decl.is_a?(AST::Declarations::SingletonClassDecl)
|
272
|
+
|
273
|
+
case member.node.receiver
|
274
|
+
when Prism::SelfNode
|
275
|
+
:singleton
|
276
|
+
else
|
277
|
+
:instance
|
278
|
+
end
|
279
|
+
end
|
208
280
|
end
|
209
281
|
end
|
210
282
|
end
|
data/lib/rbs/inline.rb
CHANGED
data/rbs_collection.lock.yaml
CHANGED
@@ -1,10 +1,6 @@
|
|
1
1
|
---
|
2
2
|
path: ".gem_rbs_collection"
|
3
3
|
gems:
|
4
|
-
- name: abbrev
|
5
|
-
version: '0'
|
6
|
-
source:
|
7
|
-
type: stdlib
|
8
4
|
- name: fileutils
|
9
5
|
version: '0'
|
10
6
|
source:
|
@@ -38,7 +34,7 @@ gems:
|
|
38
34
|
source:
|
39
35
|
type: stdlib
|
40
36
|
- name: prism
|
41
|
-
version: 0.
|
37
|
+
version: 0.30.0
|
42
38
|
source:
|
43
39
|
type: rubygems
|
44
40
|
- name: rake
|
@@ -46,11 +42,11 @@ gems:
|
|
46
42
|
source:
|
47
43
|
type: git
|
48
44
|
name: ruby/gem_rbs_collection
|
49
|
-
revision:
|
45
|
+
revision: 4bf1c9687fc24cfbb30f4759653308c816f3a69f
|
50
46
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
51
47
|
repo_dir: gems
|
52
48
|
- name: rbs
|
53
|
-
version: 3.5.
|
49
|
+
version: 3.5.1
|
54
50
|
source:
|
55
51
|
type: rubygems
|
56
52
|
- name: rdoc
|
data/rbs_collection.yaml
CHANGED
@@ -4,6 +4,8 @@ module RBS
|
|
4
4
|
module Inline
|
5
5
|
module AST
|
6
6
|
module Annotations
|
7
|
+
type t = VarType | ReturnType | Use | Inherits | Generic | ModuleSelf | Skip | Assertion | Application | RBSAnnotation | Override | IvarType | Yields | Embedded
|
8
|
+
|
7
9
|
class Base
|
8
10
|
attr_reader source: CommentLines
|
9
11
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# Generated from lib/rbs/inline/ast/comment_lines.rb with RBS::Inline
|
2
|
+
|
1
3
|
module RBS
|
2
4
|
module Inline
|
3
5
|
module AST
|
@@ -12,15 +14,17 @@ module RBS
|
|
12
14
|
#
|
13
15
|
# We want to get a String of comment1 and comment2, `"Hello\nWorld".
|
14
16
|
# And want to translate a location in the string into the location in comment1 and comment2.
|
15
|
-
#
|
16
17
|
class CommentLines
|
17
|
-
attr_reader comments: Array[[Prism::Comment, Integer]]
|
18
|
+
attr_reader comments: Array[[ Prism::Comment, Integer ]]
|
18
19
|
|
19
|
-
|
20
|
+
# @rbs comments: Array[Prism::Comment]
|
21
|
+
def initialize: (Array[Prism::Comment] comments) -> untyped
|
20
22
|
|
21
23
|
def string: () -> String
|
22
24
|
|
23
|
-
|
25
|
+
# @rbs index: Integer
|
26
|
+
# @rbs returns [Prism::Comment, Integer]?
|
27
|
+
def comment_location: (Integer index) -> [ Prism::Comment, Integer ]?
|
24
28
|
end
|
25
29
|
end
|
26
30
|
end
|
@@ -10,7 +10,7 @@ module RBS
|
|
10
10
|
def type_name: (Prism::Node node) -> TypeName?
|
11
11
|
end
|
12
12
|
|
13
|
-
type t = ClassDecl | ModuleDecl | ConstantDecl
|
13
|
+
type t = ClassDecl | ModuleDecl | ConstantDecl | SingletonClassDecl
|
14
14
|
|
15
15
|
interface _WithComments
|
16
16
|
def comments: () -> AnnotationParser::ParsingResult?
|
@@ -110,6 +110,9 @@ module RBS
|
|
110
110
|
|
111
111
|
def start_line: () -> Integer
|
112
112
|
end
|
113
|
+
|
114
|
+
class SingletonClassDecl < ModuleOrClass[Prism::SingletonClassNode]
|
115
|
+
end
|
113
116
|
end
|
114
117
|
end
|
115
118
|
end
|
@@ -4,6 +4,12 @@ module RBS
|
|
4
4
|
module Inline
|
5
5
|
module AST
|
6
6
|
module Members
|
7
|
+
type ruby = RubyDef | RubyAlias | RubyMixin | RubyAttr | RubyPublic | RubyPrivate
|
8
|
+
|
9
|
+
type rbs = RBSIvar | RBSEmbedded
|
10
|
+
|
11
|
+
type t = ruby | rbs
|
12
|
+
|
7
13
|
class Base
|
8
14
|
attr_reader location: Prism::Location
|
9
15
|
|
@@ -44,16 +50,6 @@ module RBS
|
|
44
50
|
|
45
51
|
def method_type_annotations: () -> Array[Annotations::Assertion]
|
46
52
|
|
47
|
-
# Returns the `kind` of the method definition
|
48
|
-
#
|
49
|
-
# [FIXME] It only supports `self` receiver.
|
50
|
-
#
|
51
|
-
# ```rb
|
52
|
-
# def self.foo = () # :singleton
|
53
|
-
# def object.foo = () # Not supported (returns :instance)
|
54
|
-
# ```
|
55
|
-
def method_kind: () -> RBS::AST::Members::MethodDefinition::kind
|
56
|
-
|
57
53
|
def return_type: () -> Types::t?
|
58
54
|
|
59
55
|
def var_type_hash: () -> Hash[Symbol, Types::t?]
|
@@ -84,6 +80,8 @@ module RBS
|
|
84
80
|
end
|
85
81
|
|
86
82
|
class RubyMixin < RubyBase
|
83
|
+
include Declarations::ConstantUtil
|
84
|
+
|
87
85
|
# CallNode that calls `include`, `prepend`, and `extend` method
|
88
86
|
attr_reader node: Prism::CallNode
|
89
87
|
|
@@ -1,97 +1,125 @@
|
|
1
|
+
# Generated from lib/rbs/inline/ast/tree.rb with RBS::Inline
|
2
|
+
|
1
3
|
module RBS
|
2
4
|
module Inline
|
3
5
|
module AST
|
4
6
|
class Tree
|
5
|
-
type token = [Symbol, String]
|
7
|
+
type token = [ Symbol, String ]
|
6
8
|
|
7
9
|
type tree = token | Tree | Types::t | MethodType | nil
|
8
10
|
|
9
11
|
attr_reader trees: Array[tree]
|
10
12
|
|
13
|
+
attr_reader type: Symbol
|
14
|
+
|
11
15
|
# Children but without `tWHITESPACE` tokens
|
12
|
-
#
|
13
16
|
attr_reader non_trivia_trees: Array[tree]
|
14
17
|
|
15
|
-
|
18
|
+
# @rbs type: Symbol
|
19
|
+
def initialize: (Symbol type) -> untyped
|
16
20
|
|
17
|
-
|
21
|
+
# @rbs tok: tree
|
22
|
+
# @rbs returns self
|
23
|
+
def <<: (tree tok) -> self
|
18
24
|
|
19
|
-
|
25
|
+
# Returns the source code associated to the tree
|
26
|
+
def to_s: () -> String
|
20
27
|
|
21
28
|
# Returns n-th token from the children
|
22
29
|
#
|
23
30
|
# Raises if the value is not a token or nil.
|
24
31
|
#
|
25
|
-
|
32
|
+
# @rbs index: Integer
|
33
|
+
# @rbs returns token?
|
34
|
+
def nth_token: (Integer index) -> token?
|
26
35
|
|
27
36
|
# Returns n-th token from the children
|
28
37
|
#
|
29
38
|
# Returns `nil` if the value is not a token.
|
30
39
|
#
|
31
|
-
|
40
|
+
# @rbs index: Integer
|
41
|
+
# @rbs returns token?
|
42
|
+
def nth_token?: (Integer index) -> token?
|
32
43
|
|
33
44
|
# Returns n-th token from the children
|
34
45
|
#
|
35
46
|
# Raises if the value is not token.
|
36
47
|
#
|
37
|
-
|
48
|
+
# @rbs index: Integer
|
49
|
+
# @rbs returns token
|
50
|
+
def nth_token!: (Integer index) -> token
|
38
51
|
|
39
52
|
# Returns n-th tree from the children
|
40
53
|
#
|
41
54
|
# Raises if the value is not a tree or nil.
|
42
55
|
#
|
43
|
-
|
56
|
+
# @rbs index: Integer
|
57
|
+
# @rbs returns Tree?
|
58
|
+
def nth_tree: (Integer index) -> Tree?
|
44
59
|
|
45
60
|
# Returns n-th tree from the children
|
46
61
|
#
|
47
62
|
# Returns `nil` if the value is not a tree or nil.
|
48
63
|
#
|
49
|
-
|
64
|
+
# @rbs index: Integer
|
65
|
+
# @rbs returns Tree?
|
66
|
+
def nth_tree?: (Integer index) -> Tree?
|
50
67
|
|
51
68
|
# Returns n-th tree from the children
|
52
69
|
#
|
53
70
|
# Raises if the value is not a tree.
|
54
71
|
#
|
55
|
-
|
72
|
+
# @rbs index: Integer
|
73
|
+
# @rbs returns Tree
|
74
|
+
def nth_tree!: (Integer index) -> Tree
|
56
75
|
|
57
76
|
# Returns n-th type from the children
|
58
77
|
#
|
59
|
-
# Raises if the value is not a
|
78
|
+
# Raises if the value is not a type or nil.
|
60
79
|
#
|
61
|
-
|
80
|
+
# @rbs index: Integer
|
81
|
+
# @rbs returns Types::t?
|
82
|
+
def nth_type: (Integer index) -> Types::t?
|
62
83
|
|
63
84
|
# Returns n-th type from the children
|
64
85
|
#
|
65
86
|
# Returns `nil` if the value is not a type.
|
66
87
|
#
|
67
|
-
|
88
|
+
# @rbs index: Integer
|
89
|
+
# @rbs returns Types::t?
|
90
|
+
def nth_type?: (Integer index) -> Types::t?
|
68
91
|
|
69
92
|
# Returns n-th type from the children
|
70
93
|
#
|
71
94
|
# Raises if the value is not a type.
|
72
95
|
#
|
73
|
-
|
96
|
+
# @rbs index: Integer
|
97
|
+
# @rbs returns Types::t
|
98
|
+
def nth_type!: (Integer index) -> Types::t
|
74
99
|
|
75
100
|
# Returns n-th method type from the children
|
76
101
|
#
|
77
102
|
# Raises if the value is not a method type or `nil`.
|
78
103
|
#
|
79
|
-
|
104
|
+
# @rbs index: Integer
|
105
|
+
# @rbs returns MethodType?
|
106
|
+
def nth_method_type: (Integer index) -> MethodType?
|
80
107
|
|
81
108
|
# Returns n-th method type from the children
|
82
109
|
#
|
83
110
|
# Returns `nil` if the value is not a method type.
|
84
111
|
#
|
85
|
-
|
112
|
+
# @rbs index: Integer
|
113
|
+
# @rbs returns MethodType?
|
114
|
+
def nth_method_type?: (Integer index) -> MethodType?
|
86
115
|
|
87
116
|
# Returns n-th method tree from the children
|
88
117
|
#
|
89
118
|
# Raises if the value is not a method tree.
|
90
119
|
#
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
def to_s: () -> String
|
120
|
+
# @rbs index: Integer
|
121
|
+
# @rbs returns MethodType
|
122
|
+
def nth_method_type!: (Integer index) -> MethodType
|
95
123
|
end
|
96
124
|
end
|
97
125
|
end
|
@@ -30,9 +30,10 @@ module RBS
|
|
30
30
|
|
31
31
|
def initialize: () -> void
|
32
32
|
|
33
|
-
# @rbs result: ParseResult
|
33
|
+
# @rbs result: ParseResult
|
34
|
+
# @rbs opt_in: bool -- `true` for *opt-out* mode, `false` for *opt-in* mode.
|
34
35
|
# @rbs returns [Array[AST::Annotations::Use], Array[AST::Declarations::t]]?
|
35
|
-
def self.parse: (ParseResult
|
36
|
+
def self.parse: (ParseResult result, opt_in: bool) -> [ Array[AST::Annotations::Use], Array[AST::Declarations::t] ]?
|
36
37
|
|
37
38
|
# @rbs returns AST::Declarations::ModuleDecl | AST::Declarations::ClassDecl | nil
|
38
39
|
def current_class_module_decl: () -> (AST::Declarations::ModuleDecl | AST::Declarations::ClassDecl | nil)
|
@@ -40,9 +41,9 @@ module RBS
|
|
40
41
|
# @rbs returns AST::Declarations::ModuleDecl | AST::Declarations::ClassDecl
|
41
42
|
def current_class_module_decl!: () -> (AST::Declarations::ModuleDecl | AST::Declarations::ClassDecl)
|
42
43
|
|
43
|
-
# :: (AST::Declarations::ModuleDecl | AST::Declarations::ClassDecl) { () -> void } -> void
|
44
|
+
# :: (AST::Declarations::ModuleDecl | AST::Declarations::ClassDecl | AST::Declarations::SingletonClassDecl) { () -> void } -> void
|
44
45
|
# :: (AST::Declarations::ConstantDecl) -> void
|
45
|
-
def push_class_module_decl: (AST::Declarations::ModuleDecl | AST::Declarations::ClassDecl) { () -> void } -> void
|
46
|
+
def push_class_module_decl: (AST::Declarations::ModuleDecl | AST::Declarations::ClassDecl | AST::Declarations::SingletonClassDecl) { () -> void } -> void
|
46
47
|
| (AST::Declarations::ConstantDecl) -> void
|
47
48
|
|
48
49
|
# Load inner declarations and delete them from `#comments` hash
|
@@ -59,6 +60,9 @@ module RBS
|
|
59
60
|
# @rbs override
|
60
61
|
def visit_class_node: ...
|
61
62
|
|
63
|
+
# @rbs override
|
64
|
+
def visit_singleton_class_node: ...
|
65
|
+
|
62
66
|
# @rbs override
|
63
67
|
def visit_module_node: ...
|
64
68
|
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# Generated from lib/rbs/inline/writer.rb with RBS::Inline
|
2
|
+
|
3
|
+
module RBS
|
4
|
+
module Inline
|
5
|
+
class Writer
|
6
|
+
attr_reader output: String
|
7
|
+
|
8
|
+
attr_reader writer: RBS::Writer
|
9
|
+
|
10
|
+
# @rbs buffer: String
|
11
|
+
def initialize: (?String buffer) -> untyped
|
12
|
+
|
13
|
+
# @rbs uses: Array[AST::Annotations::Use]
|
14
|
+
# @rbs decls: Array[AST::Declarations::t]
|
15
|
+
def self.write: (Array[AST::Annotations::Use] uses, Array[AST::Declarations::t] decls) -> untyped
|
16
|
+
|
17
|
+
# @rbs lines: Array[String]
|
18
|
+
# @rbs returns void
|
19
|
+
def header: (*String lines) -> void
|
20
|
+
|
21
|
+
# @rbs uses: Array[AST::Annotations::Use]
|
22
|
+
# @rbs decls: Array[AST::Declarations::t]
|
23
|
+
# @rbs returns void
|
24
|
+
def write: (Array[AST::Annotations::Use] uses, Array[AST::Declarations::t] decls) -> void
|
25
|
+
|
26
|
+
# @rbs decl: AST::Declarations::t
|
27
|
+
# @rbs returns RBS::AST::Declarations::t?
|
28
|
+
def translate_decl: (AST::Declarations::t decl) -> RBS::AST::Declarations::t?
|
29
|
+
|
30
|
+
# @rbs decl: AST::Declarations::ClassDecl
|
31
|
+
# @rbs returns RBS::AST::Declarations::Class?
|
32
|
+
def translate_class_decl: (AST::Declarations::ClassDecl decl) -> RBS::AST::Declarations::Class?
|
33
|
+
|
34
|
+
# @rbs decl: AST::Declarations::ModuleDecl
|
35
|
+
# @rbs returns RBS::AST::Declarations::Module?
|
36
|
+
def translate_module_decl: (AST::Declarations::ModuleDecl decl) -> RBS::AST::Declarations::Module?
|
37
|
+
|
38
|
+
# @rbs decl: AST::Declarations::ConstantDecl
|
39
|
+
# @rbs returns RBS::AST::Declarations::Constant?
|
40
|
+
def translate_constant_decl: (AST::Declarations::ConstantDecl decl) -> RBS::AST::Declarations::Constant?
|
41
|
+
|
42
|
+
# @rbs decl: AST::Declarations::SingletonClassDecl
|
43
|
+
# @rbs returns Array[RBS::AST::Members::t]
|
44
|
+
def translate_singleton_decl: (AST::Declarations::SingletonClassDecl decl) -> Array[RBS::AST::Members::t]
|
45
|
+
|
46
|
+
# @rbs member: AST::Members::t
|
47
|
+
# @rbs decl: AST::Declarations::ClassDecl | AST::Declarations::ModuleDecl | AST::Declarations::SingletonClassDecl
|
48
|
+
# @rbs returns Array[RBS::AST::Members::t | RBS::AST::Declarations::t]?
|
49
|
+
def translate_member: (AST::Members::t member, AST::Declarations::ClassDecl | AST::Declarations::ModuleDecl | AST::Declarations::SingletonClassDecl decl) -> Array[RBS::AST::Members::t | RBS::AST::Declarations::t]?
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
# Returns the `kind` of the method definition
|
54
|
+
#
|
55
|
+
# ```rb
|
56
|
+
# def self.foo = () # :singleton
|
57
|
+
# class A
|
58
|
+
# class << self
|
59
|
+
# def bar = () # :singleton
|
60
|
+
# end
|
61
|
+
# end
|
62
|
+
#
|
63
|
+
# def object.foo = () # Not supported (returns :instance)
|
64
|
+
# ```
|
65
|
+
#
|
66
|
+
# @rbs member: AST::Members::RubyDef
|
67
|
+
# @rbs decl: AST::Declarations::ClassDecl | AST::Declarations::ModuleDecl | AST::Declarations::SingletonClassDecl
|
68
|
+
# @rbs returns RBS::AST::Members::MethodDefinition::kind
|
69
|
+
def method_kind: (AST::Members::RubyDef member, AST::Declarations::ClassDecl | AST::Declarations::ModuleDecl | AST::Declarations::SingletonClassDecl decl) -> RBS::AST::Members::MethodDefinition::kind
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|