diff --git a/lib/syntax_tree/node.rb b/lib/syntax_tree/node.rb index e5aa6b50..7d7e0f87 100644 --- a/lib/syntax_tree/node.rb +++ b/lib/syntax_tree/node.rb @@ -7456,6 +7456,7 @@ def deconstruct_keys(_keys) { beginning: beginning, ending: ending, + options: options, parts: parts, location: location, comments: comments @@ -7490,18 +7491,22 @@ def format(q) end q.text("}") - q.text(ending[1..]) + q.text(options) end else q.group do q.text("/") q.format_each(parts) q.text("/") - q.text(ending[1..]) + q.text(options) end end end + def options + ending[1..] + end + private def include?(pattern) diff --git a/lib/syntax_tree/visitor/field_visitor.rb b/lib/syntax_tree/visitor/field_visitor.rb index 06e8945f..827b4e3a 100644 --- a/lib/syntax_tree/visitor/field_visitor.rb +++ b/lib/syntax_tree/visitor/field_visitor.rb @@ -738,6 +738,7 @@ def visit_regexp_end(node) def visit_regexp_literal(node) node(node, "regexp_literal") do list("parts", node.parts) + field("options", node.options) comments(node) end end