node_mutation 1.23.3 → 1.24.0

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: e941ef481546d5db16679d319312e0541c63b61cf5dceefcef91b97625e9ee18
4
- data.tar.gz: e0638f659b75f11cbfadcbddb2a108e50b2e0055918a608b352661a54f5b66b6
3
+ metadata.gz: 6083384501299b7550d7a91ddee8a643ebfa8ef1d167dd8b95687af79ddcbad4
4
+ data.tar.gz: a1e8ac6f05d36650b5d012a3f5e1bc3adbd7b0a5fde2d2f7eb559bd2a5abea31
5
5
  SHA512:
6
- metadata.gz: 5546f83edb1e5cbf6550a9400bacee3d478ead1f8898572be71aaa1e136ffb4fe62aea1927f5eae517d8cbc171b3371700fda96ca8ec3b581e38b5a257194467
7
- data.tar.gz: cdd3a1497c5e6a4e451cdba7af3b55287a3859a4b435b7a8c63108851b1599babd17e78c68d91126ae382c6ecfc98ce2d982d6f871a0ab7c828e9685d3a1cce5
6
+ metadata.gz: 6fa73367b5a8508bb4b7f5c5fc5831c00f3f1e6d36b9eef0b5cb87ea9814514317d61d0ae5c016b35459e1a232de0fc32a3b9f437c62642ac017d1d406e7f9bf
7
+ data.tar.gz: 67d8d95f5f3877905b55ef4e5c30e193ed8f20d7f1516e93fd26552a5887eae4d3f29c4da85064f8c09844a6188899eb2af32e812e8f573f1c2d2cdf0c6d4cd4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # NodeMutation
2
2
 
3
+ ## 1.24.0 (2024-03-03)
4
+
5
+ * Remove `Adapter#get_indent`
6
+
3
7
  ## 1.23.3 (2024-02-20)
4
8
 
5
9
  * `child_node_range` supports `LocalVariableReadNode#name`
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- node_mutation (1.23.3)
4
+ node_mutation (1.24.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -82,7 +82,7 @@ class NodeMutation::ParserAdapter < NodeMutation::Adapter
82
82
  if lines_count > 1 && lines_count == evaluated.size
83
83
  new_code = []
84
84
  lines.each_with_index { |line, index|
85
- new_code << (index == 0 ? line : line[get_indent(evaluated.first) - NodeMutation.tab_width..-1])
85
+ new_code << (index == 0 ? line : line[get_start_loc(evaluated.first).column - NodeMutation.tab_width..-1])
86
86
  }
87
87
  new_code.join("\n")
88
88
  else
@@ -253,10 +253,6 @@ class NodeMutation::ParserAdapter < NodeMutation::Adapter
253
253
  NodeMutation::Struct::Location.new(end_loc.line, end_loc.column)
254
254
  end
255
255
 
256
- def get_indent(node)
257
- file_source(node).split("\n")[get_start_loc(node).line - 1][/\A */].size
258
- end
259
-
260
256
  private
261
257
 
262
258
  def child_node_by_name(node, child_name)
@@ -74,7 +74,7 @@ class NodeMutation::PrismAdapter < NodeMutation::Adapter
74
74
  if lines_count > 1 && lines_count == evaluated.size
75
75
  new_code = []
76
76
  lines.each_with_index { |line, index|
77
- new_code << (index == 0 ? line : line[get_indent(evaluated.first) - NodeMutation.tab_width..-1])
77
+ new_code << (index == 0 ? line : line[get_start_loc(evaluated.first).column - NodeMutation.tab_width..-1])
78
78
  }
79
79
  new_code.join("\n")
80
80
  else
@@ -186,10 +186,6 @@ class NodeMutation::PrismAdapter < NodeMutation::Adapter
186
186
  NodeMutation::Struct::Location.new(node.location.end_line, node.location.end_column)
187
187
  end
188
188
 
189
- def get_indent(node)
190
- node.location.start_column
191
- end
192
-
193
189
  private
194
190
 
195
191
  def child_node_by_name(node, child_name)
@@ -74,7 +74,7 @@ class NodeMutation::SyntaxTreeAdapter < NodeMutation::Adapter
74
74
  if lines_count > 1 && lines_count == evaluated.size
75
75
  new_code = []
76
76
  lines.each_with_index { |line, index|
77
- new_code << (index == 0 ? line : line[get_indent(evaluated.first) - NodeMutation.tab_width..-1])
77
+ new_code << (index == 0 ? line : line[get_start_loc(evaluated.first).column - NodeMutation.tab_width..-1])
78
78
  }
79
79
  new_code.join("\n")
80
80
  else
@@ -185,10 +185,6 @@ class NodeMutation::SyntaxTreeAdapter < NodeMutation::Adapter
185
185
  NodeMutation::Struct::Location.new(node.location.end_line, node.location.end_column)
186
186
  end
187
187
 
188
- def get_indent(node)
189
- node.location.start_column
190
- end
191
-
192
188
  private
193
189
 
194
190
  def child_node_by_name(node, child_name)
@@ -66,11 +66,4 @@ class NodeMutation::Adapter
66
66
  def get_end_loc(node, child_name = nil)
67
67
  raise NotImplementedError, "get_end_loc is not implemented"
68
68
  end
69
-
70
- # Get indent of ast node
71
- # @param node [Node] ast node
72
- # @return [Number] indent
73
- def get_indent(node)
74
- raise NotImplementedError, "get_indent is not implemented"
75
- end
76
69
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class NodeMutation
4
- VERSION = "1.23.3"
4
+ VERSION = "1.24.0"
5
5
  end
@@ -14,6 +14,4 @@ class NodeMutation::Adapter[T]
14
14
  def get_start_loc: (node: T, ?child_name: String) -> NodeMutation::Struct::Location
15
15
 
16
16
  def get_end_loc: (node: T, ?child_name: String) -> NodeMutation::Struct::Location
17
-
18
- def get_indent: (node: T) -> Integer
19
17
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: node_mutation
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.23.3
4
+ version: 1.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Huang
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-02-20 00:00:00.000000000 Z
11
+ date: 2024-03-03 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: ast node mutation apis
14
14
  email: