rbs_activesupport 1.1.0 → 1.2.0
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.
- checksums.yaml +4 -4
- data/.rubocop.yml +9 -0
- data/.vscode/settings.json +3 -1
- data/README.md +7 -0
- data/lib/generators/rbs_activesupport/install_generator.rb +2 -0
- data/lib/rbs_activesupport/ast.rb +4 -2
- data/lib/rbs_activesupport/attribute_accessor.rb +13 -10
- data/lib/rbs_activesupport/class_attribute.rb +12 -9
- data/lib/rbs_activesupport/declaration_builder.rb +31 -13
- data/lib/rbs_activesupport/delegate.rb +11 -6
- data/lib/rbs_activesupport/generator.rb +18 -8
- data/lib/rbs_activesupport/include.rb +14 -8
- data/lib/rbs_activesupport/method_searcher.rb +8 -4
- data/lib/rbs_activesupport/parser/comment_parser.rb +5 -3
- data/lib/rbs_activesupport/parser.rb +26 -9
- data/lib/rbs_activesupport/rake_task.rb +21 -12
- data/lib/rbs_activesupport/version.rb +1 -1
- data/rbs_collection.lock.yaml +20 -20
- data/sig/generators/rbs_activesupport/install_generator.rbs +7 -0
- data/sig/rbs_activesupport/ast.rbs +8 -2
- data/sig/rbs_activesupport/attribute_accessor.rbs +13 -0
- data/sig/rbs_activesupport/class_attribute.rbs +12 -0
- data/sig/rbs_activesupport/declaration_builder.rbs +32 -4
- data/sig/rbs_activesupport/delegate.rbs +11 -0
- data/sig/rbs_activesupport/generator.rbs +14 -0
- data/sig/rbs_activesupport/include.rbs +14 -0
- data/sig/rbs_activesupport/method_searcher.rbs +8 -1
- data/sig/rbs_activesupport/parser/comment_parser.rbs +5 -0
- data/sig/rbs_activesupport/parser.rbs +25 -2
- data/sig/rbs_activesupport/rake_task.rbs +10 -0
- data/sig/rbs_activesupport/version.rbs +5 -0
- data/sig/rbs_activesupport.rbs +4 -2
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e77fa40a7a5219ebb44f4f61f46e6191d57fdbb484ee21bf56482e1e39f15be
|
4
|
+
data.tar.gz: e357c7dcb7a169e1fb4134bb3f86fdfe7651a79ce705de666c0d131defc632e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc3430776bd189fa7af3ba83d205328adb8222cc26061fa3f3069e0ad0ea9ffa6140a9f2d6dcfa19720eec0970b2f9f16d16ef11d8c0e1de72d749d0c8572298
|
7
|
+
data.tar.gz: 3a9f7bc7e633726b9928db97d93937c3b753b6bfbe2a796b161cb11dc8acd66360a654d274bd7cfa9d91209bc062bc6b348e9470125ebd5ac4ca2f47bfa95b79
|
data/.rubocop.yml
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
AllCops:
|
2
2
|
TargetRubyVersion: 2.7
|
3
3
|
|
4
|
+
Layout/LeadingCommentSpace:
|
5
|
+
Enabled: false
|
6
|
+
|
4
7
|
Metrics/AbcSize:
|
5
8
|
Max: 25
|
6
9
|
Exclude:
|
@@ -22,6 +25,12 @@ Metrics/MethodLength:
|
|
22
25
|
Exclude:
|
23
26
|
- "lib/rbs_activesupport/ast.rb"
|
24
27
|
|
28
|
+
Style/AccessorGrouping:
|
29
|
+
Enabled: false
|
30
|
+
|
31
|
+
Style/CommentedKeyword:
|
32
|
+
Enabled: false
|
33
|
+
|
25
34
|
Style/Documentation:
|
26
35
|
Enabled: false
|
27
36
|
|
data/.vscode/settings.json
CHANGED
data/README.md
CHANGED
@@ -14,6 +14,13 @@ After the installation, please run rake task generator:
|
|
14
14
|
|
15
15
|
bundle exec rails g rbs_activesupport:install
|
16
16
|
|
17
|
+
And then, please modify `lib/tasks/rbs_activesupport.rake` to fit your application.
|
18
|
+
For example, set it up like this if you're using Rails configuration:
|
19
|
+
|
20
|
+
RbsActivesupport::RakeTask.new do |task|
|
21
|
+
task.target_directories = [Rails.root / "app", Rails.root / "lib"]
|
22
|
+
end
|
23
|
+
|
17
24
|
## Usage
|
18
25
|
|
19
26
|
Run `rbs:activesupport:setup` task:
|
@@ -12,6 +12,8 @@ module RbsActivesupport
|
|
12
12
|
require 'rbs_activesupport/rake_task'
|
13
13
|
|
14
14
|
RbsActivesupport::RakeTask.new do |task|
|
15
|
+
# The target directories
|
16
|
+
# task.target_directories = [Rails.root / "app"]
|
15
17
|
end
|
16
18
|
rescue LoadError
|
17
19
|
# failed to load rbs_activesupport. Skip to load rbs_activesupport tasks.
|
@@ -2,13 +2,15 @@
|
|
2
2
|
|
3
3
|
module RbsActivesupport
|
4
4
|
module AST
|
5
|
-
|
5
|
+
# @rbs node: Array[untyped]
|
6
|
+
def eval_args(node) #: Array[Array[Symbol?]]
|
6
7
|
# @type var args: Array[Array[Symbol?]]
|
7
8
|
*args, _ = eval_node(node)
|
8
9
|
args
|
9
10
|
end
|
10
11
|
|
11
|
-
|
12
|
+
# @rbs node: Array[untyped]
|
13
|
+
def eval_args_with_options(node) #: [Array[Symbol], Hash[Symbol, untyped]]
|
12
14
|
# @type var methods: Array[Symbol]
|
13
15
|
# @type var options: Hash[Symbol, untyped]
|
14
16
|
*args, _ = eval_node(node)
|
@@ -2,14 +2,17 @@
|
|
2
2
|
|
3
3
|
module RbsActivesupport
|
4
4
|
class AttributeAccessor
|
5
|
-
attr_reader :name
|
5
|
+
attr_reader :name #: Symbol
|
6
|
+
attr_reader :options #: Hash[untyped, untyped]
|
6
7
|
|
7
|
-
|
8
|
+
# @rbs name: Symbol
|
9
|
+
# @rbs options: Hash[untyped, untyped]
|
10
|
+
def initialize(name, options) #: void
|
8
11
|
@name = name
|
9
12
|
@options = options
|
10
13
|
end
|
11
14
|
|
12
|
-
def type
|
15
|
+
def type #: String
|
13
16
|
# @type var trailng_comment: String?
|
14
17
|
trailing_comment = options[:trailing_comment]
|
15
18
|
if trailing_comment&.start_with?("#:")
|
@@ -19,31 +22,31 @@ module RbsActivesupport
|
|
19
22
|
end
|
20
23
|
end
|
21
24
|
|
22
|
-
def singleton_reader?
|
25
|
+
def singleton_reader? #: bool
|
23
26
|
options.fetch(:singleton_reader, true)
|
24
27
|
end
|
25
28
|
|
26
|
-
def singleton_writer?
|
29
|
+
def singleton_writer? #: bool
|
27
30
|
options.fetch(:singleton_writer, true)
|
28
31
|
end
|
29
32
|
|
30
|
-
def instance_accessor?
|
33
|
+
def instance_accessor? #: bool
|
31
34
|
options.fetch(:instance_accessor, true)
|
32
35
|
end
|
33
36
|
|
34
|
-
def instance_reader?
|
37
|
+
def instance_reader? #: bool
|
35
38
|
options.fetch(:instance_reader, instance_accessor?)
|
36
39
|
end
|
37
40
|
|
38
|
-
def instance_writer?
|
41
|
+
def instance_writer? #: bool
|
39
42
|
options.fetch(:instance_writer, instance_accessor?)
|
40
43
|
end
|
41
44
|
|
42
|
-
def public?
|
45
|
+
def public? #: bool
|
43
46
|
!private?
|
44
47
|
end
|
45
48
|
|
46
|
-
def private?
|
49
|
+
def private? #: bool
|
47
50
|
options.fetch(:private, false)
|
48
51
|
end
|
49
52
|
end
|
@@ -2,14 +2,17 @@
|
|
2
2
|
|
3
3
|
module RbsActivesupport
|
4
4
|
class ClassAttribute
|
5
|
-
attr_reader :name
|
5
|
+
attr_reader :name #: Symbol
|
6
|
+
attr_reader :options #: Hash[untyped, untyped]
|
6
7
|
|
7
|
-
|
8
|
+
# @rbs name: Symbol
|
9
|
+
# @rbs options: Hash[untyped, untyped]
|
10
|
+
def initialize(name, options) #: void
|
8
11
|
@name = name
|
9
12
|
@options = options
|
10
13
|
end
|
11
14
|
|
12
|
-
def type
|
15
|
+
def type #: String
|
13
16
|
# @type var trailng_comment: String?
|
14
17
|
trailing_comment = options[:trailing_comment]
|
15
18
|
if trailing_comment&.start_with?("#:")
|
@@ -19,27 +22,27 @@ module RbsActivesupport
|
|
19
22
|
end
|
20
23
|
end
|
21
24
|
|
22
|
-
def instance_accessor?
|
25
|
+
def instance_accessor? #: bool
|
23
26
|
options.fetch(:instance_accessor, true)
|
24
27
|
end
|
25
28
|
|
26
|
-
def instance_reader?
|
29
|
+
def instance_reader? #: bool
|
27
30
|
options.fetch(:instance_reader, instance_accessor?)
|
28
31
|
end
|
29
32
|
|
30
|
-
def instance_writer?
|
33
|
+
def instance_writer? #: bool
|
31
34
|
options.fetch(:instance_writer, instance_accessor?)
|
32
35
|
end
|
33
36
|
|
34
|
-
def instance_predicate?
|
37
|
+
def instance_predicate? #: bool
|
35
38
|
options.fetch(:instance_predicate, true)
|
36
39
|
end
|
37
40
|
|
38
|
-
def public?
|
41
|
+
def public? #: bool
|
39
42
|
!private?
|
40
43
|
end
|
41
44
|
|
42
|
-
def private?
|
45
|
+
def private? #: bool
|
43
46
|
options.fetch(:private, false)
|
44
47
|
end
|
45
48
|
end
|
@@ -2,15 +2,20 @@
|
|
2
2
|
|
3
3
|
module RbsActivesupport
|
4
4
|
class DeclarationBuilder
|
5
|
+
# @rbs! type t = AttributeAccessor | ClassAttribute | Delegate | Include
|
6
|
+
|
5
7
|
include AST
|
6
8
|
|
7
|
-
attr_reader :method_searcher
|
9
|
+
attr_reader :method_searcher #: MethodSearcher
|
8
10
|
|
9
|
-
|
11
|
+
# @rbs method_searcher: MethodSearcher
|
12
|
+
def initialize(method_searcher) #: void
|
10
13
|
@method_searcher = method_searcher
|
11
14
|
end
|
12
15
|
|
13
|
-
|
16
|
+
# @rbs namespace: RBS::Namespace
|
17
|
+
# @rbs method_calls: Array[Parser::MethodCall]
|
18
|
+
def build(namespace, method_calls) #: [Array[String], Array[String]]
|
14
19
|
public_decls, private_decls = build_method_calls(namespace, method_calls).partition(&:public?)
|
15
20
|
[public_decls.map(&method(:render)).compact, # steep:ignore BlockTypeMismatch
|
16
21
|
private_decls.map(&method(:render)).compact] # steep:ignore BlockTypeMismatch
|
@@ -18,7 +23,9 @@ module RbsActivesupport
|
|
18
23
|
|
19
24
|
private
|
20
25
|
|
21
|
-
|
26
|
+
# @rbs namespace: RBS::Namespace
|
27
|
+
# @rbs method_calls: Array[Parser::MethodCall]
|
28
|
+
def build_method_calls(namespace, method_calls) #: Array[t]
|
22
29
|
method_calls.flat_map do |method_call|
|
23
30
|
case method_call.name
|
24
31
|
when :class_attribute
|
@@ -36,7 +43,8 @@ module RbsActivesupport
|
|
36
43
|
end.compact
|
37
44
|
end
|
38
45
|
|
39
|
-
|
46
|
+
# @rbs method_call: Parser::MethodCall
|
47
|
+
def build_attribute_accessor(method_call) #: Array[AttributeAccessor]
|
40
48
|
methods, options = eval_args_with_options(method_call.args)
|
41
49
|
options[:singleton_reader] = false if %i[cattr_writer mattr_writer].include?(method_call.name)
|
42
50
|
options[:singleton_writer] = false if %i[cattr_reader mattr_reader].include?(method_call.name)
|
@@ -49,7 +57,8 @@ module RbsActivesupport
|
|
49
57
|
end
|
50
58
|
end
|
51
59
|
|
52
|
-
|
60
|
+
# @rbs method_call: Parser::MethodCall
|
61
|
+
def build_class_attribute(method_call) #: Array[ClassAttribute]
|
53
62
|
methods, options = eval_args_with_options(method_call.args)
|
54
63
|
options[:private] = true if method_call.private?
|
55
64
|
options[:trailing_comment] = method_call.trailing_comment
|
@@ -58,7 +67,9 @@ module RbsActivesupport
|
|
58
67
|
end
|
59
68
|
end
|
60
69
|
|
61
|
-
|
70
|
+
# @rbs namespace: RBS::Namespace
|
71
|
+
# @rbs method_call: Parser::MethodCall
|
72
|
+
def build_delegate(namespace, method_call) #: Array[Delegate]
|
62
73
|
methods, options = eval_args_with_options(method_call.args)
|
63
74
|
options[:private] = true if method_call.private?
|
64
75
|
methods.map do |method|
|
@@ -66,14 +77,17 @@ module RbsActivesupport
|
|
66
77
|
end
|
67
78
|
end
|
68
79
|
|
69
|
-
|
80
|
+
# @rbs namespace: RBS::Namespace
|
81
|
+
# @rbs method_call: Parser::MethodCall
|
82
|
+
def build_include(namespace, method_call) #: Array[Include]
|
70
83
|
module_paths = eval_args(method_call.args)
|
71
84
|
module_paths.map do |module_path|
|
72
85
|
Include.new(namespace, module_path, { private: method_call.private? })
|
73
86
|
end
|
74
87
|
end
|
75
88
|
|
76
|
-
|
89
|
+
# @rbs decl: t
|
90
|
+
def render(decl) #: String?
|
77
91
|
case decl
|
78
92
|
when AttributeAccessor
|
79
93
|
render_attribute_accessor(decl)
|
@@ -86,7 +100,8 @@ module RbsActivesupport
|
|
86
100
|
end
|
87
101
|
end
|
88
102
|
|
89
|
-
|
103
|
+
# @rbs decl: AttributeAccessor
|
104
|
+
def render_attribute_accessor(decl) #: String
|
90
105
|
methods = []
|
91
106
|
methods << "def self.#{decl.name}: () -> (#{decl.type})" if decl.singleton_reader?
|
92
107
|
methods << "def self.#{decl.name}=: (#{decl.type}) -> (#{decl.type})" if decl.singleton_writer?
|
@@ -95,7 +110,8 @@ module RbsActivesupport
|
|
95
110
|
methods.join("\n")
|
96
111
|
end
|
97
112
|
|
98
|
-
|
113
|
+
# @rbs decl: ClassAttribute
|
114
|
+
def render_class_attribute(decl) #: String
|
99
115
|
methods = []
|
100
116
|
methods << "def self.#{decl.name}: () -> (#{decl.type})"
|
101
117
|
methods << "def self.#{decl.name}=: (#{decl.type}) -> (#{decl.type})"
|
@@ -106,13 +122,15 @@ module RbsActivesupport
|
|
106
122
|
methods.join("\n")
|
107
123
|
end
|
108
124
|
|
109
|
-
|
125
|
+
# @rbs decl: Delegate
|
126
|
+
def render_delegate(decl) #: String
|
110
127
|
method_types = method_searcher.method_types_for(decl)
|
111
128
|
|
112
129
|
"def #{decl.method_name}: #{method_types.join(" | ")}"
|
113
130
|
end
|
114
131
|
|
115
|
-
|
132
|
+
# @rbs decl: Include
|
133
|
+
def render_include(decl) #: String?
|
116
134
|
return unless decl.concern? && decl.classmethods?
|
117
135
|
|
118
136
|
<<~RBS
|
@@ -2,19 +2,24 @@
|
|
2
2
|
|
3
3
|
module RbsActivesupport
|
4
4
|
class Delegate
|
5
|
-
attr_reader :namespace
|
5
|
+
attr_reader :namespace #: RBS::Namespace
|
6
|
+
attr_reader :method #: Symbol
|
7
|
+
attr_reader :options #: Hash[Symbol, untyped]
|
6
8
|
|
7
|
-
|
9
|
+
# @rbs namespace: RBS::Namespace
|
10
|
+
# @rbs method: Symbol
|
11
|
+
# @rbs options: Hash[Symbol, untyped]
|
12
|
+
def initialize(namespace, method, options) #: void
|
8
13
|
@namespace = namespace
|
9
14
|
@method = method
|
10
15
|
@options = options
|
11
16
|
end
|
12
17
|
|
13
|
-
def to
|
18
|
+
def to #: Symbol
|
14
19
|
options[:to]
|
15
20
|
end
|
16
21
|
|
17
|
-
def method_name
|
22
|
+
def method_name #: Symbol
|
18
23
|
case options[:prefix]
|
19
24
|
when true
|
20
25
|
:"#{to}_#{method}"
|
@@ -25,11 +30,11 @@ module RbsActivesupport
|
|
25
30
|
end
|
26
31
|
end
|
27
32
|
|
28
|
-
def public?
|
33
|
+
def public? #: bool
|
29
34
|
!private?
|
30
35
|
end
|
31
36
|
|
32
|
-
def private?
|
37
|
+
def private? #: bool
|
33
38
|
options.fetch(:private, false)
|
34
39
|
end
|
35
40
|
end
|
@@ -2,20 +2,27 @@
|
|
2
2
|
|
3
3
|
module RbsActivesupport
|
4
4
|
class Generator
|
5
|
-
|
5
|
+
# @rbs pathname: Pathname
|
6
|
+
# @rbs rbs_builder: RBS::DefinitionBuilder
|
7
|
+
def self.generate(pathname, rbs_builder) #: String?
|
6
8
|
new(pathname, rbs_builder).generate
|
7
9
|
end
|
8
10
|
|
9
|
-
|
11
|
+
include AST
|
10
12
|
|
11
|
-
|
13
|
+
attr_reader :pathname #: Pathname
|
14
|
+
attr_reader :declaration_builder #: DeclarationBuilder
|
15
|
+
|
16
|
+
# @rbs pathname: Pathname
|
17
|
+
# @rbs rbs_builder: RBS::DefinitionBuilder
|
18
|
+
def initialize(pathname, rbs_builder) #: void
|
12
19
|
@pathname = pathname
|
13
20
|
|
14
21
|
method_searcher = MethodSearcher.new(rbs_builder)
|
15
22
|
@declaration_builder = DeclarationBuilder.new(method_searcher)
|
16
23
|
end
|
17
24
|
|
18
|
-
def generate
|
25
|
+
def generate #: String?
|
19
26
|
declarations = parse_source_code
|
20
27
|
return if declarations.empty?
|
21
28
|
|
@@ -42,20 +49,22 @@ module RbsActivesupport
|
|
42
49
|
|
43
50
|
private
|
44
51
|
|
45
|
-
|
52
|
+
# @rbs rbs: String
|
53
|
+
def format(rbs) #: String
|
46
54
|
parsed = RBS::Parser.parse_signature(rbs)
|
47
55
|
StringIO.new.tap do |out|
|
48
56
|
RBS::Writer.new(out: out).write(parsed[1] + parsed[2])
|
49
57
|
end.string
|
50
58
|
end
|
51
59
|
|
52
|
-
def parse_source_code
|
60
|
+
def parse_source_code #: Hash[RBS::Namespace, Array[Parser::MethodCall]]
|
53
61
|
parser = Parser.new
|
54
62
|
parser.parse(pathname.read)
|
55
63
|
parser.method_calls
|
56
64
|
end
|
57
65
|
|
58
|
-
|
66
|
+
# @rbs namespace: RBS::Namespace
|
67
|
+
def header(namespace) #: String
|
59
68
|
context = +""
|
60
69
|
namespace.path.map do |mod_name|
|
61
70
|
context += "::#{mod_name}"
|
@@ -75,7 +84,8 @@ module RbsActivesupport
|
|
75
84
|
end.join("\n")
|
76
85
|
end
|
77
86
|
|
78
|
-
|
87
|
+
# @rbs namespace: RBS::Namespace
|
88
|
+
def footer(namespace) #: String
|
79
89
|
"end\n" * namespace.path.size
|
80
90
|
end
|
81
91
|
end
|
@@ -4,15 +4,20 @@ require "active_support/concern"
|
|
4
4
|
|
5
5
|
module RbsActivesupport
|
6
6
|
class Include
|
7
|
-
attr_reader :context
|
7
|
+
attr_reader :context #: RBS::Namespace
|
8
|
+
attr_reader :module_path #: Array[Symbol?]
|
9
|
+
attr_reader :options #: Hash[Symbol, untyped]
|
8
10
|
|
9
|
-
|
11
|
+
# @rbs context: RBS::Namespace
|
12
|
+
# @rbs module_path: Array[Symbol?]
|
13
|
+
# @rbs options: Hash[Symbol, untyped]
|
14
|
+
def initialize(context, module_path, options) #: void
|
10
15
|
@context = context
|
11
16
|
@module_path = module_path
|
12
17
|
@options = options
|
13
18
|
end
|
14
19
|
|
15
|
-
def argument
|
20
|
+
def argument #: RBS::Namespace
|
16
21
|
if module_path.first.nil?
|
17
22
|
RBS::Namespace.new(path: module_path[1...], absolute: true) # steep:ignore ArgumentTypeMismatch
|
18
23
|
else
|
@@ -20,7 +25,8 @@ module RbsActivesupport
|
|
20
25
|
end
|
21
26
|
end
|
22
27
|
|
23
|
-
|
28
|
+
# @rbs %a{pure}
|
29
|
+
def module_name #: RBS::Namespace?
|
24
30
|
namespace = @context
|
25
31
|
|
26
32
|
loop do
|
@@ -33,7 +39,7 @@ module RbsActivesupport
|
|
33
39
|
end
|
34
40
|
end
|
35
41
|
|
36
|
-
def concern?
|
42
|
+
def concern? #: bool
|
37
43
|
return false unless module_name
|
38
44
|
|
39
45
|
modname = module_name.to_s.delete_suffix("::")
|
@@ -43,18 +49,18 @@ module RbsActivesupport
|
|
43
49
|
mod&.singleton_class&.include?(ActiveSupport::Concern)
|
44
50
|
end
|
45
51
|
|
46
|
-
def classmethods?
|
52
|
+
def classmethods? #: bool
|
47
53
|
return false unless module_name
|
48
54
|
|
49
55
|
modname = module_name.append(:ClassMethods).to_s.delete_suffix("::")
|
50
56
|
Object.const_defined?(modname)
|
51
57
|
end
|
52
58
|
|
53
|
-
def public?
|
59
|
+
def public? #: bool
|
54
60
|
!private?
|
55
61
|
end
|
56
62
|
|
57
|
-
def private?
|
63
|
+
def private? #: bool
|
58
64
|
options.fetch(:private, false)
|
59
65
|
end
|
60
66
|
end
|
@@ -4,13 +4,15 @@ require "rbs"
|
|
4
4
|
|
5
5
|
module RbsActivesupport
|
6
6
|
class MethodSearcher
|
7
|
-
attr_reader :rbs_builder
|
7
|
+
attr_reader :rbs_builder #: RBS::DefinitionBuilder
|
8
8
|
|
9
|
-
|
9
|
+
# @rbs rbs_builder: RBS::DefinitionBuilder
|
10
|
+
def initialize(rbs_builder) #: void
|
10
11
|
@rbs_builder = rbs_builder
|
11
12
|
end
|
12
13
|
|
13
|
-
|
14
|
+
# @rbs delegate: Delegate
|
15
|
+
def method_types_for(delegate) #: Array[String]
|
14
16
|
delegate_to = lookup_method_types(delegate.namespace.to_type_name, delegate.to)
|
15
17
|
return ["() -> untyped"] if delegate_to.any? { |t| t.type.return_type.is_a?(RBS::Types::Bases::Any) }
|
16
18
|
|
@@ -25,7 +27,9 @@ module RbsActivesupport
|
|
25
27
|
|
26
28
|
private
|
27
29
|
|
28
|
-
|
30
|
+
# @rbs type_name: RBS::TypeName
|
31
|
+
# @rbs method: Symbol
|
32
|
+
def lookup_method_types(type_name, method) #: Array[RBS::MethodType]
|
29
33
|
instance = rbs_builder.build_instance(type_name)
|
30
34
|
method_def = instance.methods[method]
|
31
35
|
return [] unless method_def
|
@@ -3,14 +3,16 @@
|
|
3
3
|
module RbsActivesupport
|
4
4
|
class Parser
|
5
5
|
class CommentParser
|
6
|
-
attr_reader :line_comments,
|
6
|
+
attr_reader :line_comments #: Hash[Integer, String]
|
7
|
+
attr_reader :trailing_comments #: Hash[Integer, String]
|
7
8
|
|
8
|
-
def initialize
|
9
|
+
def initialize #: void
|
9
10
|
@line_comments = {}
|
10
11
|
@trailing_comments = {}
|
11
12
|
end
|
12
13
|
|
13
|
-
|
14
|
+
# @rbs string: String
|
15
|
+
def parse(string) #: self
|
14
16
|
# @type var code_lines: Hash[Integer, bool]
|
15
17
|
code_lines = {}
|
16
18
|
Ripper.lex(string).each do |(line, _), type, token, _|
|
@@ -8,39 +8,54 @@ require "rbs/prototype/rb"
|
|
8
8
|
module RbsActivesupport
|
9
9
|
class Parser < ::RBS::Prototype::RB
|
10
10
|
class MethodCall
|
11
|
-
attr_reader :name
|
11
|
+
attr_reader :name #: t
|
12
|
+
attr_reader :args #: Array[RubyVM::AbstractSyntaxTree::Node]
|
13
|
+
attr_reader :trailing_comment #: String?
|
12
14
|
|
13
|
-
|
15
|
+
# @rbs @private: bool
|
16
|
+
|
17
|
+
# @rbs name: t
|
18
|
+
# @rbs args: Array[RubyVM::AbstractSyntaxTree::Node]
|
19
|
+
# @rbs private: bool
|
20
|
+
# @rbs trailing_comment: String?
|
21
|
+
def initialize(name, args, private, trailing_comment: nil) #: void
|
14
22
|
@name = name
|
15
23
|
@args = args
|
16
24
|
@private = private
|
17
25
|
@trailing_comment = trailing_comment
|
18
26
|
end
|
19
27
|
|
20
|
-
def private?
|
28
|
+
def private? #: bool
|
21
29
|
@private
|
22
30
|
end
|
23
31
|
end
|
24
32
|
|
33
|
+
# @rbs!
|
34
|
+
# type t = :class_attribute | :delegate | :cattr_accessor | :mattr_accessor | :cattr_reader | :mattr_reader |
|
35
|
+
# :cattr_writer | :mattr_writer | :include
|
36
|
+
|
25
37
|
METHODS = %i[
|
26
38
|
class_attribute delegate cattr_accessor mattr_accessor cattr_reader mattr_reader cattr_writer mattr_writer include
|
27
|
-
].freeze # steep:ignore IncompatibleAssignment
|
39
|
+
].freeze #: Array[t] # steep:ignore IncompatibleAssignment
|
28
40
|
|
29
41
|
alias process_orig process
|
30
42
|
|
31
|
-
attr_reader :comment_parser
|
43
|
+
attr_reader :comment_parser #: CommentParser
|
44
|
+
attr_reader :method_calls #: Hash[RBS::Namespace, Array[MethodCall]]
|
32
45
|
|
33
|
-
def initialize
|
46
|
+
def initialize #: void
|
34
47
|
super
|
35
48
|
@comment_parser = CommentParser.new
|
36
49
|
@method_calls = Hash.new { |hash, key| hash[key] = [] }
|
37
50
|
end
|
38
51
|
|
39
|
-
|
52
|
+
# @rbs string: String
|
53
|
+
def parse(string) #: void
|
40
54
|
comment_parser.parse(string)
|
41
55
|
super
|
42
56
|
end
|
43
57
|
|
58
|
+
# @rbs override
|
44
59
|
def process(node, decls:, comments:, context:)
|
45
60
|
case node.type
|
46
61
|
when :FCALL, :VCALL
|
@@ -57,11 +72,13 @@ module RbsActivesupport
|
|
57
72
|
end
|
58
73
|
end
|
59
74
|
|
60
|
-
|
75
|
+
# @rbs node: RubyVM::AbstractSyntaxTree::Node
|
76
|
+
def trailing_comment_for(node) #: String?
|
61
77
|
comment_parser.trailing_comments[node.last_lineno]
|
62
78
|
end
|
63
79
|
|
64
|
-
|
80
|
+
# @rbs decls: Array[RBS::AST::Declarations::t | RBS::AST::Members::t]
|
81
|
+
def private?(decls) #: bool
|
65
82
|
current_accessibility(decls) == private
|
66
83
|
end
|
67
84
|
end
|
@@ -5,13 +5,20 @@ require "rake/tasklib"
|
|
5
5
|
|
6
6
|
module RbsActivesupport
|
7
7
|
class RakeTask < Rake::TaskLib
|
8
|
-
attr_accessor :name
|
8
|
+
attr_accessor :name #: Symbol
|
9
|
+
attr_accessor :signature_root_dir #: Pathname
|
10
|
+
attr_accessor :target_directories #: Array[Pathname]
|
9
11
|
|
10
|
-
|
12
|
+
# @rbs @rbs_builder: RBS::DefinitionBuilder
|
13
|
+
|
14
|
+
# @rbs name: Symbol
|
15
|
+
# @rbs &block: ?(self) -> void
|
16
|
+
def initialize(name = :'rbs:activesupport', &block) #: void
|
11
17
|
super()
|
12
18
|
|
13
19
|
@name = name
|
14
20
|
@signature_root_dir = Pathname(Rails.root / "sig/activesupport")
|
21
|
+
@target_directories = [Rails.root / "app"]
|
15
22
|
|
16
23
|
block&.call(self)
|
17
24
|
|
@@ -20,14 +27,14 @@ module RbsActivesupport
|
|
20
27
|
define_setup_task
|
21
28
|
end
|
22
29
|
|
23
|
-
def define_setup_task
|
30
|
+
def define_setup_task #: void
|
24
31
|
desc "Run all tasks of rbs_activesupport"
|
25
32
|
|
26
33
|
deps = [:"#{name}:clean", :"#{name}:generate"]
|
27
34
|
task("#{name}:setup" => deps)
|
28
35
|
end
|
29
36
|
|
30
|
-
def define_generate_task
|
37
|
+
def define_generate_task #: void
|
31
38
|
desc "Generate RBS files for activesupport gem"
|
32
39
|
task("#{name}:generate": :environment) do
|
33
40
|
require "rbs_activesupport" # load RbsActivesupport lazily
|
@@ -36,18 +43,20 @@ module RbsActivesupport
|
|
36
43
|
|
37
44
|
signature_root_dir.mkpath
|
38
45
|
|
39
|
-
|
40
|
-
|
41
|
-
|
46
|
+
target_directories.each do |dir|
|
47
|
+
dir.glob("**/*.rb").each do |file|
|
48
|
+
rbs = Generator.new(file, rbs_builder).generate
|
49
|
+
next unless rbs
|
42
50
|
|
43
|
-
|
44
|
-
|
45
|
-
|
51
|
+
rbs_path = signature_root_dir / file.sub_ext(".rbs").relative_path_from(Rails.root)
|
52
|
+
rbs_path.dirname.mkpath
|
53
|
+
rbs_path.write(rbs)
|
54
|
+
end
|
46
55
|
end
|
47
56
|
end
|
48
57
|
end
|
49
58
|
|
50
|
-
def define_clean_task
|
59
|
+
def define_clean_task #: void
|
51
60
|
desc "Clean RBS files for config gem"
|
52
61
|
task "#{name}:clean" do
|
53
62
|
signature_root_dir.rmtree if signature_root_dir.exist?
|
@@ -56,7 +65,7 @@ module RbsActivesupport
|
|
56
65
|
|
57
66
|
private
|
58
67
|
|
59
|
-
def rbs_builder
|
68
|
+
def rbs_builder #: RBS::DefinitionBuilder
|
60
69
|
@rbs_builder ||= begin
|
61
70
|
loader = RBS::CLI::LibraryOptions.new.loader
|
62
71
|
loader.add(path: Pathname("sig"))
|
data/rbs_collection.lock.yaml
CHANGED
@@ -6,7 +6,7 @@ gems:
|
|
6
6
|
source:
|
7
7
|
type: git
|
8
8
|
name: ruby/gem_rbs_collection
|
9
|
-
revision:
|
9
|
+
revision: 4f55d83688a772342f0d96966cd51d06af03c2c8
|
10
10
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
11
11
|
repo_dir: gems
|
12
12
|
- name: actionview
|
@@ -14,7 +14,7 @@ gems:
|
|
14
14
|
source:
|
15
15
|
type: git
|
16
16
|
name: ruby/gem_rbs_collection
|
17
|
-
revision:
|
17
|
+
revision: 4f55d83688a772342f0d96966cd51d06af03c2c8
|
18
18
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
19
19
|
repo_dir: gems
|
20
20
|
- name: activesupport
|
@@ -22,7 +22,7 @@ gems:
|
|
22
22
|
source:
|
23
23
|
type: git
|
24
24
|
name: ruby/gem_rbs_collection
|
25
|
-
revision:
|
25
|
+
revision: 4f55d83688a772342f0d96966cd51d06af03c2c8
|
26
26
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
27
27
|
repo_dir: gems
|
28
28
|
- name: ast
|
@@ -30,7 +30,7 @@ gems:
|
|
30
30
|
source:
|
31
31
|
type: git
|
32
32
|
name: ruby/gem_rbs_collection
|
33
|
-
revision:
|
33
|
+
revision: 4f55d83688a772342f0d96966cd51d06af03c2c8
|
34
34
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
35
35
|
repo_dir: gems
|
36
36
|
- name: base64
|
@@ -50,7 +50,7 @@ gems:
|
|
50
50
|
source:
|
51
51
|
type: git
|
52
52
|
name: ruby/gem_rbs_collection
|
53
|
-
revision:
|
53
|
+
revision: 4f55d83688a772342f0d96966cd51d06af03c2c8
|
54
54
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
55
55
|
repo_dir: gems
|
56
56
|
- name: connection_pool
|
@@ -58,7 +58,7 @@ gems:
|
|
58
58
|
source:
|
59
59
|
type: git
|
60
60
|
name: ruby/gem_rbs_collection
|
61
|
-
revision:
|
61
|
+
revision: 4f55d83688a772342f0d96966cd51d06af03c2c8
|
62
62
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
63
63
|
repo_dir: gems
|
64
64
|
- name: date
|
@@ -82,7 +82,7 @@ gems:
|
|
82
82
|
source:
|
83
83
|
type: git
|
84
84
|
name: ruby/gem_rbs_collection
|
85
|
-
revision:
|
85
|
+
revision: 4f55d83688a772342f0d96966cd51d06af03c2c8
|
86
86
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
87
87
|
repo_dir: gems
|
88
88
|
- name: io-console
|
@@ -114,7 +114,7 @@ gems:
|
|
114
114
|
source:
|
115
115
|
type: git
|
116
116
|
name: ruby/gem_rbs_collection
|
117
|
-
revision:
|
117
|
+
revision: 4f55d83688a772342f0d96966cd51d06af03c2c8
|
118
118
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
119
119
|
repo_dir: gems
|
120
120
|
- name: optparse
|
@@ -126,7 +126,7 @@ gems:
|
|
126
126
|
source:
|
127
127
|
type: git
|
128
128
|
name: ruby/gem_rbs_collection
|
129
|
-
revision:
|
129
|
+
revision: 4f55d83688a772342f0d96966cd51d06af03c2c8
|
130
130
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
131
131
|
repo_dir: gems
|
132
132
|
- name: parser
|
@@ -134,7 +134,7 @@ gems:
|
|
134
134
|
source:
|
135
135
|
type: git
|
136
136
|
name: ruby/gem_rbs_collection
|
137
|
-
revision:
|
137
|
+
revision: 4f55d83688a772342f0d96966cd51d06af03c2c8
|
138
138
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
139
139
|
repo_dir: gems
|
140
140
|
- name: pathname
|
@@ -154,7 +154,7 @@ gems:
|
|
154
154
|
source:
|
155
155
|
type: git
|
156
156
|
name: ruby/gem_rbs_collection
|
157
|
-
revision:
|
157
|
+
revision: 4f55d83688a772342f0d96966cd51d06af03c2c8
|
158
158
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
159
159
|
repo_dir: gems
|
160
160
|
- name: rails-dom-testing
|
@@ -162,7 +162,7 @@ gems:
|
|
162
162
|
source:
|
163
163
|
type: git
|
164
164
|
name: ruby/gem_rbs_collection
|
165
|
-
revision:
|
165
|
+
revision: 4f55d83688a772342f0d96966cd51d06af03c2c8
|
166
166
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
167
167
|
repo_dir: gems
|
168
168
|
- name: railties
|
@@ -170,7 +170,7 @@ gems:
|
|
170
170
|
source:
|
171
171
|
type: git
|
172
172
|
name: ruby/gem_rbs_collection
|
173
|
-
revision:
|
173
|
+
revision: 4f55d83688a772342f0d96966cd51d06af03c2c8
|
174
174
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
175
175
|
repo_dir: gems
|
176
176
|
- name: rainbow
|
@@ -178,7 +178,7 @@ gems:
|
|
178
178
|
source:
|
179
179
|
type: git
|
180
180
|
name: ruby/gem_rbs_collection
|
181
|
-
revision:
|
181
|
+
revision: 4f55d83688a772342f0d96966cd51d06af03c2c8
|
182
182
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
183
183
|
repo_dir: gems
|
184
184
|
- name: rake
|
@@ -186,7 +186,7 @@ gems:
|
|
186
186
|
source:
|
187
187
|
type: git
|
188
188
|
name: ruby/gem_rbs_collection
|
189
|
-
revision:
|
189
|
+
revision: 4f55d83688a772342f0d96966cd51d06af03c2c8
|
190
190
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
191
191
|
repo_dir: gems
|
192
192
|
- name: rbs
|
@@ -202,7 +202,7 @@ gems:
|
|
202
202
|
source:
|
203
203
|
type: git
|
204
204
|
name: ruby/gem_rbs_collection
|
205
|
-
revision:
|
205
|
+
revision: 4f55d83688a772342f0d96966cd51d06af03c2c8
|
206
206
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
207
207
|
repo_dir: gems
|
208
208
|
- name: ripper
|
@@ -214,7 +214,7 @@ gems:
|
|
214
214
|
source:
|
215
215
|
type: git
|
216
216
|
name: ruby/gem_rbs_collection
|
217
|
-
revision:
|
217
|
+
revision: 4f55d83688a772342f0d96966cd51d06af03c2c8
|
218
218
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
219
219
|
repo_dir: gems
|
220
220
|
- name: rubocop-ast
|
@@ -222,7 +222,7 @@ gems:
|
|
222
222
|
source:
|
223
223
|
type: git
|
224
224
|
name: ruby/gem_rbs_collection
|
225
|
-
revision:
|
225
|
+
revision: 4f55d83688a772342f0d96966cd51d06af03c2c8
|
226
226
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
227
227
|
repo_dir: gems
|
228
228
|
- name: securerandom
|
@@ -246,7 +246,7 @@ gems:
|
|
246
246
|
source:
|
247
247
|
type: git
|
248
248
|
name: ruby/gem_rbs_collection
|
249
|
-
revision:
|
249
|
+
revision: 4f55d83688a772342f0d96966cd51d06af03c2c8
|
250
250
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
251
251
|
repo_dir: gems
|
252
252
|
- name: time
|
@@ -266,7 +266,7 @@ gems:
|
|
266
266
|
source:
|
267
267
|
type: git
|
268
268
|
name: ruby/gem_rbs_collection
|
269
|
-
revision:
|
269
|
+
revision: 4f55d83688a772342f0d96966cd51d06af03c2c8
|
270
270
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
271
271
|
repo_dir: gems
|
272
272
|
- name: uri
|
@@ -1,7 +1,13 @@
|
|
1
|
+
# Generated from lib/rbs_activesupport/ast.rb with RBS::Inline
|
2
|
+
|
1
3
|
module RbsActivesupport
|
2
4
|
module AST
|
3
|
-
|
4
|
-
def
|
5
|
+
# @rbs node: Array[untyped]
|
6
|
+
def eval_args: (Array[untyped] node) -> Array[Array[Symbol?]]
|
7
|
+
|
8
|
+
# @rbs node: Array[untyped]
|
9
|
+
def eval_args_with_options: (Array[untyped] node) -> [ Array[Symbol], Hash[Symbol, untyped] ]
|
10
|
+
|
5
11
|
def eval_node: (untyped node) -> untyped
|
6
12
|
end
|
7
13
|
end
|
@@ -1,16 +1,29 @@
|
|
1
|
+
# Generated from lib/rbs_activesupport/attribute_accessor.rb with RBS::Inline
|
2
|
+
|
1
3
|
module RbsActivesupport
|
2
4
|
class AttributeAccessor
|
3
5
|
attr_reader name: Symbol
|
6
|
+
|
4
7
|
attr_reader options: Hash[untyped, untyped]
|
5
8
|
|
9
|
+
# @rbs name: Symbol
|
10
|
+
# @rbs options: Hash[untyped, untyped]
|
6
11
|
def initialize: (Symbol name, Hash[untyped, untyped] options) -> void
|
12
|
+
|
7
13
|
def type: () -> String
|
14
|
+
|
8
15
|
def singleton_reader?: () -> bool
|
16
|
+
|
9
17
|
def singleton_writer?: () -> bool
|
18
|
+
|
10
19
|
def instance_accessor?: () -> bool
|
20
|
+
|
11
21
|
def instance_reader?: () -> bool
|
22
|
+
|
12
23
|
def instance_writer?: () -> bool
|
24
|
+
|
13
25
|
def public?: () -> bool
|
26
|
+
|
14
27
|
def private?: () -> bool
|
15
28
|
end
|
16
29
|
end
|
@@ -1,15 +1,27 @@
|
|
1
|
+
# Generated from lib/rbs_activesupport/class_attribute.rb with RBS::Inline
|
2
|
+
|
1
3
|
module RbsActivesupport
|
2
4
|
class ClassAttribute
|
3
5
|
attr_reader name: Symbol
|
6
|
+
|
4
7
|
attr_reader options: Hash[untyped, untyped]
|
5
8
|
|
9
|
+
# @rbs name: Symbol
|
10
|
+
# @rbs options: Hash[untyped, untyped]
|
6
11
|
def initialize: (Symbol name, Hash[untyped, untyped] options) -> void
|
12
|
+
|
7
13
|
def type: () -> String
|
14
|
+
|
8
15
|
def instance_accessor?: () -> bool
|
16
|
+
|
9
17
|
def instance_reader?: () -> bool
|
18
|
+
|
10
19
|
def instance_writer?: () -> bool
|
20
|
+
|
11
21
|
def instance_predicate?: () -> bool
|
22
|
+
|
12
23
|
def public?: () -> bool
|
24
|
+
|
13
25
|
def private?: () -> bool
|
14
26
|
end
|
15
27
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# Generated from lib/rbs_activesupport/declaration_builder.rb with RBS::Inline
|
2
|
+
|
1
3
|
module RbsActivesupport
|
2
4
|
class DeclarationBuilder
|
3
5
|
type t = AttributeAccessor | ClassAttribute | Delegate | Include
|
@@ -6,20 +8,46 @@ module RbsActivesupport
|
|
6
8
|
|
7
9
|
attr_reader method_searcher: MethodSearcher
|
8
10
|
|
11
|
+
# @rbs method_searcher: MethodSearcher
|
9
12
|
def initialize: (MethodSearcher method_searcher) -> void
|
10
|
-
|
13
|
+
|
14
|
+
# @rbs namespace: RBS::Namespace
|
15
|
+
# @rbs method_calls: Array[Parser::MethodCall]
|
16
|
+
def build: (RBS::Namespace namespace, Array[Parser::MethodCall] method_calls) -> [ Array[String], Array[String] ]
|
11
17
|
|
12
18
|
private
|
13
19
|
|
20
|
+
# @rbs namespace: RBS::Namespace
|
21
|
+
# @rbs method_calls: Array[Parser::MethodCall]
|
14
22
|
def build_method_calls: (RBS::Namespace namespace, Array[Parser::MethodCall] method_calls) -> Array[t]
|
23
|
+
|
24
|
+
# @rbs method_call: Parser::MethodCall
|
15
25
|
def build_attribute_accessor: (Parser::MethodCall method_call) -> Array[AttributeAccessor]
|
16
|
-
|
17
|
-
|
18
|
-
def
|
26
|
+
|
27
|
+
# @rbs method_call: Parser::MethodCall
|
28
|
+
def build_class_attribute: (Parser::MethodCall method_call) -> Array[ClassAttribute]
|
29
|
+
|
30
|
+
# @rbs namespace: RBS::Namespace
|
31
|
+
# @rbs method_call: Parser::MethodCall
|
32
|
+
def build_delegate: (RBS::Namespace namespace, Parser::MethodCall method_call) -> Array[Delegate]
|
33
|
+
|
34
|
+
# @rbs namespace: RBS::Namespace
|
35
|
+
# @rbs method_call: Parser::MethodCall
|
36
|
+
def build_include: (RBS::Namespace namespace, Parser::MethodCall method_call) -> Array[Include]
|
37
|
+
|
38
|
+
# @rbs decl: t
|
19
39
|
def render: (t decl) -> String?
|
40
|
+
|
41
|
+
# @rbs decl: AttributeAccessor
|
20
42
|
def render_attribute_accessor: (AttributeAccessor decl) -> String
|
43
|
+
|
44
|
+
# @rbs decl: ClassAttribute
|
21
45
|
def render_class_attribute: (ClassAttribute decl) -> String
|
46
|
+
|
47
|
+
# @rbs decl: Delegate
|
22
48
|
def render_delegate: (Delegate decl) -> String
|
49
|
+
|
50
|
+
# @rbs decl: Include
|
23
51
|
def render_include: (Include decl) -> String?
|
24
52
|
end
|
25
53
|
end
|
@@ -1,13 +1,24 @@
|
|
1
|
+
# Generated from lib/rbs_activesupport/delegate.rb with RBS::Inline
|
2
|
+
|
1
3
|
module RbsActivesupport
|
2
4
|
class Delegate
|
3
5
|
attr_reader namespace: RBS::Namespace
|
6
|
+
|
4
7
|
attr_reader method: Symbol
|
8
|
+
|
5
9
|
attr_reader options: Hash[Symbol, untyped]
|
6
10
|
|
11
|
+
# @rbs namespace: RBS::Namespace
|
12
|
+
# @rbs method: Symbol
|
13
|
+
# @rbs options: Hash[Symbol, untyped]
|
7
14
|
def initialize: (RBS::Namespace namespace, Symbol method, Hash[Symbol, untyped] options) -> void
|
15
|
+
|
8
16
|
def to: () -> Symbol
|
17
|
+
|
9
18
|
def method_name: () -> Symbol
|
19
|
+
|
10
20
|
def public?: () -> bool
|
21
|
+
|
11
22
|
def private?: () -> bool
|
12
23
|
end
|
13
24
|
end
|
@@ -1,20 +1,34 @@
|
|
1
|
+
# Generated from lib/rbs_activesupport/generator.rb with RBS::Inline
|
2
|
+
|
1
3
|
module RbsActivesupport
|
2
4
|
class Generator
|
5
|
+
# @rbs pathname: Pathname
|
6
|
+
# @rbs rbs_builder: RBS::DefinitionBuilder
|
3
7
|
def self.generate: (Pathname pathname, RBS::DefinitionBuilder rbs_builder) -> String?
|
4
8
|
|
5
9
|
include AST
|
6
10
|
|
7
11
|
attr_reader pathname: Pathname
|
12
|
+
|
8
13
|
attr_reader declaration_builder: DeclarationBuilder
|
9
14
|
|
15
|
+
# @rbs pathname: Pathname
|
16
|
+
# @rbs rbs_builder: RBS::DefinitionBuilder
|
10
17
|
def initialize: (Pathname pathname, RBS::DefinitionBuilder rbs_builder) -> void
|
18
|
+
|
11
19
|
def generate: () -> String?
|
12
20
|
|
13
21
|
private
|
14
22
|
|
23
|
+
# @rbs rbs: String
|
15
24
|
def format: (String rbs) -> String
|
25
|
+
|
16
26
|
def parse_source_code: () -> Hash[RBS::Namespace, Array[Parser::MethodCall]]
|
27
|
+
|
28
|
+
# @rbs namespace: RBS::Namespace
|
17
29
|
def header: (RBS::Namespace namespace) -> String
|
30
|
+
|
31
|
+
# @rbs namespace: RBS::Namespace
|
18
32
|
def footer: (RBS::Namespace namespace) -> String
|
19
33
|
end
|
20
34
|
end
|
@@ -1,16 +1,30 @@
|
|
1
|
+
# Generated from lib/rbs_activesupport/include.rb with RBS::Inline
|
2
|
+
|
1
3
|
module RbsActivesupport
|
2
4
|
class Include
|
3
5
|
attr_reader context: RBS::Namespace
|
6
|
+
|
4
7
|
attr_reader module_path: Array[Symbol?]
|
8
|
+
|
5
9
|
attr_reader options: Hash[Symbol, untyped]
|
6
10
|
|
11
|
+
# @rbs context: RBS::Namespace
|
12
|
+
# @rbs module_path: Array[Symbol?]
|
13
|
+
# @rbs options: Hash[Symbol, untyped]
|
7
14
|
def initialize: (RBS::Namespace context, Array[Symbol?] module_path, Hash[Symbol, untyped] options) -> void
|
15
|
+
|
8
16
|
def argument: () -> RBS::Namespace
|
17
|
+
|
18
|
+
# @rbs %a{pure}
|
9
19
|
%a{pure}
|
10
20
|
def module_name: () -> RBS::Namespace?
|
21
|
+
|
11
22
|
def concern?: () -> bool
|
23
|
+
|
12
24
|
def classmethods?: () -> bool
|
25
|
+
|
13
26
|
def public?: () -> bool
|
27
|
+
|
14
28
|
def private?: () -> bool
|
15
29
|
end
|
16
30
|
end
|
@@ -1,12 +1,19 @@
|
|
1
|
+
# Generated from lib/rbs_activesupport/method_searcher.rb with RBS::Inline
|
2
|
+
|
1
3
|
module RbsActivesupport
|
2
4
|
class MethodSearcher
|
3
5
|
attr_reader rbs_builder: RBS::DefinitionBuilder
|
4
6
|
|
7
|
+
# @rbs rbs_builder: RBS::DefinitionBuilder
|
5
8
|
def initialize: (RBS::DefinitionBuilder rbs_builder) -> void
|
9
|
+
|
10
|
+
# @rbs delegate: Delegate
|
6
11
|
def method_types_for: (Delegate delegate) -> Array[String]
|
7
12
|
|
8
13
|
private
|
9
14
|
|
10
|
-
|
15
|
+
# @rbs type_name: RBS::TypeName
|
16
|
+
# @rbs method: Symbol
|
17
|
+
def lookup_method_types: (RBS::TypeName type_name, Symbol method) -> Array[RBS::MethodType]
|
11
18
|
end
|
12
19
|
end
|
@@ -1,10 +1,15 @@
|
|
1
|
+
# Generated from lib/rbs_activesupport/parser/comment_parser.rb with RBS::Inline
|
2
|
+
|
1
3
|
module RbsActivesupport
|
2
4
|
class Parser
|
3
5
|
class CommentParser
|
4
6
|
attr_reader line_comments: Hash[Integer, String]
|
7
|
+
|
5
8
|
attr_reader trailing_comments: Hash[Integer, String]
|
6
9
|
|
7
10
|
def initialize: () -> void
|
11
|
+
|
12
|
+
# @rbs string: String
|
8
13
|
def parse: (String string) -> self
|
9
14
|
end
|
10
15
|
end
|
@@ -1,26 +1,49 @@
|
|
1
|
+
# Generated from lib/rbs_activesupport/parser.rb with RBS::Inline
|
2
|
+
|
1
3
|
module RbsActivesupport
|
2
4
|
class Parser < ::RBS::Prototype::RB
|
3
5
|
class MethodCall
|
4
6
|
attr_reader name: t
|
7
|
+
|
5
8
|
attr_reader args: Array[RubyVM::AbstractSyntaxTree::Node]
|
9
|
+
|
6
10
|
attr_reader trailing_comment: String?
|
7
11
|
|
8
12
|
@private: bool
|
9
13
|
|
14
|
+
# @rbs name: t
|
15
|
+
# @rbs args: Array[RubyVM::AbstractSyntaxTree::Node]
|
16
|
+
# @rbs private: bool
|
17
|
+
# @rbs trailing_comment: String?
|
10
18
|
def initialize: (t name, Array[RubyVM::AbstractSyntaxTree::Node] args, bool private, ?trailing_comment: String?) -> void
|
19
|
+
|
11
20
|
def private?: () -> bool
|
12
21
|
end
|
13
22
|
|
14
23
|
type t = :class_attribute | :delegate | :cattr_accessor | :mattr_accessor | :cattr_reader | :mattr_reader | :cattr_writer | :mattr_writer | :include
|
24
|
+
|
15
25
|
METHODS: Array[t]
|
16
26
|
|
17
27
|
alias process_orig process
|
18
28
|
|
19
29
|
attr_reader comment_parser: CommentParser
|
30
|
+
|
20
31
|
attr_reader method_calls: Hash[RBS::Namespace, Array[MethodCall]]
|
21
32
|
|
22
|
-
def
|
23
|
-
|
33
|
+
def initialize: () -> void
|
34
|
+
|
35
|
+
# @rbs string: String
|
36
|
+
def parse: (String string) -> void
|
37
|
+
|
38
|
+
# @rbs override
|
39
|
+
def process: ...
|
40
|
+
|
41
|
+
# @rbs node: RubyVM::AbstractSyntaxTree::Node
|
42
|
+
def trailing_comment_for: (RubyVM::AbstractSyntaxTree::Node node) -> String?
|
43
|
+
|
44
|
+
# @rbs decls: Array[RBS::AST::Declarations::t | RBS::AST::Members::t]
|
24
45
|
def private?: (Array[RBS::AST::Declarations::t | RBS::AST::Members::t] decls) -> bool
|
46
|
+
|
47
|
+
private
|
25
48
|
end
|
26
49
|
end
|
@@ -1,13 +1,23 @@
|
|
1
|
+
# Generated from lib/rbs_activesupport/rake_task.rb with RBS::Inline
|
2
|
+
|
1
3
|
module RbsActivesupport
|
2
4
|
class RakeTask < Rake::TaskLib
|
3
5
|
attr_accessor name: Symbol
|
6
|
+
|
4
7
|
attr_accessor signature_root_dir: Pathname
|
5
8
|
|
9
|
+
attr_accessor target_directories: Array[Pathname]
|
10
|
+
|
6
11
|
@rbs_builder: RBS::DefinitionBuilder
|
7
12
|
|
13
|
+
# @rbs name: Symbol
|
14
|
+
# @rbs &block: ?(self) -> void
|
8
15
|
def initialize: (?Symbol name) ?{ (self) -> void } -> void
|
16
|
+
|
9
17
|
def define_setup_task: () -> void
|
18
|
+
|
10
19
|
def define_generate_task: () -> void
|
20
|
+
|
11
21
|
def define_clean_task: () -> void
|
12
22
|
|
13
23
|
private
|
data/sig/rbs_activesupport.rbs
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbs_activesupport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takeshi KOMIYA
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -83,6 +83,7 @@ files:
|
|
83
83
|
- lib/rbs_activesupport/version.rb
|
84
84
|
- rbs_collection.lock.yaml
|
85
85
|
- rbs_collection.yaml
|
86
|
+
- sig/generators/rbs_activesupport/install_generator.rbs
|
86
87
|
- sig/rbs_activesupport.rbs
|
87
88
|
- sig/rbs_activesupport/ast.rbs
|
88
89
|
- sig/rbs_activesupport/attribute_accessor.rbs
|
@@ -95,6 +96,7 @@ files:
|
|
95
96
|
- sig/rbs_activesupport/parser.rbs
|
96
97
|
- sig/rbs_activesupport/parser/comment_parser.rbs
|
97
98
|
- sig/rbs_activesupport/rake_task.rbs
|
99
|
+
- sig/rbs_activesupport/version.rbs
|
98
100
|
homepage: https://github.com/tk0miya/rbs_activesupport
|
99
101
|
licenses:
|
100
102
|
- MIT
|