syntax_tree 4.0.0 → 4.0.1

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: 10f0ce4d457d0e9f5bd36e167de9b1904ddfae5194f5b6be022aa269ca292703
4
- data.tar.gz: 52fc74a1cdef543d8b6c47c4cc8843530f8e3ef3ad91ae28d8394e3438c78059
3
+ metadata.gz: 5d8670e1c7ff4d583f84ee1fc217c714d217c944f36bb2bba5e2527cdd9012c8
4
+ data.tar.gz: c00025ed6cfb6031f64c9531282d527ff5113b78fa1228b86774bb84bb834576
5
5
  SHA512:
6
- metadata.gz: b4eb3a6cdf87afb63722f01b3ba3840fa96766a5636585cdec3b17d5b6ad630746d3e06e05b599960bb907db084a30c644cd2778868684f5f681953a1dbb411e
7
- data.tar.gz: 994023a5b4da885e0b9eccd1641381e00b7142f47efbb75d27bcfe4da4b36c1cb07f000cbdbc5f0d5b57e5ef2d9c00c43bfff9251bd236cdc9e5eee01e21d683
6
+ metadata.gz: bb4cd48f69132f5685e24ebbd29bb020468be6bf2a9a191bc3bba6ebf45dd5d63b2f61669c1695ec1711be4bcb4a5a8a29191fae1051b63d0b7d09bb75e78c0a
7
+ data.tar.gz: 5f35a3f095d3208246c013bf18b2d93cd4066ac5375750d5100b1c893806edb8ce240230cd30d70cfb525e6dfae4bbbc1ab108b6d549750a37ab0b16ba07c437
data/.rubocop.yml CHANGED
@@ -13,6 +13,9 @@ AllCops:
13
13
  Layout/LineLength:
14
14
  Max: 80
15
15
 
16
+ Lint/AmbiguousBlockAssociation:
17
+ Enabled: false
18
+
16
19
  Lint/DuplicateBranch:
17
20
  Enabled: false
18
21
 
