synvert-core 0.16.0 → 0.16.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: c2c7961db23fe0b1984a90265b8a35d1927d7cfc7dfaa5d66cc7d71d80f3315a
4
- data.tar.gz: 66826322dc49882fd9b718e895af0ff954e3c2137014661f97832a94d3de5104
3
+ metadata.gz: 327989a145ffc5562768e51cf54f6a86ad2bed0b329c7398eb9499a3fa0f4b07
4
+ data.tar.gz: d7cb9ca59c8a821329b7063e515a329ab451a83ce80439028af458d9cf745804
5
5
  SHA512:
6
- metadata.gz: c396d7f949f0300cbac84fd1324728d3466c514cedcc463ab955f3c7cae3f83bd4e080c92d3ca88f32798ce8b0b6c882113cac4b4ea41a98540b8cc4977ebdb0
7
- data.tar.gz: 804ebc08dd0fe453f932e767c960923bbe7270a3cef0fd95cb61d5b85488a137d0b2da8558823c4cf8cba22b150ca742fb1818d22a1bacccfc1a92da55daf1cc
6
+ metadata.gz: 7e3afcda5002e5d275faba969dc193e0d8f88781e647ab7fecb44bbbe3b0de383aa74bfad2341b406e148005c4ec7b44fbe941ab884f2a1968d4c81ec1cb9080
7
+ data.tar.gz: 2b504f8c0a822ae0874e154d45f811b9301bda4c7399bf4c54c365d30bf719367d17a04f0bd41fd77c618c0045901bf70e825301b3811ba023fe0f20bf1c17d5
@@ -1,5 +1,7 @@
1
1
  # CHANGELOG
2
2
 
3
+ * Abstract `find_matching_nodes`
4
+
3
5
  ## 0.16.0 (2021-01-17)
4
6
 
5
7
  * Use parser 3.0.0
@@ -2,14 +2,14 @@
2
2
 
3
3
  module Synvert::Core
4
4
  # Rewriter not found exception.
5
- class RewriterNotFound < Exception
5
+ class RewriterNotFound < RuntimeError
6
6
  end
7
7
 
8
8
  # Gemfile.lock not found exception.
9
- class GemfileLockNotFound < Exception
9
+ class GemfileLockNotFound < RuntimeError
10
10
  end
11
11
 
12
12
  # Method not supported exception.
13
- class MethodNotSupported < Exception
13
+ class MethodNotSupported < RuntimeError
14
14
  end
15
15
  end
@@ -108,7 +108,7 @@ module Synvert::Core
108
108
  if @actions.length > 0
109
109
  @actions.sort_by! { |action| action.send(@options[:sort_by]) }
110
110
  conflict_actions = get_conflict_actions
111
- @actions.reverse.each do |action|
111
+ @actions.reverse_each do |action|
112
112
  source[action.begin_pos...action.end_pos] = action.rewritten_code
113
113
  source = remove_code_or_whole_line(source, action.line)
114
114
  end
@@ -22,18 +22,8 @@ module Synvert::Core
22
22
  current_node = @instance.current_node
23
23
  return unless current_node
24
24
 
25
+ matching_nodes = find_matching_nodes(current_node)
25
26
  @instance.process_with_node current_node do
26
- matching_nodes = []
27
- matching_nodes << current_node if current_node.match? @rules
28
- if @options[:recursive]
29
- current_node.recursive_children do |child_node|
30
- matching_nodes << child_node if child_node.match? @rules
31
- end
32
- else
33
- current_node.children do |child_node|
34
- matching_nodes << child_node if child_node.match? @rules
35
- end
36
- end
37
27
  matching_nodes.each do |matching_node|
38
28
  @instance.process_with_node matching_node do
39
29
  @instance.instance_eval &@block
@@ -41,5 +31,22 @@ module Synvert::Core
41
31
  end
42
32
  end
43
33
  end
34
+
35
+ private
36
+
37
+ def find_matching_nodes(current_node)
38
+ matching_nodes = []
39
+ if @options[:recursive]
40
+ matching_nodes << current_node if current_node.match? @rules
41
+ current_node.recursive_children do |child_node|
42
+ matching_nodes << child_node if child_node.match? @rules
43
+ end
44
+ else
45
+ current_node.each do |child_node|
46
+ matching_nodes << child_node if child_node.match? @rules
47
+ end
48
+ end
49
+ matching_nodes
50
+ end
44
51
  end
45
52
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Synvert
4
4
  module Core
5
- VERSION = "0.16.0"
5
+ VERSION = "0.16.1"
6
6
  end
7
7
  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: 0.16.0
4
+ version: 0.16.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-17 00:00:00.000000000 Z
11
+ date: 2021-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parser