Skip to content

Commit

Permalink
Turn on 'emit_match_pattern'
Browse files Browse the repository at this point in the history
  • Loading branch information
marcandre committed Dec 28, 2020
1 parent 0d5505c commit dc1d9ae
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ See the [docs site](https://docs.rubocop.org/rubocop-ast) for more details.

### Parser compatibility switches

This gem, by default, uses most [legacy AST output from parser](https://github.com/whitequark/parser/#usage), except for `emit_forward_arg` which is set to `true`.
This gem, by default, uses most [legacy AST output from parser](https://github.com/whitequark/parser/#usage), except for the following which are set to `true`:
* `emit_forward_arg`
* `emit_match_pattern`

The main `RuboCop` gem uses these defaults (and is currently only compatible with these), but this gem can be used separately from `RuboCop` and is meant to be compatible with all settings. For example, to have `-> { ... }` emitted
as `LambdaNode` instead of `SendNode`:
Expand Down
1 change: 1 addition & 0 deletions lib/rubocop/ast/builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ module AST
# root_node = parser.parse(buffer)
class Builder < Parser::Builders::Default
self.emit_forward_arg = true
self.emit_match_pattern = true if respond_to?(:emit_match_pattern=)

# @api private
NODE_MAP = {
Expand Down
3 changes: 3 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
if ENV['MODERNIZE']
RuboCop::AST::Builder.modernize
RuboCop::AST::Builder.emit_forward_arg = false # inverse of default
if RuboCop::AST::Builder.respond_to?(:emit_match_pattern=)
RuboCop::AST::Builder.emit_match_pattern = false # inverse of default
end
end

RSpec.shared_context 'ruby 2.3', :ruby23 do
Expand Down

0 comments on commit dc1d9ae

Please sign in to comment.