synvert-core 1.28.3 → 1.28.5

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: 4ea0617537582c8fe24441b78a96a9e7e3ec74ef50a85bd761f1a2c620bb67ae
4
- data.tar.gz: 30aed9720e68b3014aced6cea3d80dcf48d746ffcc217b543c6211cd29545468
3
+ metadata.gz: 0bec5627263e4ec474329e21a53a142f9d9320a888fd4b3d236ec538617d0ff3
4
+ data.tar.gz: 0b94c83241ddc9288b4487e76d8e2f75de6a2ec0636096d3dcb2fc1fcf042001
5
5
  SHA512:
6
- metadata.gz: b4c4d9a0fe6833d651c25d9a574818a54976c5ffcd6ef018208763f277b990735361fca476488bfa831e8a4d5dcb96bc4b092bfc10506b5e6306b6a5941f3dd6
7
- data.tar.gz: 4abe08f1cc6cf27ef830dbfcedb943737d11a377e5f87df3d6a7f67eabc6c6d790e86de647fe81a495a147cc1e2c90950a933c378665add69864f66b18a80fc2
6
+ metadata.gz: 2a86dd8058630846880993ec83e7201153e98e8af1d87cbe75f3cf6f0b8dbf98affab6d360a6ded45d80597225e5a7c3117662b98c092362644a7133951243cf
7
+ data.tar.gz: f2846ce3d7893d5d068d408eaafc916297e20a9f4989f5b94a495e723dc2cd6b185542ec826fc478fb88fe09d749feb6397576b2e3175099d4970c43cc4f1e12
data/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.28.5 (2023-09-25)
4
+
5
+ * Update `node-query` to 1.13.11
6
+ * Update `node_mutation` to 1.20.0
7
+ * Combine actions within scope
8
+ * Iterate actions in engine
9
+
10
+ ## 1.28.4 (2023-08-16)
11
+
12
+ * Merge `test_results` based on file_path
13
+ * Update `node-query` to 1.13.9
14
+ * Update `node_mutation` to 1.19.3
15
+
3
16
  ## 1.28.3 (2023-06-22)
4
17
 
5
18
  * Update `node_mutation` to 1.19.1
data/Gemfile.lock CHANGED
@@ -1,20 +1,20 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- synvert-core (1.28.3)
4
+ synvert-core (1.28.5)
5
5
  activesupport (< 7.0.0)
6
- node_mutation (>= 1.19.1)
7
- node_query (>= 1.13.5)
6
+ node_mutation (>= 1.20.0)
7
+ node_query (>= 1.13.11)
8
8
  parallel
9
9
  parser
10
10
  parser_node_ext (>= 1.2.0)
11
11
  syntax_tree
12
- syntax_tree_ext (>= 0.6.0)
12
+ syntax_tree_ext (>= 0.6.4)
13
13
 
14
14
  GEM
15
15
  remote: https://rubygems.org/
16
16
  specs:
17
- activesupport (6.1.7.3)
17
+ activesupport (6.1.7.6)
18
18
  concurrent-ruby (~> 1.0, >= 1.0.2)
19
19
  i18n (>= 1.6, < 2)
20
20
  minitest (>= 5.1)
@@ -48,10 +48,10 @@ GEM
48
48
  rb-inotify (~> 0.9, >= 0.9.10)
49
49
  lumberjack (1.2.8)
50
50
  method_source (1.0.0)
51
- minitest (5.18.1)
51
+ minitest (5.20.0)
52
52
  nenv (0.3.0)
53
- node_mutation (1.19.1)
54
- node_query (1.13.5)
53
+ node_mutation (1.20.0)
54
+ node_query (1.13.11)
55
55
  notiffany (0.1.3)
56
56
  nenv (~> 0.1)
57
57
  shellany (~> 0.0)
@@ -84,14 +84,14 @@ GEM
84
84
  rspec-support (~> 3.10.0)
85
85
  rspec-support (3.10.3)
86
86
  shellany (0.0.1)
87
- syntax_tree (6.1.1)
87
+ syntax_tree (6.2.0)
88
88
  prettier_print (>= 1.2.0)
89
- syntax_tree_ext (0.6.0)
89
+ syntax_tree_ext (0.6.4)
90
90
  syntax_tree
91
91
  thor (1.2.1)
92
92
  tzinfo (2.0.6)
93
93
  concurrent-ruby (~> 1.0)
94
- zeitwerk (2.6.8)
94
+ zeitwerk (2.6.11)
95
95
 
96
96
  PLATFORMS
97
97
  ruby
@@ -34,7 +34,7 @@ module Synvert::Core
34
34
  start += index + END_LINE.length
35
35
  end
36
36
  indices.each do |index|
37
- actions.each do |action|
37
+ NodeMutation::Helper.iterate_actions(actions) do |action|
38
38
  action.start -= END_LINE.length if action.start > index
39
39
  action.end -= END_LINE.length if action.end > index
40
40
  end
@@ -37,7 +37,9 @@ module Synvert::Core
37
37
  # @return current ast node
38
38
  # @!attribute [r] mutation_adapter
39
39
  # @return NodeMutation Adapter
40
- attr_reader :file_path, :current_node, :mutation_adapter
40
+ # @!attribute [r] current_mutation
41
+ # @return current node mutation
42
+ attr_reader :file_path, :mutation_adapter, :current_mutation
41
43
  attr_accessor :current_node
42
44
 
43
45
  # Process the instance.
@@ -29,7 +29,9 @@ module Synvert::Core
29
29
  @instance.process_with_node current_node do
30
30
  matching_nodes.each do |matching_node|
31
31
  @instance.process_with_node matching_node do
32
- @instance.instance_eval(&@block)
32
+ @instance.current_mutation.combine do
33
+ @instance.instance_eval(&@block)
34
+ end
33
35
  end
34
36
  end
35
37
  end
@@ -91,7 +91,7 @@ module Synvert::Core
91
91
  # @!attribute [r] gem_spec
92
92
  # @return [Rewriter::GemSpec] the gem spec
93
93
  # @!attribute [r] test_results
94
- # @return [Array<Object>] the test results
94
+ # @return [Hash<String, Object>] the test results
95
95
  # @!attribute [rw] options
96
96
  # @return [Hash] the rewriter options
97
97
  attr_reader :group,
@@ -121,7 +121,7 @@ module Synvert::Core
121
121
  @affected_files = Set.new
122
122
  @redo_until_no_change = false
123
123
  @options = DEFAULT_OPTIONS.dup
124
- @test_results = []
124
+ @test_results = Hash.new { |h, k| h[k] = [] }
125
125
  self.class.register(@group, @name, self)
126
126
  end
127
127
 
@@ -153,7 +153,22 @@ module Synvert::Core
153
153
  if !@affected_files.empty? && @redo_until_no_change # redo
154
154
  test
155
155
  end
156
- @test_results
156
+ @test_results.map do |filename, test_results|
157
+ new_actions = test_results.map(&:actions).flatten.sort_by(&:end)
158
+ last_start = -1
159
+ conflicted = new_actions.any? do |action|
160
+ if last_start > action.end
161
+ true
162
+ else
163
+ last_start = action.start
164
+ false
165
+ end
166
+ end
167
+ result = NodeMutation::Result.new(affected: true, conflicted: conflicted)
168
+ result.actions = new_actions
169
+ result.file_path = filename
170
+ result
171
+ end
157
172
  end
158
173
 
159
174
  # Add a warning.
@@ -287,7 +302,7 @@ module Synvert::Core
287
302
  result = NodeMutation::Result.new(affected: true, conflicted: false)
288
303
  result.actions = [NodeMutation::Struct::Action.new(:add_file, 0, 0, content)]
289
304
  result.file_path = filename
290
- @test_results << result
305
+ merge_test_result(result)
291
306
  return
292
307
  end
293
308
 
@@ -314,7 +329,7 @@ module Synvert::Core
314
329
  result = NodeMutation::Result.new(affected: true, conflicted: false)
315
330
  result.actions = [NodeMutation::Struct::Action.new(:remove_file, 0, -1)]
316
331
  result.file_path = filename
317
- @test_results << result
332
+ merge_test_result(result)
318
333
  return
319
334
  end
320
335
 
@@ -430,7 +445,13 @@ module Synvert::Core
430
445
  end
431
446
 
432
447
  def merge_test_results(results)
433
- @test_results += results.compact.select { |result| result.affected? }
448
+ results.compact.select(&:affected?).each do |result|
449
+ merge_test_result(result)
450
+ end
451
+ end
452
+
453
+ def merge_test_result(result)
454
+ @test_results[result.file_path] << result
434
455
  end
435
456
  end
436
457
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Synvert
4
4
  module Core
5
- VERSION = '1.28.3'
5
+ VERSION = '1.28.5'
6
6
  end
7
7
  end
@@ -6,7 +6,9 @@ module Synvert::Core
6
6
  describe Rewriter::WithinScope do
7
7
  let(:instance) {
8
8
  rewriter = Rewriter.new('foo', 'bar')
9
- Rewriter::Instance.new(rewriter, 'file pattern')
9
+ Rewriter::Instance.new(rewriter, 'file pattern').tap do |instance|
10
+ instance.instance_variable_set(:@current_mutation, NodeMutation.new('source'))
11
+ end
10
12
  }
11
13
  let(:source) { <<~EOS }
12
14
  describe User do
@@ -20,11 +20,11 @@ Gem::Specification.new do |spec|
20
20
  spec.require_paths = ["lib"]
21
21
 
22
22
  spec.add_runtime_dependency "activesupport", "< 7.0.0"
23
- spec.add_runtime_dependency "node_query", ">= 1.13.5"
24
- spec.add_runtime_dependency "node_mutation", ">= 1.19.1"
23
+ spec.add_runtime_dependency "node_query", ">= 1.13.11"
24
+ spec.add_runtime_dependency "node_mutation", ">= 1.20.0"
25
25
  spec.add_runtime_dependency "parser"
26
26
  spec.add_runtime_dependency "parser_node_ext", ">= 1.2.0"
27
27
  spec.add_runtime_dependency "syntax_tree"
28
- spec.add_runtime_dependency "syntax_tree_ext", ">= 0.6.0"
28
+ spec.add_runtime_dependency "syntax_tree_ext", ">= 0.6.4"
29
29
  spec.add_runtime_dependency "parallel"
30
30
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: synvert-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.28.3
4
+ version: 1.28.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-22 00:00:00.000000000 Z
11
+ date: 2023-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -30,28 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 1.13.5
33
+ version: 1.13.11
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 1.13.5
40
+ version: 1.13.11
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: node_mutation
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 1.19.1
47
+ version: 1.20.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 1.19.1
54
+ version: 1.20.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: parser
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - ">="
102
102
  - !ruby/object:Gem::Version
103
- version: 0.6.0
103
+ version: 0.6.4
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
- version: 0.6.0
110
+ version: 0.6.4
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: parallel
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -207,7 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
207
207
  - !ruby/object:Gem::Version
208
208
  version: '0'
209
209
  requirements: []
210
- rubygems_version: 3.4.13
210
+ rubygems_version: 3.4.18
211
211
  signing_key:
212
212
  specification_version: 4
213
213
  summary: convert ruby code to better syntax.