rbs-inline 0.4.0 → 0.5.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 +8 -5
- data/Rakefile +12 -0
- data/lib/rbs/inline/annotation_parser/tokenizer.rb +361 -0
- data/lib/rbs/inline/annotation_parser.rb +548 -326
- data/lib/rbs/inline/ast/annotations.rb +427 -138
- data/lib/rbs/inline/ast/comment_lines.rb +17 -20
- data/lib/rbs/inline/ast/declarations.rb +64 -28
- data/lib/rbs/inline/ast/members.rb +129 -115
- data/lib/rbs/inline/ast/tree.rb +37 -22
- data/lib/rbs/inline/cli.rb +12 -12
- data/lib/rbs/inline/node_utils.rb +1 -1
- data/lib/rbs/inline/parser.rb +134 -65
- data/lib/rbs/inline/version.rb +1 -1
- data/lib/rbs/inline/writer.rb +195 -118
- data/lib/rbs/inline.rb +1 -0
- data/sig/generated/rbs/inline/annotation_parser/tokenizer.rbs +221 -0
- data/sig/generated/rbs/inline/annotation_parser.rbs +148 -92
- data/sig/generated/rbs/inline/ast/annotations.rbs +141 -37
- data/sig/generated/rbs/inline/ast/comment_lines.rbs +8 -4
- data/sig/generated/rbs/inline/ast/declarations.rbs +26 -10
- data/sig/generated/rbs/inline/ast/members.rbs +26 -15
- data/sig/generated/rbs/inline/ast/tree.rbs +23 -17
- data/sig/generated/rbs/inline/cli.rbs +3 -3
- data/sig/generated/rbs/inline/node_utils.rbs +1 -1
- data/sig/generated/rbs/inline/parser.rbs +35 -18
- data/sig/generated/rbs/inline/writer.rbs +54 -22
- metadata +4 -2
@@ -6,11 +6,11 @@ module RBS
|
|
6
6
|
module Declarations
|
7
7
|
module ConstantUtil
|
8
8
|
# @rbs node: Prism::Node
|
9
|
-
# @rbs
|
9
|
+
# @rbs return: TypeName?
|
10
10
|
def type_name: (Prism::Node node) -> TypeName?
|
11
11
|
end
|
12
12
|
|
13
|
-
type t = ClassDecl | ModuleDecl | ConstantDecl | SingletonClassDecl
|
13
|
+
type t = ClassDecl | ModuleDecl | ConstantDecl | SingletonClassDecl | BlockDecl
|
14
14
|
|
15
15
|
interface _WithComments
|
16
16
|
def comments: () -> AnnotationParser::ParsingResult?
|
@@ -18,7 +18,7 @@ module RBS
|
|
18
18
|
|
19
19
|
# @rbs module-self _WithComments
|
20
20
|
module Generics : _WithComments
|
21
|
-
# @rbs
|
21
|
+
# @rbs return: Array[RBS::AST::TypeParam]
|
22
22
|
def type_params: () -> Array[RBS::AST::TypeParam]
|
23
23
|
end
|
24
24
|
|
@@ -55,7 +55,7 @@ module RBS
|
|
55
55
|
# @rbs node: Prism::ClassNode
|
56
56
|
# @rbs comments: AnnotationParser::ParsingResult?
|
57
57
|
# @rbs super_app: Annotations::Application?
|
58
|
-
# @rbs
|
58
|
+
# @rbs return: void
|
59
59
|
def initialize: (Prism::ClassNode node, AnnotationParser::ParsingResult? comments, Annotations::Application? super_app) -> void
|
60
60
|
|
61
61
|
# @rbs %a{pure}
|
@@ -86,25 +86,25 @@ module RBS
|
|
86
86
|
|
87
87
|
attr_reader comments: AnnotationParser::ParsingResult?
|
88
88
|
|
89
|
-
attr_reader assertion: Annotations::
|
89
|
+
attr_reader assertion: Annotations::TypeAssertion?
|
90
90
|
|
91
91
|
# @rbs node: Prism::ConstantWriteNode
|
92
92
|
# @rbs comments: AnnotationParser::ParsingResult?
|
93
|
-
# @rbs assertion: Annotations::
|
94
|
-
def initialize: (Prism::ConstantWriteNode node, AnnotationParser::ParsingResult? comments, Annotations::
|
93
|
+
# @rbs assertion: Annotations::TypeAssertion?
|
94
|
+
def initialize: (Prism::ConstantWriteNode node, AnnotationParser::ParsingResult? comments, Annotations::TypeAssertion? assertion) -> void
|
95
95
|
|
96
96
|
# @rbs %a{pure}
|
97
|
-
# @rbs
|
97
|
+
# @rbs return: Types::t
|
98
98
|
%a{pure}
|
99
99
|
def type: () -> Types::t
|
100
100
|
|
101
101
|
# @rbs %a{pure}
|
102
102
|
# @rbs return Types::t?
|
103
103
|
%a{pure}
|
104
|
-
def literal_type: () ->
|
104
|
+
def literal_type: () -> Types::t?
|
105
105
|
|
106
106
|
# @rbs %a{pure}
|
107
|
-
# @rbs
|
107
|
+
# @rbs return: TypeName?
|
108
108
|
%a{pure}
|
109
109
|
def constant_name: () -> TypeName?
|
110
110
|
|
@@ -113,6 +113,22 @@ module RBS
|
|
113
113
|
|
114
114
|
class SingletonClassDecl < ModuleOrClass[Prism::SingletonClassNode]
|
115
115
|
end
|
116
|
+
|
117
|
+
class BlockDecl < Base
|
118
|
+
attr_reader node: Prism::BlockNode
|
119
|
+
|
120
|
+
attr_reader comments: AnnotationParser::ParsingResult?
|
121
|
+
|
122
|
+
# Members included in the declaration
|
123
|
+
attr_reader members: Array[Members::t | t]
|
124
|
+
|
125
|
+
# @rbs (Prism::BlockNode, AnnotationParser::ParsingResult?) -> void
|
126
|
+
def initialize: (Prism::BlockNode, AnnotationParser::ParsingResult?) -> void
|
127
|
+
|
128
|
+
def start_line: () -> Integer
|
129
|
+
|
130
|
+
def module_class_annotation: () -> (Annotations::ModuleDecl | Annotations::ClassDecl | nil)
|
131
|
+
end
|
116
132
|
end
|
117
133
|
end
|
118
134
|
end
|
@@ -37,30 +37,41 @@ module RBS
|
|
37
37
|
# ```
|
38
38
|
attr_reader visibility: RBS::AST::Members::visibility?
|
39
39
|
|
40
|
-
|
40
|
+
# Assertion given at the end of the method name
|
41
|
+
attr_reader assertion: Annotations::TypeAssertion?
|
41
42
|
|
42
43
|
# @rbs node: Prism::DefNode
|
43
44
|
# @rbs comments: AnnotationParser::ParsingResult?
|
44
45
|
# @rbs visibility: RBS::AST::Members::visibility?
|
45
|
-
# @rbs assertion: Annotations::
|
46
|
-
def initialize: (Prism::DefNode node, AnnotationParser::ParsingResult? comments, RBS::AST::Members::visibility? visibility, Annotations::
|
46
|
+
# @rbs assertion: Annotations::TypeAssertion?
|
47
|
+
def initialize: (Prism::DefNode node, AnnotationParser::ParsingResult? comments, RBS::AST::Members::visibility? visibility, Annotations::TypeAssertion? assertion) -> void
|
47
48
|
|
48
49
|
# Returns the name of the method
|
49
50
|
def method_name: () -> Symbol
|
50
51
|
|
51
|
-
|
52
|
+
# Returns `nil` if no `@rbs METHOD-TYPE` or `#:` annotation is given
|
53
|
+
#
|
54
|
+
# Returns an empty array if only `...` method type is given.
|
55
|
+
def annotated_method_types: () -> Array[MethodType]?
|
52
56
|
|
53
57
|
def return_type: () -> Types::t?
|
54
58
|
|
55
59
|
def var_type_hash: () -> Hash[Symbol, Types::t?]
|
56
60
|
|
61
|
+
def splat_param_type_annotation: () -> Annotations::SplatParamType?
|
62
|
+
|
63
|
+
def double_splat_param_type_annotation: () -> Annotations::DoubleSplatParamType?
|
64
|
+
|
65
|
+
def overloading?: () -> bool
|
66
|
+
|
57
67
|
def method_overloads: () -> Array[RBS::AST::Members::MethodDefinition::Overload]
|
58
68
|
|
59
69
|
def method_annotations: () -> Array[RBS::AST::Annotation]
|
60
70
|
|
71
|
+
# Returns the `@rbs override` annotation
|
61
72
|
def override_annotation: () -> AST::Annotations::Override?
|
62
73
|
|
63
|
-
def
|
74
|
+
def block_type_annotation: () -> AST::Annotations::BlockType?
|
64
75
|
end
|
65
76
|
|
66
77
|
class RubyAlias < RubyBase
|
@@ -70,12 +81,12 @@ module RBS
|
|
70
81
|
|
71
82
|
# @rbs node: Prism::AliasMethodNode
|
72
83
|
# @rbs comments: AnnotationParser::ParsingResult?
|
73
|
-
def initialize: (Prism::AliasMethodNode node, AnnotationParser::ParsingResult? comments) ->
|
84
|
+
def initialize: (Prism::AliasMethodNode node, AnnotationParser::ParsingResult? comments) -> void
|
74
85
|
|
75
|
-
# @rbs
|
86
|
+
# @rbs return: Symbol -- the name of *old* method
|
76
87
|
def old_name: () -> Symbol
|
77
88
|
|
78
|
-
# @rbs
|
89
|
+
# @rbs return: Symbol -- the name of *new* method
|
79
90
|
def new_name: () -> Symbol
|
80
91
|
end
|
81
92
|
|
@@ -94,10 +105,10 @@ module RBS
|
|
94
105
|
# @rbs node: Prism::CallNode
|
95
106
|
# @rbs comments: AnnotationParser::ParsingResult?
|
96
107
|
# @rbs application: Annotations::Application?
|
97
|
-
# @rbs
|
108
|
+
# @rbs return: void
|
98
109
|
def initialize: (Prism::CallNode node, AnnotationParser::ParsingResult? comments, Annotations::Application? application) -> void
|
99
110
|
|
100
|
-
# @rbs
|
111
|
+
# @rbs return: ::RBS::AST::Members::Include
|
101
112
|
# | ::RBS::AST::Members::Extend
|
102
113
|
# | ::RBS::AST::Members::Prepend
|
103
114
|
# | nil
|
@@ -109,16 +120,16 @@ module RBS
|
|
109
120
|
|
110
121
|
attr_reader comments: AnnotationParser::ParsingResult?
|
111
122
|
|
112
|
-
attr_reader assertion: Annotations::
|
123
|
+
attr_reader assertion: Annotations::TypeAssertion?
|
113
124
|
|
114
125
|
# @rbs node: Prism::CallNode
|
115
126
|
# @rbs comments: AnnotationParser::ParsingResult?
|
116
|
-
# @rbs assertion: Annotations::
|
117
|
-
# @rbs
|
118
|
-
def initialize: (Prism::CallNode node, AnnotationParser::ParsingResult? comments, Annotations::
|
127
|
+
# @rbs assertion: Annotations::TypeAssertion?
|
128
|
+
# @rbs return: void
|
129
|
+
def initialize: (Prism::CallNode node, AnnotationParser::ParsingResult? comments, Annotations::TypeAssertion? assertion) -> void
|
119
130
|
|
120
131
|
# @rbs return Array[RBS::AST::Members::AttrReader | RBS::AST::Members::AttrWriter | RBS::AST::Members::AttrAccessor]?
|
121
|
-
def rbs: () ->
|
132
|
+
def rbs: () -> Array[RBS::AST::Members::AttrReader | RBS::AST::Members::AttrWriter | RBS::AST::Members::AttrAccessor]?
|
122
133
|
|
123
134
|
# Returns the type of the attribute
|
124
135
|
#
|
@@ -3,11 +3,11 @@
|
|
3
3
|
module RBS
|
4
4
|
module Inline
|
5
5
|
module AST
|
6
|
-
|
7
|
-
type token = [ Symbol, String ]
|
6
|
+
type token = [ Symbol, String ]
|
8
7
|
|
9
|
-
|
8
|
+
type tree = token | Tree | Types::t | MethodType | nil
|
10
9
|
|
10
|
+
class Tree
|
11
11
|
attr_reader trees: Array[tree]
|
12
12
|
|
13
13
|
attr_reader type: Symbol
|
@@ -16,21 +16,27 @@ module RBS
|
|
16
16
|
attr_reader non_trivia_trees: Array[tree]
|
17
17
|
|
18
18
|
# @rbs type: Symbol
|
19
|
-
def initialize: (Symbol type) ->
|
19
|
+
def initialize: (Symbol type) -> void
|
20
20
|
|
21
21
|
# @rbs tok: tree
|
22
|
-
# @rbs
|
22
|
+
# @rbs return: self
|
23
23
|
def <<: (tree tok) -> self
|
24
24
|
|
25
25
|
# Returns the source code associated to the tree
|
26
26
|
def to_s: () -> String
|
27
27
|
|
28
|
+
# Returns `true` if token at the given index is of the given type
|
29
|
+
def token?: (untyped type, at: untyped) -> untyped
|
30
|
+
|
31
|
+
# Returns `true` if tree at the given index is of the given type
|
32
|
+
def tree?: (untyped type, at: untyped) -> untyped
|
33
|
+
|
28
34
|
# Returns n-th token from the children
|
29
35
|
#
|
30
36
|
# Raises if the value is not a token or nil.
|
31
37
|
#
|
32
38
|
# @rbs index: Integer
|
33
|
-
# @rbs
|
39
|
+
# @rbs return: token?
|
34
40
|
def nth_token: (Integer index) -> token?
|
35
41
|
|
36
42
|
# Returns n-th token from the children
|
@@ -38,7 +44,7 @@ module RBS
|
|
38
44
|
# Returns `nil` if the value is not a token.
|
39
45
|
#
|
40
46
|
# @rbs index: Integer
|
41
|
-
# @rbs
|
47
|
+
# @rbs return: token?
|
42
48
|
def nth_token?: (Integer index) -> token?
|
43
49
|
|
44
50
|
# Returns n-th token from the children
|
@@ -46,7 +52,7 @@ module RBS
|
|
46
52
|
# Raises if the value is not token.
|
47
53
|
#
|
48
54
|
# @rbs index: Integer
|
49
|
-
# @rbs
|
55
|
+
# @rbs return: token
|
50
56
|
def nth_token!: (Integer index) -> token
|
51
57
|
|
52
58
|
# Returns n-th tree from the children
|
@@ -54,7 +60,7 @@ module RBS
|
|
54
60
|
# Raises if the value is not a tree or nil.
|
55
61
|
#
|
56
62
|
# @rbs index: Integer
|
57
|
-
# @rbs
|
63
|
+
# @rbs return: Tree?
|
58
64
|
def nth_tree: (Integer index) -> Tree?
|
59
65
|
|
60
66
|
# Returns n-th tree from the children
|
@@ -62,7 +68,7 @@ module RBS
|
|
62
68
|
# Returns `nil` if the value is not a tree or nil.
|
63
69
|
#
|
64
70
|
# @rbs index: Integer
|
65
|
-
# @rbs
|
71
|
+
# @rbs return: Tree?
|
66
72
|
def nth_tree?: (Integer index) -> Tree?
|
67
73
|
|
68
74
|
# Returns n-th tree from the children
|
@@ -70,7 +76,7 @@ module RBS
|
|
70
76
|
# Raises if the value is not a tree.
|
71
77
|
#
|
72
78
|
# @rbs index: Integer
|
73
|
-
# @rbs
|
79
|
+
# @rbs return: Tree
|
74
80
|
def nth_tree!: (Integer index) -> Tree
|
75
81
|
|
76
82
|
# Returns n-th type from the children
|
@@ -78,7 +84,7 @@ module RBS
|
|
78
84
|
# Raises if the value is not a type or nil.
|
79
85
|
#
|
80
86
|
# @rbs index: Integer
|
81
|
-
# @rbs
|
87
|
+
# @rbs return: Types::t?
|
82
88
|
def nth_type: (Integer index) -> Types::t?
|
83
89
|
|
84
90
|
# Returns n-th type from the children
|
@@ -86,7 +92,7 @@ module RBS
|
|
86
92
|
# Returns `nil` if the value is not a type.
|
87
93
|
#
|
88
94
|
# @rbs index: Integer
|
89
|
-
# @rbs
|
95
|
+
# @rbs return: Types::t?
|
90
96
|
def nth_type?: (Integer index) -> Types::t?
|
91
97
|
|
92
98
|
# Returns n-th type from the children
|
@@ -94,7 +100,7 @@ module RBS
|
|
94
100
|
# Raises if the value is not a type.
|
95
101
|
#
|
96
102
|
# @rbs index: Integer
|
97
|
-
# @rbs
|
103
|
+
# @rbs return: Types::t
|
98
104
|
def nth_type!: (Integer index) -> Types::t
|
99
105
|
|
100
106
|
# Returns n-th method type from the children
|
@@ -102,7 +108,7 @@ module RBS
|
|
102
108
|
# Raises if the value is not a method type or `nil`.
|
103
109
|
#
|
104
110
|
# @rbs index: Integer
|
105
|
-
# @rbs
|
111
|
+
# @rbs return: MethodType?
|
106
112
|
def nth_method_type: (Integer index) -> MethodType?
|
107
113
|
|
108
114
|
# Returns n-th method type from the children
|
@@ -110,7 +116,7 @@ module RBS
|
|
110
116
|
# Returns `nil` if the value is not a method type.
|
111
117
|
#
|
112
118
|
# @rbs index: Integer
|
113
|
-
# @rbs
|
119
|
+
# @rbs return: MethodType?
|
114
120
|
def nth_method_type?: (Integer index) -> MethodType?
|
115
121
|
|
116
122
|
# Returns n-th method tree from the children
|
@@ -118,7 +124,7 @@ module RBS
|
|
118
124
|
# Raises if the value is not a method tree.
|
119
125
|
#
|
120
126
|
# @rbs index: Integer
|
121
|
-
# @rbs
|
127
|
+
# @rbs return: MethodType
|
122
128
|
def nth_method_type!: (Integer index) -> MethodType
|
123
129
|
end
|
124
130
|
end
|
@@ -25,12 +25,12 @@ module RBS
|
|
25
25
|
# @rbs output_path: Pathname
|
26
26
|
def initialize: (Pathname pwd, Array[Pathname] base_paths, Pathname output_path) -> void
|
27
27
|
|
28
|
-
#
|
28
|
+
# : (Pathname) -> Pathname?
|
29
29
|
def calculate: (Pathname) -> Pathname?
|
30
30
|
|
31
31
|
# @rbs path: Pathname
|
32
32
|
# @rbs prefix: Pathname
|
33
|
-
# @rbs
|
33
|
+
# @rbs return: bool
|
34
34
|
def has_prefix?: (Pathname path, prefix: Pathname) -> bool
|
35
35
|
end
|
36
36
|
|
@@ -45,7 +45,7 @@ module RBS
|
|
45
45
|
def initialize: (?stdout: IO, ?stderr: IO) -> void
|
46
46
|
|
47
47
|
# @rbs args: Array[String]
|
48
|
-
# @rbs
|
48
|
+
# @rbs return: Integer
|
49
49
|
def run: (Array[String] args) -> Integer
|
50
50
|
end
|
51
51
|
end
|
@@ -5,11 +5,13 @@ use Prism::*
|
|
5
5
|
module RBS
|
6
6
|
module Inline
|
7
7
|
class Parser < Prism::Visitor
|
8
|
+
type with_members = AST::Declarations::ModuleDecl | AST::Declarations::ClassDecl | AST::Declarations::SingletonClassDecl | AST::Declarations::BlockDecl
|
9
|
+
|
8
10
|
# The top level declarations
|
9
11
|
attr_reader decls: Array[AST::Declarations::t]
|
10
12
|
|
11
13
|
# The surrounding declarations
|
12
|
-
attr_reader surrounding_decls: Array[
|
14
|
+
attr_reader surrounding_decls: Array[with_members]
|
13
15
|
|
14
16
|
# ParsingResult associated with the line number at the end
|
15
17
|
#
|
@@ -30,21 +32,30 @@ module RBS
|
|
30
32
|
|
31
33
|
def initialize: () -> void
|
32
34
|
|
35
|
+
# Parses the given Prism result to a three tuple
|
36
|
+
#
|
37
|
+
# Returns a three tuple of:
|
38
|
+
#
|
39
|
+
# 1. An array of `use` directives
|
40
|
+
# 2. An array of declarations
|
41
|
+
# 3. An array of RBS declarations given as `@rbs!` annotation at top-level
|
42
|
+
#
|
43
|
+
# Note that only RBS declarations are allowed in the top-level `@rbs!` annotations.
|
44
|
+
# RBS *members* are ignored in the array.
|
45
|
+
#
|
33
46
|
# @rbs result: ParseResult
|
34
47
|
# @rbs opt_in: bool -- `true` for *opt-out* mode, `false` for *opt-in* mode.
|
35
|
-
# @rbs
|
36
|
-
def self.parse: (ParseResult result, opt_in: bool) -> [ Array[AST::Annotations::Use], Array[AST::Declarations::t] ]?
|
48
|
+
# @rbs return: [Array[AST::Annotations::Use], Array[AST::Declarations::t], Array[RBS::AST::Declarations::t]]?
|
49
|
+
def self.parse: (ParseResult result, opt_in: bool) -> [ Array[AST::Annotations::Use], Array[AST::Declarations::t], Array[RBS::AST::Declarations::t] ]?
|
37
50
|
|
38
|
-
# @rbs
|
39
|
-
def current_class_module_decl: () ->
|
51
|
+
# @rbs return: with_members?
|
52
|
+
def current_class_module_decl: () -> with_members?
|
40
53
|
|
41
|
-
# @rbs
|
42
|
-
def current_class_module_decl!: () ->
|
54
|
+
# @rbs return: with_members
|
55
|
+
def current_class_module_decl!: () -> with_members
|
43
56
|
|
44
|
-
#
|
45
|
-
|
46
|
-
def push_class_module_decl: (AST::Declarations::ModuleDecl | AST::Declarations::ClassDecl | AST::Declarations::SingletonClassDecl) { () -> void } -> void
|
47
|
-
| (AST::Declarations::ConstantDecl) -> void
|
57
|
+
# : (with_members) { () -> void } -> void
|
58
|
+
def push_class_module_decl: (with_members) { () -> void } -> void
|
48
59
|
|
49
60
|
# Load inner declarations and delete them from `#comments` hash
|
50
61
|
#
|
@@ -89,12 +100,15 @@ module RBS
|
|
89
100
|
def visit_call_node: ...
|
90
101
|
|
91
102
|
# @rbs new_visibility: RBS::AST::Members::visibility?
|
92
|
-
# @rbs block:
|
93
|
-
# @rbs
|
103
|
+
# @rbs &block: () -> void
|
104
|
+
# @rbs return: void
|
94
105
|
def push_visibility: (RBS::AST::Members::visibility? new_visibility) { () -> void } -> void
|
95
106
|
|
107
|
+
# @rbs [A] (Node) { () -> A } -> A?
|
108
|
+
def process_nesting_node: [A] (Node) { () -> A } -> A?
|
109
|
+
|
96
110
|
# @rbs node: Node
|
97
|
-
# @rbs
|
111
|
+
# @rbs return: bool
|
98
112
|
def ignored_node?: (Node node) -> bool
|
99
113
|
|
100
114
|
# Fetch Application annotation which is associated to `node`
|
@@ -102,19 +116,22 @@ module RBS
|
|
102
116
|
# The application annotation is removed from `comments`.
|
103
117
|
#
|
104
118
|
# @rbs node: Node
|
105
|
-
# @rbs
|
119
|
+
# @rbs return: AST::Annotations::Application?
|
106
120
|
def application_annotation: (Node node) -> AST::Annotations::Application?
|
107
121
|
|
108
|
-
# Fetch
|
122
|
+
# Fetch TypeAssertion annotation which is associated to `node`
|
109
123
|
#
|
110
124
|
# The assertion annotation is removed from `comments`.
|
111
125
|
#
|
112
126
|
# @rbs node: Node | Location
|
113
|
-
# @rbs
|
114
|
-
def assertion_annotation: (Node | Location node) -> AST::Annotations::
|
127
|
+
# @rbs return: AST::Annotations::TypeAssertion?
|
128
|
+
def assertion_annotation: (Node | Location node) -> AST::Annotations::TypeAssertion?
|
115
129
|
|
116
130
|
# @rbs override
|
117
131
|
def visit_constant_write_node: ...
|
132
|
+
|
133
|
+
# @rbs override
|
134
|
+
def visit_block_node: ...
|
118
135
|
end
|
119
136
|
end
|
120
137
|
end
|
@@ -3,50 +3,72 @@
|
|
3
3
|
module RBS
|
4
4
|
module Inline
|
5
5
|
class Writer
|
6
|
+
interface _Content
|
7
|
+
def <<: (RBS::AST::Declarations::t | RBS::AST::Members::t) -> void
|
8
|
+
|
9
|
+
def concat: (Array[RBS::AST::Declarations::t | RBS::AST::Members::t]) -> void
|
10
|
+
end
|
11
|
+
|
6
12
|
attr_reader output: String
|
7
13
|
|
8
14
|
attr_reader writer: RBS::Writer
|
9
15
|
|
10
16
|
# @rbs buffer: String
|
11
|
-
def initialize: (?String buffer) ->
|
17
|
+
def initialize: (?String buffer) -> void
|
12
18
|
|
13
19
|
# @rbs uses: Array[AST::Annotations::Use]
|
14
20
|
# @rbs decls: Array[AST::Declarations::t]
|
15
|
-
|
21
|
+
# @rbs rbs_decls: Array[RBS::AST::Declarations::t]
|
22
|
+
def self.write: (Array[AST::Annotations::Use] uses, Array[AST::Declarations::t] decls, Array[RBS::AST::Declarations::t] rbs_decls) -> void
|
16
23
|
|
17
|
-
# @rbs lines:
|
18
|
-
# @rbs
|
24
|
+
# @rbs *lines: String
|
25
|
+
# @rbs return: void
|
19
26
|
def header: (*String lines) -> void
|
20
27
|
|
21
28
|
# @rbs uses: Array[AST::Annotations::Use]
|
22
29
|
# @rbs decls: Array[AST::Declarations::t]
|
23
|
-
# @rbs
|
24
|
-
|
30
|
+
# @rbs rbs_decls: Array[RBS::AST::Declarations::t] --
|
31
|
+
# Top level `rbs!` declarations
|
32
|
+
# @rbs return: void
|
33
|
+
def write: (Array[AST::Annotations::Use] uses, Array[AST::Declarations::t] decls, Array[RBS::AST::Declarations::t] rbs_decls) -> void
|
25
34
|
|
26
35
|
# @rbs decl: AST::Declarations::t
|
27
|
-
# @rbs
|
28
|
-
|
36
|
+
# @rbs rbs: _Content
|
37
|
+
# @rbs return: void
|
38
|
+
def translate_decl: (AST::Declarations::t decl, _Content rbs) -> void
|
29
39
|
|
30
40
|
# @rbs decl: AST::Declarations::ClassDecl
|
31
|
-
# @rbs
|
32
|
-
|
41
|
+
# @rbs rbs: _Content
|
42
|
+
# @rbs return: void
|
43
|
+
def translate_class_decl: (AST::Declarations::ClassDecl decl, _Content rbs) -> void
|
44
|
+
|
45
|
+
# @rbs members: Array[AST::Declarations::t | AST::Members::t]
|
46
|
+
# @rbs decl: AST::Declarations::SingletonClassDecl?
|
47
|
+
# @rbs rbs: _Content
|
48
|
+
# @rbs return: void
|
49
|
+
def translate_members: (Array[AST::Declarations::t | AST::Members::t] members, AST::Declarations::SingletonClassDecl? decl, _Content rbs) -> void
|
33
50
|
|
34
51
|
# @rbs decl: AST::Declarations::ModuleDecl
|
35
|
-
# @rbs
|
36
|
-
|
52
|
+
# @rbs rbs: _Content
|
53
|
+
# @rbs return: void
|
54
|
+
def translate_module_decl: (AST::Declarations::ModuleDecl decl, _Content rbs) -> void
|
37
55
|
|
38
56
|
# @rbs decl: AST::Declarations::ConstantDecl
|
39
|
-
# @rbs
|
40
|
-
|
57
|
+
# @rbs rbs: _Content
|
58
|
+
# @rbs return: void
|
59
|
+
def translate_constant_decl: (AST::Declarations::ConstantDecl decl, _Content rbs) -> void
|
41
60
|
|
42
61
|
# @rbs decl: AST::Declarations::SingletonClassDecl
|
43
|
-
# @rbs
|
44
|
-
|
62
|
+
# @rbs rbs: _Content
|
63
|
+
# @rbs return: void
|
64
|
+
def translate_singleton_decl: (AST::Declarations::SingletonClassDecl decl, _Content rbs) -> void
|
45
65
|
|
46
66
|
# @rbs member: AST::Members::t
|
47
|
-
# @rbs decl: AST::Declarations::
|
48
|
-
#
|
49
|
-
|
67
|
+
# @rbs decl: AST::Declarations::SingletonClassDecl? --
|
68
|
+
# The surrouding singleton class definition
|
69
|
+
# @rbs rbs: _Content
|
70
|
+
# @rbs return void
|
71
|
+
def translate_member: (AST::Members::t member, AST::Declarations::SingletonClassDecl? decl, _Content rbs) -> void
|
50
72
|
|
51
73
|
private
|
52
74
|
|
@@ -64,9 +86,19 @@ module RBS
|
|
64
86
|
# ```
|
65
87
|
#
|
66
88
|
# @rbs member: AST::Members::RubyDef
|
67
|
-
# @rbs decl: AST::Declarations::
|
68
|
-
# @rbs
|
69
|
-
def method_kind: (AST::Members::RubyDef member, AST::Declarations::
|
89
|
+
# @rbs decl: AST::Declarations::SingletonClassDecl?
|
90
|
+
# @rbs return: RBS::AST::Members::MethodDefinition::kind
|
91
|
+
def method_kind: (AST::Members::RubyDef member, AST::Declarations::SingletonClassDecl? decl) -> RBS::AST::Members::MethodDefinition::kind
|
92
|
+
|
93
|
+
# @rbs block: AST::Declarations::BlockDecl
|
94
|
+
# @rbs rbs: _Content
|
95
|
+
# @rbs return: void
|
96
|
+
def translate_module_block_decl: (AST::Declarations::BlockDecl block, _Content rbs) -> void
|
97
|
+
|
98
|
+
# @rbs block: AST::Declarations::BlockDecl
|
99
|
+
# @rbs rbs: _Content
|
100
|
+
# @rbs return: void
|
101
|
+
def translate_class_block_decl: (AST::Declarations::BlockDecl block, _Content rbs) -> void
|
70
102
|
end
|
71
103
|
end
|
72
104
|
end
|
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.
|
4
|
+
version: 0.5.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-
|
11
|
+
date: 2024-07-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: prism
|
@@ -61,6 +61,7 @@ files:
|
|
61
61
|
- exe/rbs-inline
|
62
62
|
- lib/rbs/inline.rb
|
63
63
|
- lib/rbs/inline/annotation_parser.rb
|
64
|
+
- lib/rbs/inline/annotation_parser/tokenizer.rb
|
64
65
|
- lib/rbs/inline/ast/annotations.rb
|
65
66
|
- lib/rbs/inline/ast/comment_lines.rb
|
66
67
|
- lib/rbs/inline/ast/declarations.rb
|
@@ -75,6 +76,7 @@ files:
|
|
75
76
|
- rbs_collection.yaml
|
76
77
|
- sig/generated/rbs/inline.rbs
|
77
78
|
- sig/generated/rbs/inline/annotation_parser.rbs
|
79
|
+
- sig/generated/rbs/inline/annotation_parser/tokenizer.rbs
|
78
80
|
- sig/generated/rbs/inline/ast/annotations.rbs
|
79
81
|
- sig/generated/rbs/inline/ast/comment_lines.rbs
|
80
82
|
- sig/generated/rbs/inline/ast/declarations.rbs
|