node_mutation 1.15.0 → 1.15.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/Gemfile.lock +1 -1
- data/lib/node_mutation/parser_adapter.rb +2 -0
- data/lib/node_mutation/version.rb +1 -1
- data/lib/node_mutation.rb +9 -3
- data/sig/node_mutation.rbs +3 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fadeda3c2cf8d3f0d618b4a9996241619ab404fef419e87026a443c8078e06f
|
4
|
+
data.tar.gz: 39d9939b21c96821ce056ad1983b301d16fc1d49c936ce082e3b208a6a93547c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdbfe2e830ef226679fa3556b52a23f67755afb2e33a7f8efaf5bd47e4f0e1d59f3b43af99bf4542587b2c9eee832a5309f0531689cc98cb954e38ca03bc0edc
|
7
|
+
data.tar.gz: b9b9d033e38d84f4672cdb3630d44f8179af09ceb268b25d9e88fe3a86eff97d543f710d3f0c3ecbb3f8a2c22c45de2998a02b32b454dd2eff08d6d907ba4f4e
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -90,6 +90,8 @@ class NodeMutation::ParserAdapter < NodeMutation::Adapter
|
|
90
90
|
)
|
91
91
|
when %i[class name], %i[const name], %i[cvar name], %i[def name], %i[defs name], %i[gvar name], %i[ivar name], %i[lvar name]
|
92
92
|
NodeMutation::Struct::Range.new(node.loc.name.begin_pos, node.loc.name.end_pos)
|
93
|
+
when %i[const double_colon]
|
94
|
+
NodeMutation::Struct::Range.new(node.loc.double_colon.begin_pos, node.loc.double_colon.end_pos)
|
93
95
|
when %i[defs dot]
|
94
96
|
NodeMutation::Struct::Range.new(node.loc.operator.begin_pos, node.loc.operator.end_pos) if node.loc.operator
|
95
97
|
when %i[defs self]
|
data/lib/node_mutation.rb
CHANGED
@@ -205,9 +205,15 @@ class NodeMutation
|
|
205
205
|
# end
|
206
206
|
# end
|
207
207
|
def wrap(node, prefix:, suffix:, newline: false)
|
208
|
-
|
209
|
-
|
210
|
-
|
208
|
+
if newline
|
209
|
+
indentation = NodeMutation.adapter.get_start_loc(node).column
|
210
|
+
@actions << InsertAction.new(node, prefix + "\n" + ' ' * indentation, at: 'beginning').process
|
211
|
+
@actions << InsertAction.new(node, "\n" + ' ' * indentation + suffix, at: 'end').process
|
212
|
+
@actions << IndentAction.new(node).process
|
213
|
+
else
|
214
|
+
@actions << InsertAction.new(node, prefix, at: 'beginning').process
|
215
|
+
@actions << InsertAction.new(node, suffix, at: 'end').process
|
216
|
+
end
|
211
217
|
end
|
212
218
|
|
213
219
|
# No operation.
|
data/sig/node_mutation.rbs
CHANGED
@@ -23,6 +23,8 @@ module NodeMutation[T]
|
|
23
23
|
|
24
24
|
def delete: (node: T, *selectors: Array[String], **options: { and_comma: bool }) -> void
|
25
25
|
|
26
|
+
def indent: (node: T, ?tab_size: Integer) -> void
|
27
|
+
|
26
28
|
def insert: (node: T, code: String, ?at: "beginning" | "end", ?to: nil | String) -> void
|
27
29
|
|
28
30
|
def prepend: (node: T, code: String) -> void
|
@@ -33,7 +35,7 @@ module NodeMutation[T]
|
|
33
35
|
|
34
36
|
def replace_with: (node: T, code: String) -> void
|
35
37
|
|
36
|
-
def wrap: (node: T,
|
38
|
+
def wrap: (node: T, prefix: String, suffix: String, ?newline: bool) -> void
|
37
39
|
|
38
40
|
def noop: (node: T) -> void
|
39
41
|
|