Class: Evilution::Mutator::Operator::SplatOperator Private
- Defined in:
- lib/evilution/mutator/operator/splat_operator.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #visit_assoc_splat_node(node) ⇒ Object private
- #visit_hash_node(node) ⇒ Object private
-
#visit_keyword_hash_node(node) ⇒ Object
private
KeywordHashNode wraps call-arg kwargs +
**splat. - #visit_splat_node(node) ⇒ Object private
Methods inherited from Base
#call, clear_parse_cache!, #initialize, operator_name, parsed_tree_for
Constructor Details
This class inherits a constructor from Evilution::Mutator::Base
Instance Method Details
#visit_assoc_splat_node(node) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
36 37 38 39 40 41 42 43 44 |
# File 'lib/evilution/mutator/operator/splat_operator.rb', line 36 def visit_assoc_splat_node(node) return super if node.value.nil? return super if hash_elements.include?(node) return super if kwarg_preceded_splats.include?(node) mutate_remove_double_splat(node) super end |
#visit_hash_node(node) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
12 13 14 15 |
# File 'lib/evilution/mutator/operator/splat_operator.rb', line 12 def visit_hash_node(node) node.elements.each { |el| hash_elements.add(el) } super end |
#visit_keyword_hash_node(node) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
KeywordHashNode wraps call-arg kwargs + **splat. When an explicit
k: v precedes a **opts splat in the same call, demoting **opts to
bare opts puts a positional after a keyword and Ruby rejects it
(bar(k: v, opts) is a syntax error). Mark such splats so
visit_assoc_splat_node skips them. Splats that come BEFORE any kwarg
(bar(**opts, k: v)) are still safe — positional-before-keyword is fine.
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/evilution/mutator/operator/splat_operator.rb', line 23 def visit_keyword_hash_node(node) seen_kwarg = false node.elements.each do |el| if el.is_a?(Prism::AssocSplatNode) && seen_kwarg kwarg_preceded_splats.add(el) elsif el.is_a?(Prism::AssocNode) seen_kwarg = true end end super end |
#visit_splat_node(node) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
6 7 8 9 10 |
# File 'lib/evilution/mutator/operator/splat_operator.rb', line 6 def visit_splat_node(node) mutate_remove_splat(node) if node.expression super end |