node_mutation 1.23.2 → 1.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +1 -1
- data/lib/node_mutation/adapter/parser.rb +1 -5
- data/lib/node_mutation/adapter/prism.rb +3 -5
- data/lib/node_mutation/adapter/syntax_tree.rb +1 -5
- data/lib/node_mutation/adapter.rb +0 -7
- data/lib/node_mutation/version.rb +1 -1
- data/sig/node_mutation/adapter.rbs +0 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6083384501299b7550d7a91ddee8a643ebfa8ef1d167dd8b95687af79ddcbad4
|
4
|
+
data.tar.gz: a1e8ac6f05d36650b5d012a3f5e1bc3adbd7b0a5fde2d2f7eb559bd2a5abea31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fa73367b5a8508bb4b7f5c5fc5831c00f3f1e6d36b9eef0b5cb87ea9814514317d61d0ae5c016b35459e1a232de0fc32a3b9f437c62642ac017d1d406e7f9bf
|
7
|
+
data.tar.gz: 67d8d95f5f3877905b55ef4e5c30e193ed8f20d7f1516e93fd26552a5887eae4d3f29c4da85064f8c09844a6188899eb2af32e812e8f573f1c2d2cdf0c6d4cd4
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -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[
|
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[
|
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[
|
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
|
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.
|
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-
|
11
|
+
date: 2024-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: ast node mutation apis
|
14
14
|
email:
|