node_mutation 1.23.2 → 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: 8428c48e2173db74d4ab6fca16ae15076106a021792ad2f24ff4e568a6d9af42
4
- data.tar.gz: 4ffe5f7ebc5182b9a493bac7556a3ebe3bb140b435bad9df3529fc49b9e17315
3
+ metadata.gz: 6083384501299b7550d7a91ddee8a643ebfa8ef1d167dd8b95687af79ddcbad4
4
+ data.tar.gz: a1e8ac6f05d36650b5d012a3f5e1bc3adbd7b0a5fde2d2f7eb559bd2a5abea31
5
5
  SHA512:
6
- metadata.gz: 85f90dbcb989220b83677298a8606f7ac33a1db5db5e3d71bab5753e48c62d2f3dd3b7a40fdda548cd6f9fc1a5fe24fc6d4b285f78ecc06b8a1e29145a282bfc
7
- data.tar.gz: c8ff9b11d12b5bdf7d2b550a48e55539abed67880f7b5a410f118f342001847b476b57600628906fe69ee410b8aca73dc9161cac979b45a98ef1eb4a07bd52ed
6
+ metadata.gz: 6fa73367b5a8508bb4b7f5c5fc5831c00f3f1e6d36b9eef0b5cb87ea9814514317d61d0ae5c016b35459e1a232de0fc32a3b9f437c62642ac017d1d406e7f9bf
7
+ data.tar.gz: 67d8d95f5f3877905b55ef4e5c30e193ed8f20d7f1516e93fd26552a5887eae4d3f29c4da85064f8c09844a6188899eb2af32e812e8f573f1c2d2cdf0c6d4cd4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # NodeMutation
2
2
 
3
+ ## 1.24.0 (2024-03-03)
4
+
5
+ * Remove `Adapter#get_indent`
6
+
7
+ ## 1.23.3 (2024-02-20)
8
+
9
+ * `child_node_range` supports `LocalVariableReadNode#name`
10
+
3
11
  ## 1.23.2 (2024-02-17)
4
12
 
5
13
  * Get prism node `source` without prism_ext
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- node_mutation (1.23.2)
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
@@ -141,6 +141,8 @@ class NodeMutation::PrismAdapter < NodeMutation::Adapter
141
141
  NodeMutation::Struct::Range.new(node_loc.start_offset, node_loc.end_offset) if node_loc
142
142
  elsif node.is_a?(Prism::CallNode) && child_name.to_sym == :name
143
143
  NodeMutation::Struct::Range.new(node.message_loc.start_offset, node.message_loc.end_offset)
144
+ elsif node.is_a?(Prism::LocalVariableReadNode) && child_name.to_sym == :name
145
+ NodeMutation::Struct::Range.new(node.location.start_offset, node.location.end_offset)
144
146
  else
145
147
  raise NodeMutation::MethodNotSupported,
146
148
  "#{direct_child_name} is not supported for #{get_source(node)}" unless node.respond_to?(direct_child_name)
@@ -184,10 +186,6 @@ class NodeMutation::PrismAdapter < NodeMutation::Adapter
184
186
  NodeMutation::Struct::Location.new(node.location.end_line, node.location.end_column)
185
187
  end
186
188
 
187
- def get_indent(node)
188
- node.location.start_column
189
- end
190
-
191
189
  private
192
190
 
193
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.2"
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.2
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-17 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: