Module: Semdiff::CompilerUtils
- Included in:
- AlgebraCompiler, AliasingCompiler, ConstantsCompiler, IdentityCompiler, StructuresCompiler
- Defined in:
- lib/semdiff/utils/compiler_utils.rb
Class Method Summary collapse
-
.inherit_newline(parent, node) ⇒ Object
NOTE: Uses
sendto access protected flags, seems preferable over extending Node(s).
Class Method Details
.inherit_newline(parent, node) ⇒ Object
NOTE: Uses send to access protected flags, seems
preferable over extending Node(s)
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/semdiff/utils/compiler_utils.rb', line 7 def self.inherit_newline(parent, node) need_newline = parent.newline? if need_newline == node.newline? node else flags = node.send(:flags) new_flags = if need_newline flags | Prism::NodeFlags::NEWLINE else flags & ~Prism::NodeFlags::NEWLINE end node.copy(flags: new_flags) end end |