Class: Ryac::Pipeline::BooleanShorten
- Defined in:
- lib/ryac/pipeline/boolean_shorten.rb,
sig/ryac/pipeline/boolean_shorten.rbs
Instance Method Summary collapse
Methods inherited from Stage
#analysis, #analysis_options, #call, #finish, #fixpoint?, #needs_analysis?, new
Methods included from SourcePatcher
#apply_patches, #mk, #src, #verify_parses
Instance Method Details
#collect(ctx, patches) ⇒ void
This method returns an undefined value.
6 7 8 |
# File 'lib/ryac/pipeline/boolean_shorten.rb', line 6 def collect(ctx, patches) walk(ctx.ast, patches) end |
#walk(node, patches, inside_block_params: false) ⇒ void
This method returns an undefined value.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/ryac/pipeline/boolean_shorten.rb', line 12 def walk(node, patches, inside_block_params: false) case node when Prism::BlockParametersNode node.compact_child_nodes.each { |child| walk(child, patches, inside_block_params: true) } return when Prism::TrueNode patches << mk(node, '!!1') unless inside_block_params when Prism::FalseNode patches << mk(node, '!1') unless inside_block_params end node.compact_child_nodes.each { |child| walk(child, patches, inside_block_params: inside_block_params) } end |