typeprof 0.21.4 → 0.21.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c0f10007471912f793ce801817a088aa794bc4baeb15e5179362521f55e41ec0
4
- data.tar.gz: ed61a2b2f4b9800cfb9c9e75d7aa0d0a5690ec1660e509dd4da456b60d1d03e7
3
+ metadata.gz: 1d207fe000797f7326bd569640296801ff8047d8261b2461f22c744899753641
4
+ data.tar.gz: ec87c3c228fc1326739f11fc6aaa63c4d5db46ad66bec55aab46d11d09953a50
5
5
  SHA512:
6
- metadata.gz: 218064fc39d5eeacfe48c8babb28cfade5a069703d71ec4fb45f1a436491596006a01e46b63a14a25c611924176e7bc7aa5131a687c48f9c35b9d84e03e044e8
7
- data.tar.gz: 61cca1138af6ab08bb91b9e05cd03a27de7c43bd13a36b9aa5522dffb1a118cb67f4494b0f109097572aa787a334be822773c6fedd87b3f1bcce1d7d221d7eba
6
+ metadata.gz: b6acf621b74c3468b14986c8c8616d0d6fc30a4e610dcf817ef550cc302d008cf916ea34f721a7e06038b48c77097e83a16f2e27233e93b18465f69288da4561
7
+ data.tar.gz: 1c80d8d54c9cda86819eac0aec7b47393f01423a6506946240ebdef40b02ad90bae4c69c43ced7906ecc60945b85fee2baefc8c0aa717a8b95c570f9c25adcf4
@@ -1,32 +1,39 @@
1
1
  name: Ruby
2
2
 
3
- on: [push,pull_request]
3
+ on:
4
+ push:
5
+ pull_request:
6
+ workflow_dispatch:
7
+ schedule:
8
+ # # This job runs at 00:00 on Friday.
9
+ - cron: '0 15 * * 5'
4
10
 
5
11
  jobs:
12
+ ruby-versions:
13
+ uses: ruby/actions/.github/workflows/ruby_versions.yml@master
14
+ with:
15
+ engine: cruby-truffleruby
16
+ min_version: 2.7
17
+
6
18
  build:
19
+ needs: ruby-versions
20
+ name: build (${{ matrix.ruby }})
7
21
  strategy:
8
22
  fail-fast: false
9
23
  matrix:
10
- ruby-version: [2.7, 3.0, 3.1, 3.2, head]
24
+ ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
11
25
  runs-on: ubuntu-latest
12
26
  steps:
13
27
  - uses: actions/checkout@v3
14
28
  - name: Set up Ruby
15
29
  uses: ruby/setup-ruby@v1
16
30
  with:
17
- ruby-version: ${{ matrix.ruby-version }}
18
- bundler-cache: true
31
+ ruby-version: ${{ matrix.ruby }}
32
+ - name: Bundle install
33
+ run: |
34
+ bundle install
35
+ - run: bundle exec typeprof --version
19
36
  - name: Run the test suite
20
37
  run: |
21
38
  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
39
+ 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.3)
4
+ typeprof (0.21.6)
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 (2.8.3)
14
+ rbs (3.0.1)
15
15
  simplecov (0.21.2)
16
16
  docile (~> 1.1)
17
17
  simplecov-html (~> 0.11)
@@ -6,8 +6,13 @@ module TypeProf
6
6
  @repo = RBS::Repository.new
7
7
  collection_path = Config.current.collection_path
8
8
  if collection_path&.exist?
9
- collection_lock = RBS::Collection::Config.lockfile_of(collection_path)
10
- @repo.add(collection_lock.repo_path)
9
+ lock_path = RBS::Collection::Config.to_lockfile_path(collection_path)
10
+ if lock_path.exist?
11
+ collection_lock = RBS::Collection::Config.from_path(lock_path)
12
+ @repo.add(collection_lock.repo_path)
13
+ else
14
+ raise "Please execute 'rbs collection install'"
15
+ end
11
16
  end
12
17
  @env, @loaded_gems, @builtin_env_json = RBSReader.get_builtin_env
13
18
  end
@@ -23,9 +28,14 @@ module TypeProf
23
28
  # TODO: invalidate this cache when rbs_collection.yml was changed
24
29
  collection_path = Config.current.collection_path
25
30
  if collection_path&.exist?
