typeprof 0.21.4 → 0.21.5
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/.github/workflows/main.yml +21 -15
- data/Gemfile.lock +2 -2
- data/lib/typeprof/import.rb +31 -8
- data/lib/typeprof/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f5c0fba3561953bdf7db3fe5c326cd4a8375376189928270d919f23dffd78ce
|
4
|
+
data.tar.gz: b3d7aabe2f15298c41de661308e3d757ed0643df079092fe184f6046cc9336c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b861fb63e8cfb3d39fdf5a5f753ea88041e730d5c8518098c05fa07f360eae8f3f808697e5e0462ffc76def30e7163c184a95e3bd14a941063c3dc523a9fad53
|
7
|
+
data.tar.gz: 6b061ce0869738ea048e85c74a018adc8894f1c05d71c61b0e91d93b0714c177ef2bc48499640a97fc5f43fd29ace9227ef13924df006a81239cf2ac50480087
|
data/.github/workflows/main.yml
CHANGED
@@ -1,32 +1,38 @@
|
|
1
1
|
name: Ruby
|
2
2
|
|
3
|
-
on:
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
pull_request:
|
6
|
+
workflow_dispatch:
|
7
|
+
schedule:
|
8
|
+
- cron: '11 24 * * 5'
|
4
9
|
|
5
10
|
jobs:
|
11
|
+
ruby-versions:
|
12
|
+
uses: ruby/actions/.github/workflows/ruby_versions.yml@master
|
13
|
+
with:
|
14
|
+
engine: cruby-truffleruby
|
15
|
+
min_version: 2.7
|
16
|
+
|
6
17
|
build:
|
18
|
+
needs: ruby-versions
|
19
|
+
name: build (${{ matrix.ruby }})
|
7
20
|
strategy:
|
8
21
|
fail-fast: false
|
9
22
|
matrix:
|
10
|
-
ruby
|
23
|
+
ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
|
11
24
|
runs-on: ubuntu-latest
|
12
25
|
steps:
|
13
26
|
- uses: actions/checkout@v3
|
14
27
|
- name: Set up Ruby
|
15
28
|
uses: ruby/setup-ruby@v1
|
16
29
|
with:
|
17
|
-
ruby-version: ${{ matrix.ruby
|
18
|
-
|
30
|
+
ruby-version: ${{ matrix.ruby }}
|
31
|
+
- name: Bundle install
|
32
|
+
run: |
|
33
|
+
bundle install
|
34
|
+
- run: bundle exec typeprof --version
|
19
35
|
- name: Run the test suite
|
20
36
|
run: |
|
21
37
|
bundle exec rake TESTOPT=-v
|
22
|
-
|
23
|
-
truffleruby:
|
24
|
-
runs-on: ubuntu-latest
|
25
|
-
steps:
|
26
|
-
- uses: actions/checkout@v3
|
27
|
-
- name: Set up Ruby
|
28
|
-
uses: ruby/setup-ruby@v1
|
29
|
-
with:
|
30
|
-
ruby-version: truffleruby
|
31
|
-
bundler-cache: true
|
32
|
-
- run: bundle exec typeprof --version
|
38
|
+
if: ${{ !startsWith(matrix.ruby, 'truffle') }}
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
typeprof (0.21.
|
4
|
+
typeprof (0.21.5)
|
5
5
|
rbs (>= 1.8.1)
|
6
6
|
|
7
7
|
GEM
|
@@ -11,7 +11,7 @@ GEM
|
|
11
11
|
docile (1.4.0)
|
12
12
|
power_assert (2.0.1)
|
13
13
|
rake (13.0.1)
|
14
|
-
rbs (
|
14
|
+
rbs (3.0.0)
|
15
15
|
simplecov (0.21.2)
|
16
16
|
docile (~> 1.1)
|
17
17
|
simplecov-html (~> 0.11)
|
data/lib/typeprof/import.rb
CHANGED
@@ -7,6 +7,7 @@ module TypeProf
|
|
7
7
|
collection_path = Config.current.collection_path
|
8
8
|
if collection_path&.exist?
|
9
9
|
collection_lock = RBS::Collection::Config.lockfile_of(collection_path)
|
10
|
+
raise "Please execute 'rbs collection install'" if collection_lock.nil?
|
10
11
|
@repo.add(collection_lock.repo_path)
|
11
12
|
end
|
12
13
|
@env, @loaded_gems, @builtin_env_json = RBSReader.get_builtin_env
|
@@ -77,19 +78,37 @@ module TypeProf
|
|
77
78
|
def load_rbs_string(name, content)
|
78
79
|
buffer = RBS::Buffer.new(name: name, content: content)
|
79
80
|
new_decls = []
|
80
|
-
RBS::Parser.parse_signature(buffer)
|
81
|
-
|
82
|
-
|
81
|
+
ret = RBS::Parser.parse_signature(buffer)
|
82
|
+
if ret[0].is_a?(RBS::Buffer)
|
83
|
+
# rbs 3.0
|
84
|
+
buffer, directives, decls = ret
|
85
|
+
@env.add_signature(buffer: buffer, directives: directives, decls: decls)
|
86
|
+
new_decls.concat(decls)
|
87
|
+
else
|
88
|
+
ret.each do |decl|
|
89
|
+
@env << decl
|
90
|
+
new_decls << decl
|
91
|
+
end
|
83
92
|
end
|
84
93
|
RBSReader.load_rbs(@env, new_decls)
|
85
94
|
end
|
86
95
|
|
87
96
|
def self.load_rbs(env, new_decls)
|
88
97
|
all_env = env.resolve_type_names
|
89
|
-
resolver = RBS::TypeNameResolver.from_env(all_env)
|
90
98
|
cur_env = RBS::Environment.new
|
91
|
-
|
92
|
-
|
99
|
+
if defined?(RBS::TypeNameResolver)
|
100
|
+
resolver = RBS::TypeNameResolver.from_env(all_env)
|
101
|
+
new_decls.each do |decl|
|
102
|
+
cur_env << env.resolve_declaration(resolver, decl, outer: [], prefix: RBS::Namespace.root)
|
103
|
+
end
|
104
|
+
else
|
105
|
+
resolver = RBS::Resolver::TypeNameResolver.new(all_env)
|
106
|
+
table = RBS::Environment::UseMap::Table.new()
|
107
|
+
table.compute_children
|
108
|
+
map = RBS::Environment::UseMap.new(table: table)
|
109
|
+
new_decls.each do |decl|
|
110
|
+
cur_env << s = env.resolve_declaration(resolver, map, decl, outer: [], prefix: RBS::Namespace.root)
|
111
|
+
end
|
93
112
|
end
|
94
113
|
|
95
114
|
RBS2JSON.new(all_env, cur_env).dump_json
|
@@ -134,6 +153,9 @@ module TypeProf
|
|
134
153
|
gvars
|
135
154
|
end
|
136
155
|
|
156
|
+
AliasDecl = defined?(RBS::AST::Declarations::Alias) ? RBS::AST::Declarations::Alias : RBS::AST::Declarations::AliasDecl
|
157
|
+
TypeAlias = defined?(RBS::AST::Declarations::TypeAlias) ? RBS::AST::Declarations::TypeAlias : nil
|
158
|
+
|
137
159
|
def conv_classes
|
138
160
|
json = {}
|
139
161
|
|
@@ -265,9 +287,10 @@ module TypeProf
|
|
265
287
|
|
266
288
|
# The following declarations are ignoreable because they are handled in other level
|
267
289
|
when RBS::AST::Declarations::Constant
|
268
|
-
when
|
290
|
+
when AliasDecl # type alias
|
269
291
|
when RBS::AST::Declarations::Class, RBS::AST::Declarations::Module
|
270
292
|
when RBS::AST::Declarations::Interface
|
293
|
+
when TypeAlias
|
271
294
|
|
272
295
|
else
|
273
296
|
warn "Importing #{ member.class.name } is not supported yet"
|
@@ -492,7 +515,7 @@ module TypeProf
|
|
492
515
|
else
|
493
516
|
begin
|
494
517
|
@alias_resolution_stack[ty.name] = true
|
495
|
-
alias_decl = @all_env.alias_decls[ty.name]
|
518
|
+
alias_decl = (@all_env.respond_to?(:alias_decls) ? @all_env.alias_decls : @all_env.type_alias_decls)[ty.name]
|
496
519
|
alias_decl ? conv_type(alias_decl.decl.type) : [:any]
|
497
520
|
ensure
|
498
521
|
@alias_resolution_stack.delete(ty.name)
|
data/lib/typeprof/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: typeprof
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.21.
|
4
|
+
version: 0.21.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yusuke Endoh
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rbs
|
@@ -74,7 +74,7 @@ licenses:
|
|
74
74
|
metadata:
|
75
75
|
homepage_uri: https://github.com/ruby/typeprof
|
76
76
|
source_code_uri: https://github.com/ruby/typeprof
|
77
|
-
post_install_message:
|
77
|
+
post_install_message:
|
78
78
|
rdoc_options: []
|
79
79
|
require_paths:
|
80
80
|
- lib
|
@@ -89,8 +89,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: '0'
|
91
91
|
requirements: []
|
92
|
-
rubygems_version: 3.
|
93
|
-
signing_key:
|
92
|
+
rubygems_version: 3.5.0.dev
|
93
|
+
signing_key:
|
94
94
|
specification_version: 4
|
95
95
|
summary: TypeProf is a type analysis tool for Ruby code based on abstract interpretation
|
96
96
|
test_files: []
|