rbs-trace 0.3.1 → 0.3.2
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/CHANGELOG.md +4 -0
- data/README.md +3 -0
- data/Rakefile +1 -6
- data/lib/rbs/trace/declaration.rb +2 -2
- data/lib/rbs/trace/file.rb +6 -2
- data/lib/rbs/trace/method_tracing.rb +8 -4
- data/lib/rbs/trace/version.rb +1 -1
- data/rbs_collection.lock.yaml +31 -3
- metadata +5 -10
- data/gemfiles/3.1.gemfile +0 -12
- data/gemfiles/3.1.gemfile.lock +0 -68
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e587e127bc2689a2d6e3c9f25dad32a5b75b49164b8666d0c0ff891d9c6e35f4
|
4
|
+
data.tar.gz: 47cb65ce7cef30a14cc68984e7a76614ca593a1581a439b34341386937c65591
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ccd45b222189e14609f8ef30f207341dbf6a4ed863a4c94b5cf051d28504f84cd8d101a68905de787ac5661f9bc7b9432162b81abbda85868e40e14cc741ebd
|
7
|
+
data.tar.gz: 158f74515cad425793edcc6f7d68c2ee8140afb36d9922ee80b6d1c21c020db748c9842c9b3bc6c15d330c2a12834681c6082b3e373c9ae669ccc379337ed626
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
[](https://badge.fury.io/rb/rbs-trace)
|
2
|
+
[](https://github.com/sinsoku/rbs-trace/actions/workflows/test.yml)
|
3
|
+
|
1
4
|
# RBS::Trace
|
2
5
|
|
3
6
|
RBS::Trace collects argument types and return value types using TracePoint, and inserts inline RBS type declarations into files.
|
data/Rakefile
CHANGED
@@ -44,9 +44,9 @@ module RBS
|
|
44
44
|
# TODO: support block argument
|
45
45
|
# @rbs () -> String
|
46
46
|
def parameters_rbs
|
47
|
-
converted = {}
|
47
|
+
converted = {} #: Hash[Symbol, Array[String?]]
|
48
48
|
@parameters.each do |kind, name, klass|
|
49
|
-
converted[kind] ||= []
|
49
|
+
converted[kind] ||= [] #: Array[String?]
|
50
50
|
converted[kind] << convert(kind, name, klass)
|
51
51
|
end
|
52
52
|
|
data/lib/rbs/trace/file.rb
CHANGED
@@ -37,9 +37,13 @@ module RBS
|
|
37
37
|
|
38
38
|
# @rbs (Array[String], Definition) -> boolish
|
39
39
|
def skip_insert?(lines, definition)
|
40
|
-
|
40
|
+
current = definition.lineno - 1
|
41
|
+
prev = current - 1
|
41
42
|
|
42
|
-
definition.decls.empty? ||
|
43
|
+
definition.decls.empty? ||
|
44
|
+
lines[prev]&.include?("# @rbs") ||
|
45
|
+
lines[prev]&.include?("#:") ||
|
46
|
+
lines[current]&.include?("#:")
|
43
47
|
end
|
44
48
|
|
45
49
|
# @rbs () -> Enumerator[Definition, void]
|
@@ -57,12 +57,14 @@ module RBS
|
|
57
57
|
# @rbs (File, TracePoint) -> Definition
|
58
58
|
def find_or_new_definition(file, tp)
|
59
59
|
name = tp.method_id
|
60
|
-
is_singleton = tp.defined_class.singleton_class?
|
60
|
+
is_singleton = tp.defined_class.singleton_class? # steep:ignore NoMethod
|
61
61
|
klass = is_singleton ? tp.self : tp.defined_class
|
62
62
|
mark = is_singleton ? "." : "#"
|
63
63
|
signature = "#{klass}#{mark}#{name}"
|
64
64
|
|
65
|
+
# steep:ignore:start
|
65
66
|
file.definitions[signature] ||= Definition.new(klass:, name:, lineno: tp.lineno)
|
67
|
+
# steep:ignore:end
|
66
68
|
end
|
67
69
|
|
68
70
|
# @rbs (TracePoint) -> void
|
@@ -84,7 +86,7 @@ module RBS
|
|
84
86
|
|
85
87
|
# @rbs (TracePoint) -> void
|
86
88
|
def call_event(tp) # rubocop:disable Metrics
|
87
|
-
parameters = tp.parameters.filter_map do |kind, name|
|
89
|
+
parameters = tp.parameters.filter_map do |kind, name| # steep:ignore NoMethod
|
88
90
|
# steep:ignore:start
|
89
91
|
value = tp.binding.local_variable_get(name) if name && !%i[* ** &].include?(name)
|
90
92
|
# steep:ignore:end
|
@@ -101,7 +103,9 @@ module RBS
|
|
101
103
|
end
|
102
104
|
[kind, name, klass]
|
103
105
|
end
|
106
|
+
# steep:ignore:start
|
104
107
|
stack_traces << Declaration.new(parameters, void: !assign_return_value?(tp.path, tp.method_id))
|
108
|
+
# steep:ignore:end
|
105
109
|
end
|
106
110
|
|
107
111
|
# @rbs (TracePoint, Definition) -> void
|
@@ -121,7 +125,7 @@ module RBS
|
|
121
125
|
|
122
126
|
# @rbs (String) -> bool
|
123
127
|
def ignore_path?(path)
|
124
|
-
bundle_path = Bundler.bundle_path.to_s # steep:ignore
|
128
|
+
bundle_path = Bundler.bundle_path.to_s # steep:ignore NoMethod
|
125
129
|
ruby_lib_path = RbConfig::CONFIG["rubylibdir"]
|
126
130
|
|
127
131
|
path.start_with?("<internal") ||
|
@@ -169,7 +173,7 @@ module RBS
|
|
169
173
|
def parsed_nodes(path)
|
170
174
|
return unless ::File.exist?(path)
|
171
175
|
|
172
|
-
@parsed_nodes ||= {}
|
176
|
+
@parsed_nodes ||= {} #: Hash[String, Prism::ParseResult]
|
173
177
|
@parsed_nodes[path] ||= Prism.parse_file(path)
|
174
178
|
@parsed_nodes[path].value
|
175
179
|
end
|
data/lib/rbs/trace/version.rb
CHANGED
data/rbs_collection.lock.yaml
CHANGED
@@ -6,13 +6,17 @@ gems:
|
|
6
6
|
source:
|
7
7
|
type: git
|
8
8
|
name: ruby/gem_rbs_collection
|
9
|
-
revision:
|
9
|
+
revision: ccbd2bbc6be5c195df1d90aa68d64916a9e7d0ab
|
10
10
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
11
11
|
repo_dir: gems
|
12
12
|
- name: fileutils
|
13
13
|
version: '0'
|
14
14
|
source:
|
15
15
|
type: stdlib
|
16
|
+
- name: json
|
17
|
+
version: '0'
|
18
|
+
source:
|
19
|
+
type: stdlib
|
16
20
|
- name: logger
|
17
21
|
version: '0'
|
18
22
|
source:
|
@@ -21,8 +25,16 @@ gems:
|
|
21
25
|
version: '0'
|
22
26
|
source:
|
23
27
|
type: stdlib
|
28
|
+
- name: optparse
|
29
|
+
version: '0'
|
30
|
+
source:
|
31
|
+
type: stdlib
|
32
|
+
- name: pathname
|
33
|
+
version: '0'
|
34
|
+
source:
|
35
|
+
type: stdlib
|
24
36
|
- name: prism
|
25
|
-
version:
|
37
|
+
version: 1.2.0
|
26
38
|
source:
|
27
39
|
type: rubygems
|
28
40
|
- name: rake
|
@@ -30,7 +42,23 @@ gems:
|
|
30
42
|
source:
|
31
43
|
type: git
|
32
44
|
name: ruby/gem_rbs_collection
|
33
|
-
revision:
|
45
|
+
revision: ccbd2bbc6be5c195df1d90aa68d64916a9e7d0ab
|
34
46
|
remote: https://github.com/ruby/gem_rbs_collection.git
|
35
47
|
repo_dir: gems
|
48
|
+
- name: rbs
|
49
|
+
version: 3.8.1
|
50
|
+
source:
|
51
|
+
type: rubygems
|
52
|
+
- name: rbs-inline
|
53
|
+
version: 0.10.0
|
54
|
+
source:
|
55
|
+
type: rubygems
|
56
|
+
- name: rdoc
|
57
|
+
version: '0'
|
58
|
+
source:
|
59
|
+
type: stdlib
|
60
|
+
- name: tsort
|
61
|
+
version: '0'
|
62
|
+
source:
|
63
|
+
type: stdlib
|
36
64
|
gemfile_lock_path: Gemfile.lock
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbs-trace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Takumi Shotoku
|
8
|
-
autorequire:
|
9
8
|
bindir: exe
|
10
9
|
cert_chain: []
|
11
|
-
date: 2024-
|
10
|
+
date: 2024-12-29 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: prism
|
@@ -41,8 +40,6 @@ files:
|
|
41
40
|
- README.md
|
42
41
|
- Rakefile
|
43
42
|
- Steepfile
|
44
|
-
- gemfiles/3.1.gemfile
|
45
|
-
- gemfiles/3.1.gemfile.lock
|
46
43
|
- lib/rbs-trace.rb
|
47
44
|
- lib/rbs/trace.rb
|
48
45
|
- lib/rbs/trace/declaration.rb
|
@@ -64,10 +61,9 @@ licenses:
|
|
64
61
|
- MIT
|
65
62
|
metadata:
|
66
63
|
homepage_uri: https://github.com/sinsoku/rbs-trace
|
67
|
-
source_code_uri: https://github.com/sinsoku/rbs-trace/tree/v0.3.
|
68
|
-
changelog_uri: https://github.com/sinsoku/rbs-trace/blob/v0.3.
|
64
|
+
source_code_uri: https://github.com/sinsoku/rbs-trace/tree/v0.3.2
|
65
|
+
changelog_uri: https://github.com/sinsoku/rbs-trace/blob/v0.3.2/CHANGELOG.md
|
69
66
|
rubygems_mfa_required: 'true'
|
70
|
-
post_install_message:
|
71
67
|
rdoc_options: []
|
72
68
|
require_paths:
|
73
69
|
- lib
|
@@ -82,8 +78,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
82
78
|
- !ruby/object:Gem::Version
|
83
79
|
version: '0'
|
84
80
|
requirements: []
|
85
|
-
rubygems_version: 3.
|
86
|
-
signing_key:
|
81
|
+
rubygems_version: 3.6.2
|
87
82
|
specification_version: 4
|
88
83
|
summary: Automatically Insert inline RBS type declarations using runtime information.
|
89
84
|
test_files: []
|
data/gemfiles/3.1.gemfile
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
# Specify your gem's dependencies in rbs-trace.gemspec
|
6
|
-
gemspec(path: "..")
|
7
|
-
|
8
|
-
gem "rake"
|
9
|
-
gem "rspec"
|
10
|
-
gem "rubocop", require: false
|
11
|
-
gem "rubocop-rake", require: false
|
12
|
-
gem "rubocop-rspec", require: false
|
data/gemfiles/3.1.gemfile.lock
DELETED
@@ -1,68 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: ..
|
3
|
-
specs:
|
4
|
-
rbs-trace (0.3.1)
|
5
|
-
prism (>= 0.3.0)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
ast (2.4.2)
|
11
|
-
diff-lcs (1.5.1)
|
12
|
-
json (2.7.2)
|
13
|
-
language_server-protocol (3.17.0.3)
|
14
|
-
parallel (1.26.3)
|
15
|
-
parser (3.3.5.0)
|
16
|
-
ast (~> 2.4.1)
|
17
|
-
racc
|
18
|
-
prism (1.0.0)
|
19
|
-
racc (1.8.1)
|
20
|
-
rainbow (3.1.1)
|
21
|
-
rake (13.2.1)
|
22
|
-
regexp_parser (2.9.2)
|
23
|
-
rspec (3.13.0)
|
24
|
-
rspec-core (~> 3.13.0)
|
25
|
-
rspec-expectations (~> 3.13.0)
|
26
|
-
rspec-mocks (~> 3.13.0)
|
27
|
-
rspec-core (3.13.1)
|
28
|
-
rspec-support (~> 3.13.0)
|
29
|
-
rspec-expectations (3.13.3)
|
30
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
31
|
-
rspec-support (~> 3.13.0)
|
32
|
-
rspec-mocks (3.13.1)
|
33
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
34
|
-
rspec-support (~> 3.13.0)
|
35
|
-
rspec-support (3.13.1)
|
36
|
-
rubocop (1.66.1)
|
37
|
-
json (~> 2.3)
|
38
|
-
language_server-protocol (>= 3.17.0)
|
39
|
-
parallel (~> 1.10)
|
40
|
-
parser (>= 3.3.0.2)
|
41
|
-
rainbow (>= 2.2.2, < 4.0)
|
42
|
-
regexp_parser (>= 2.4, < 3.0)
|
43
|
-
rubocop-ast (>= 1.32.2, < 2.0)
|
44
|
-
ruby-progressbar (~> 1.7)
|
45
|
-
unicode-display_width (>= 2.4.0, < 3.0)
|
46
|
-
rubocop-ast (1.32.3)
|
47
|
-
parser (>= 3.3.1.0)
|
48
|
-
rubocop-rake (0.6.0)
|
49
|
-
rubocop (~> 1.0)
|
50
|
-
rubocop-rspec (3.0.5)
|
51
|
-
rubocop (~> 1.61)
|
52
|
-
ruby-progressbar (1.13.0)
|
53
|
-
unicode-display_width (2.5.0)
|
54
|
-
|
55
|
-
PLATFORMS
|
56
|
-
arm64-darwin-23
|
57
|
-
ruby
|
58
|
-
|
59
|
-
DEPENDENCIES
|
60
|
-
rake
|
61
|
-
rbs-trace!
|
62
|
-
rspec
|
63
|
-
rubocop
|
64
|
-
rubocop-rake
|
65
|
-
rubocop-rspec
|
66
|
-
|
67
|
-
BUNDLED WITH
|
68
|
-
2.5.17
|