26
- collection_lock = RBS::Collection::Config.lockfile_of(collection_path)
27
- collection_lock.gems.each {|gem| @loaded_gems << gem["name"] }
28
- loader.add_collection(collection_lock)
31
+ lock_path = RBS::Collection::Config.to_lockfile_path(collection_path)
32
+ if lock_path.exist?
33
+ collection_lock = RBS::Collection::Config::Lockfile.from_lockfile(lockfile_path: lock_path, data: YAML.load_file(lock_path.to_s))
34
+ collection_lock.gems.each {|gem| @loaded_gems << gem["name"] }
35
+ loader.add_collection(collection_lock)
36
+ else
37
+ raise "Please execute 'rbs collection install'"
38
+ end
29
39
  end
30
40
 
31
41
  new_decls = loader.load(env: @builtin_env).map {|decl,| decl }
@@ -77,19 +87,37 @@ module TypeProf
77
87
  def load_rbs_string(name, content)
78
88
  buffer = RBS::Buffer.new(name: name, content: content)
79
89
  new_decls = []
80
- RBS::Parser.parse_signature(buffer).each do |decl|
81
- @env << decl
82
- new_decls << decl
90
+ ret = RBS::Parser.parse_signature(buffer)
91
+ if ret[0].is_a?(RBS::Buffer)
92
+ # rbs 3.0
93
+ buffer, directives, decls = ret
94
+ @env.add_signature(buffer: buffer, directives: directives, decls: decls)
95
+ new_decls.concat(decls)
96
+ else
97
+ ret.each do |decl|
98
+ @env << decl
99
+ new_decls << decl
100
+ end
83
101
  end
84
102
  RBSReader.load_rbs(@env, new_decls)
85
103
  end
86
104
 
87
105
  def self.load_rbs(env, new_decls)
88
106
  all_env = env.resolve_type_names
89
- resolver = RBS::TypeNameResolver.from_env(all_env)
90
107
  cur_env = RBS::Environment.new
91
- new_decls.each do |decl|
92
- cur_env << env.resolve_declaration(resolver, decl, outer: [], prefix: RBS::Namespace.root)
108
+ if defined?(RBS::TypeNameResolver)
109
+ resolver = RBS::TypeNameResolver.from_env(all_env)
110
+ new_decls.each do |decl|
111
+ cur_env << env.resolve_declaration(resolver, decl, outer: [], prefix: RBS::Namespace.root)
112
+ end
113
+ else
114
+ resolver = RBS::Resolver::TypeNameResolver.new(all_env)
115
+ table = RBS::Environment::UseMap::Table.new()
116
+ table.compute_children
117
+ map = RBS::Environment::UseMap.new(table: table)
118
+ new_decls.each do |decl|
119
+ cur_env << s = env.resolve_declaration(resolver, map, decl, outer: [], prefix: RBS::Namespace.root)
120
+ end
93
121
  end
94
122
 
95
123
  RBS2JSON.new(all_env, cur_env).dump_json
@@ -134,6 +162,9 @@ module TypeProf
134
162
  gvars
135
163
  end
136
164
 
165
+ AliasDecl = defined?(RBS::AST::Declarations::Alias) ? RBS::AST::Declarations::Alias : RBS::AST::Declarations::AliasDecl
166
+ TypeAlias = defined?(RBS::AST::Declarations::TypeAlias) ? RBS::AST::Declarations::TypeAlias : nil
167
+
137
168
  def conv_classes
138
169
  json = {}
139
170
 
@@ -265,9 +296,10 @@ module TypeProf
265
296
 
266
297
  # The following declarations are ignoreable because they are handled in other level
267
298
  when RBS::AST::Declarations::Constant
268
- when RBS::AST::Declarations::Alias # type alias
299
+ when AliasDecl # type alias
269
300
  when RBS::AST::Declarations::Class, RBS::AST::Declarations::Module
270
301
  when RBS::AST::Declarations::Interface
302
+ when TypeAlias
271
303
 
272
304
  else
273
305
  warn "Importing #{ member.class.name } is not supported yet"
@@ -492,7 +524,7 @@ module TypeProf
492
524
  else
493
525
  begin
494
526
  @alias_resolution_stack[ty.name] = true
495
- alias_decl = @all_env.alias_decls[ty.name]
527
+ alias_decl = (@all_env.respond_to?(:alias_decls) ? @all_env.alias_decls : @all_env.type_alias_decls)[ty.name]
496
528
  alias_decl ? conv_type(alias_decl.decl.type) : [:any]
497
529
  ensure
498
530
  @alias_resolution_stack.delete(ty.name)
@@ -1,3 +1,3 @@
1
1
  module TypeProf
2
- VERSION = "0.21.4"
2
+ VERSION = "0.21.6"
3
3
  end
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
4
+ version: 0.21.6
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-01-12 00:00:00.000000000 Z
11
+ date: 2023-02-28 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.3.26
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: []