node_mutation 1.17.1 → 1.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +1 -1
- data/lib/node_mutation/action.rb +1 -1
- data/lib/node_mutation/adapter/parser.rb +4 -4
- data/lib/node_mutation/adapter/syntax_tree.rb +4 -0
- data/lib/node_mutation/adapter.rb +2 -2
- data/lib/node_mutation/version.rb +1 -1
- data/sig/node_mutation/adapter.rbs +1 -1
- 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: ed3138d259ca0498f5435e750d23f868f85284ff5fd7150a01faef49d191e30c
|
4
|
+
data.tar.gz: e4ab22239669f8712a5dda6cd6d01a37f01ec73bb86a9e4429d3b01355b2594b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c534ac19b76e03a74e2f75eb66754e080e2453dc00f67ddc300b35e097a02577a573a926474d5f6e4ddededa14c434bf18f500f1f16a9591c1a05ce41271338c
|
7
|
+
data.tar.gz: f1a49e7ce258e4b4b89f1f3fbf7741fd83b04ede95e5593a1b2e3e57fd2ac5967c2500450a3244b5951435f447d81a01fff01179a53c0242f431b8758e4f97a2
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/lib/node_mutation/action.rb
CHANGED
@@ -8,7 +8,7 @@ class NodeMutation::ParserAdapter < NodeMutation::Adapter
|
|
8
8
|
if node.is_a?(Array)
|
9
9
|
return "" if node.empty?
|
10
10
|
|
11
|
-
source =
|
11
|
+
source = file_source(node.first)
|
12
12
|
source[node.first.loc.expression.begin_pos...node.last.loc.expression.end_pos]
|
13
13
|
else
|
14
14
|
node.loc.expression.source
|
@@ -28,7 +28,7 @@ class NodeMutation::ParserAdapter < NodeMutation::Adapter
|
|
28
28
|
end
|
29
29
|
when Array
|
30
30
|
if evaluated.size > 0
|
31
|
-
file_source =
|
31
|
+
file_source = file_source(evaluated.first)
|
32
32
|
source = file_source[evaluated.first.loc.expression.begin_pos...evaluated.last.loc.expression.end_pos]
|
33
33
|
lines = source.split "\n"
|
34
34
|
lines_count = lines.length
|
@@ -52,7 +52,7 @@ class NodeMutation::ParserAdapter < NodeMutation::Adapter
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
def
|
55
|
+
def file_source(node)
|
56
56
|
node.loc.expression.source_buffer.source
|
57
57
|
end
|
58
58
|
|
@@ -162,7 +162,7 @@ class NodeMutation::ParserAdapter < NodeMutation::Adapter
|
|
162
162
|
end
|
163
163
|
|
164
164
|
def get_indent(node)
|
165
|
-
|
165
|
+
file_source(node).split("\n")[get_start_loc(node).line - 1][/\A */].size
|
166
166
|
end
|
167
167
|
|
168
168
|
private
|
@@ -44,6 +44,10 @@ class NodeMutation::SyntaxTreeAdapter < NodeMutation::Adapter
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
+
def file_source(node)
|
48
|
+
node.source
|
49
|
+
end
|
50
|
+
|
47
51
|
def child_node_range(node, child_name)
|
48
52
|
child_node = child_node_by_name(node, child_name)
|
49
53
|
return nil if child_node.nil?
|
@@ -23,8 +23,8 @@ class NodeMutation::Adapter
|
|
23
23
|
# The file content of the ast node file
|
24
24
|
# @param node [Node] ast node
|
25
25
|
# @return file content
|
26
|
-
def
|
27
|
-
raise NotImplementedError, "
|
26
|
+
def file_source(node)
|
27
|
+
raise NotImplementedError, "file_source is not implemented"
|
28
28
|
end
|
29
29
|
|
30
30
|
# Get the start/end range of the child node
|
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.18.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: 2023-05-
|
11
|
+
date: 2023-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: ast node mutation apis
|
14
14
|
email:
|