Class: DrgDSL::ParenCleaner
- Inherits:
-
Object
- Object
- DrgDSL::ParenCleaner
- Includes:
- Visitor
- Defined in:
- lib/drgdsl/paren_cleaner.rb
Class Method Summary collapse
-
.clean(ast, remove_outer_parens: true) ⇒ Node
Ast without redundant ParenExpressions.
-
.remove_redundant_parens(expression) ⇒ String
Pretty printed expression without any redundant parentheses.
Methods included from Visitor
#cache?, #cache_key, included, #visit, #visit_BasicExpression, #visit_Comparison, #visit_Constant, #visit_DateExpression, #visit_DrgLink, #visit_Empty, #visit_FunctionCall, #visit_NotExpression, #visit_SrglrbTableCondition, #visit_TableCondition, #visit_UnaryCondition, #visit_Variable, #visit_nil
Class Method Details
.clean(ast, remove_outer_parens: true) ⇒ Node
Returns ast without redundant ParenExpressions.
18 19 20 21 22 23 24 25 26 |
# File 'lib/drgdsl/paren_cleaner.rb', line 18 def self.clean(ast, remove_outer_parens: true) # If the whole expression is wrapped in parentheses, we can start # visiting the first child. if ast.type == 'ParenExpression' && remove_outer_parens ast = ast.expression end ast.accept(new) end |