data/CHANGELOG.md CHANGED
@@ -6,6 +6,14 @@ 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.1] - 2022-10-18
10
+
11
+ ### Changed
12
+
13
+ - [#172](https://github.com/ruby-syntax-tree/syntax_tree/pull/172) - Use a refinement for `Symbol#name` addition so that other runtimes or tools don't get confused by its availability.
14
+ - [#173](https://github.com/ruby-syntax-tree/syntax_tree/pull/173) - Fix the `current_environment` usage to use the method instead of the instance variable.
15
+ - [#175](https://github.com/ruby-syntax-tree/syntax_tree/pull/175) - Update `prettier_print` requirement since v1.0.0 had a bug with `#breakable_return`.
16
+
9
17
  ## [4.0.0] - 2022-10-17
10
18
 
11
19
  ### Added
data/Gemfile.lock CHANGED
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- syntax_tree (4.0.0)
5
- prettier_print (>= 1.0.0)
4
+ syntax_tree (4.0.1)
5
+ prettier_print (>= 1.0.1)
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.0)
17
+ prettier_print (1.0.1)
18
18
  rainbow (3.1.1)
19
19
  rake (13.0.6)
20
20
  regexp_parser (2.6.0)
@@ -29,7 +29,7 @@ GEM
29
29
  rubocop-ast (>= 1.20.1, < 2.0)
30
30
  ruby-progressbar (~> 1.7)
31
31
  unicode-display_width (>= 1.4.0, < 3.0)
32
- rubocop-ast (1.21.0)
32
+ rubocop-ast (1.22.0)
33
33
  parser (>= 3.1.1.0)
34
34
  ruby-progressbar (1.11.0)
35
35
  simplecov (0.21.2)
@@ -1651,6 +1651,20 @@ module SyntaxTree
1651
1651
  # array << value
1652
1652
  #
1653
1653
  class Binary < Node
1654
+ # Since Binary's operator is a symbol, it's better to use the `name` method
1655
+ # than to allocate a new string every time. This is a tiny performance
1656
+ # optimization, but enough that it shows up in the profiler. Adding this in
1657
+ # for older Ruby versions.
1658
+ unless :+.respond_to?(:name)
1659
+ using Module.new {
1660
+ refine Symbol do
1661
+ def name
1662
+ to_s.freeze
1663
+ end
1664
+ end
1665
+ }
1666
+ end
1667
+
1654
1668
  # [untyped] the left-hand side of the expression
1655
1669
  attr_reader :left
1656
1670
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SyntaxTree
4
- VERSION = "4.0.0"
4
+ VERSION = "4.0.1"
5
5
  end
@@ -64,19 +64,19 @@ module SyntaxTree
64
64
  # arguments
65
65
  def visit_params(node)
66
66
  node.requireds.each do |param|
67
- @current_environment.add_local_definition(param, :argument)
67
+ current_environment.add_local_definition(param, :argument)
68
68
  end
69
69
 
70
70
  node.posts.each do |param|
71
- @current_environment.add_local_definition(param, :argument)
71
+ current_environment.add_local_definition(param, :argument)
72
72
  end
73
73
 
74
74
  node.keywords.each do |param|
75
- @current_environment.add_local_definition(param.first, :argument)
75
+ current_environment.add_local_definition(param.first, :argument)
76
76
  end
77
77
 
78
78
  node.optionals.each do |param|
79
- @current_environment.add_local_definition(param.first, :argument)
79
+ current_environment.add_local_definition(param.first, :argument)
80
80
  end
81
81
 
82
82
  super
@@ -84,21 +84,21 @@ module SyntaxTree
84
84
 
85
85
  def visit_rest_param(node)
86
86
  name = node.name
87
- @current_environment.add_local_definition(name, :argument) if name
87
+ current_environment.add_local_definition(name, :argument) if name
88
88
 
89
89
  super
90
90
  end
91
91
 
92
92
  def visit_kwrest_param(node)
93
93
  name = node.name
94
- @current_environment.add_local_definition(name, :argument) if name
94
+ current_environment.add_local_definition(name, :argument) if name
95
95
 
96
96
  super
97
97
  end
98
98
 
99
99
  def visit_blockarg(node)
100
100
  name = node.name
101
- @current_environment.add_local_definition(name, :argument) if name
101
+ current_environment.add_local_definition(name, :argument) if name
102
102
 
103
103
  super
104
104
  end
@@ -108,7 +108,7 @@ module SyntaxTree
108
108
  value = node.value
109
109
 
110
110
  if value.is_a?(SyntaxTree::Ident)
111
- @current_environment.add_local_definition(value, :variable)
111
+ current_environment.add_local_definition(value, :variable)
112
112
  end
113
113
 
114
114
  super
@@ -119,7 +119,7 @@ module SyntaxTree
119
119
  # Visits for keeping track of variable and argument usages
120
120
  def visit_aref_field(node)
121
121
  name = node.collection.value
122
- @current_environment.add_local_usage(name, :variable) if name
122
+ current_environment.add_local_usage(name, :variable) if name
123
123
 
124
124
  super
125
125
  end
@@ -128,10 +128,10 @@ module SyntaxTree
128
128
  value = node.value
129
129
 
130
130
  if value.is_a?(SyntaxTree::Ident)
131
- definition = @current_environment.find_local(value.value)
131
+ definition = current_environment.find_local(value.value)
132
132
 
133
133
  if definition
134
- @current_environment.add_local_usage(value, definition.type)
134
+ current_environment.add_local_usage(value, definition.type)
135
135
  end
136
136
  end
137
137
 
data/lib/syntax_tree.rb CHANGED
@@ -22,16 +22,6 @@ require_relative "syntax_tree/visitor/with_environment"
22
22
 
23
23
  require_relative "syntax_tree/parser"
24
24
 
25
- # We rely on Symbol#name being available, which is only available in Ruby 3.0+.
26
- # In case we're running on an older Ruby version, we polyfill it here.
27
- unless :+.respond_to?(:name)
28
- class Symbol # rubocop:disable Style/Documentation
29
- def name
30
- to_s.freeze
31
- end
32
- end
33
- end
34
-
35
25
  # Syntax Tree is a suite of tools built on top of the internal CRuby parser. It
36
26
  # provides the ability to generate a syntax tree from source, as well as the
37
27
  # tools necessary to inspect and manipulate that syntax tree. It can be used to
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.0"
28
+ spec.add_dependency "prettier_print", ">= 1.0.1"
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.0
4
+ version: 4.0.1
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-17 00:00:00.000000000 Z
11
+ date: 2022-10-18 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.0
19
+ version: 1.0.1
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.0
26
+ version: 1.0.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement