syntax_tree 4.0.1 → 4.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5d8670e1c7ff4d583f84ee1fc217c714d217c944f36bb2bba5e2527cdd9012c8
4
- data.tar.gz: c00025ed6cfb6031f64c9531282d527ff5113b78fa1228b86774bb84bb834576
3
+ metadata.gz: 959bd2a452303ffb7565ee0ce9641cc1167609c7c2231fc12d476d35db44ae34
4
+ data.tar.gz: d1d15bf2076e7ee83caf30d1371d3d2e3c43415349e5e89e39efca68ccda0339
5
5
  SHA512:
6
- metadata.gz: bb4cd48f69132f5685e24ebbd29bb020468be6bf2a9a191bc3bba6ebf45dd5d63b2f61669c1695ec1711be4bcb4a5a8a29191fae1051b63d0b7d09bb75e78c0a
7
- data.tar.gz: 5f35a3f095d3208246c013bf18b2d93cd4066ac5375750d5100b1c893806edb8ce240230cd30d70cfb525e6dfae4bbbc1ab108b6d549750a37ab0b16ba07c437
6
+ metadata.gz: 814586875ea83553dcf691b374056617b0491af9237c5fc4332da559cec7cf459593b515549cdf33c2a5b3bd45a79b01b8fa9c6bb027646799f3fb935b1b37b1
7
+ data.tar.gz: a7a70c1d9b77b7c9f3c460973760cabf7446fa794e1254da25536657e7094c9bbcdb6522f08a00a26fe317d982b31b48e9f99758e2a9dde093b5c7998cdf047a
data/CHANGELOG.md CHANGED
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [4.0.2] - 2022-10-19
10
+
11
+ ### Changed
12
+
13
+ - [#177](https://github.com/ruby-syntax-tree/syntax_tree/pull/177) - Fix up various other issues with the environment visitor addition.
14
+
9
15
  ## [4.0.1] - 2022-10-18
10
16
 
11
17
  ### Changed
@@ -391,7 +397,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
391
397
 
392
398
  - 🎉 Initial release! 🎉
393
399
 
394
- [unreleased]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v4.0.0...HEAD
400
+ [unreleased]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v4.0.2...HEAD
401
+ [4.0.2]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v4.0.1...v4.0.2
402
+ [4.0.1]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v4.0.0...v4.0.1
395
403
  [4.0.0]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v3.6.3...v4.0.0
396
404
  [3.6.3]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v3.6.2...v3.6.3
397
405
  [3.6.2]: https://github.com/ruby-syntax-tree/syntax_tree/compare/v3.6.1...v3.6.2
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- syntax_tree (4.0.1)
5
- prettier_print (>= 1.0.1)
4
+ syntax_tree (4.0.2)
5
+ prettier_print (>= 1.0.2)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
@@ -14,7 +14,7 @@ GEM
14
14
  parallel (1.22.1)
15
15
  parser (3.1.2.1)
16
16
  ast (~> 2.4.1)
17
- prettier_print (1.0.1)
17
+ prettier_print (1.0.2)
18
18
  rainbow (3.1.1)
19
19
  rake (13.0.6)
20
20
  regexp_parser (2.6.0)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SyntaxTree
4
- VERSION = "4.0.1"
4
+ VERSION = "4.0.2"
5
5
  end
@@ -44,8 +44,12 @@ module SyntaxTree
44
44
  with_new_environment { super }
45
45
  end
46
46
 
47
+ # When we find a method invocation with a block, only the code that happens
48
+ # inside of the block needs a fresh environment. The method invocation
49
+ # itself happens in the same environment
47
50
  def visit_method_add_block(node)
48
- with_new_environment { super }
51
+ visit(node.call)
52
+ with_new_environment { visit(node.block) }
49
53
  end
50
54
 
51
55
  def visit_def(node)
@@ -63,9 +67,7 @@ module SyntaxTree
63
67
  # Visit for keeping track of local arguments, such as method and block
64
68
  # arguments
65
69
  def visit_params(node)
66
- node.requireds.each do |param|
67
- current_environment.add_local_definition(param, :argument)
68
- end
70
+ add_argument_definitions(node.requireds)
69
71
 
70
72
  node.posts.each do |param|
71
73
  current_environment.add_local_definition(param, :argument)
@@ -117,13 +119,6 @@ module SyntaxTree
117
119
  alias visit_pinned_var_ref visit_var_field
118
120
 
119
121
  # Visits for keeping track of variable and argument usages
120
- def visit_aref_field(node)
121
- name = node.collection.value
122
- current_environment.add_local_usage(name, :variable) if name
123
-
124
- super
125
- end
126
-
127
122
  def visit_var_ref(node)
128
123
  value = node.value
129
124
 
@@ -137,5 +132,17 @@ module SyntaxTree
137
132
 
138
133
  super
139
134
  end
135
+
136
+ private
137
+
138
+ def add_argument_definitions(list)
139
+ list.each do |param|
140
+ if param.is_a?(SyntaxTree::MLHSParen)
141
+ add_argument_definitions(param.contents.parts)
142
+ else
143
+ current_environment.add_local_definition(param, :argument)
144
+ end
145
+ end
146
+ end
140
147
  end
141
148
  end
data/syntax_tree.gemspec CHANGED
@@ -25,7 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
26
  spec.require_paths = %w[lib]
27
27
 
28
- spec.add_dependency "prettier_print", ">= 1.0.1"
28
+ spec.add_dependency "prettier_print", ">= 1.0.2"
29
29
 
30
30
  spec.add_development_dependency "bundler"
31
31
  spec.add_development_dependency "minitest"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: syntax_tree
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Newton
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-18 00:00:00.000000000 Z
11
+ date: 2022-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prettier_print
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.1
19
+ version: 1.0.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 1.0.1
26
+ version: 1.0.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement