Class: Ast::Merge::Comment::SupportStyle
- Inherits:
-
Object
- Object
- Ast::Merge::Comment::SupportStyle
- Defined in:
- lib/ast/merge/comment/support_style.rb
Overview
Describes how a merge pipeline will own, read, and write comments.
Capability answers what a parser/backend can provide. SupportStyle answers how the merge implementation intends to use those comments end-to-end. Keeping the two concepts separate lets parsers expose native comment information while merge gems still converge on a portable write contract, even when the real architecture uses a synthetic ownership or output pipeline internally.
This is the support-style/write-model axis. It is deliberately separate from parser capability and from ruleset capability declarations.
Constant Summary collapse
- STYLES =
%i[ source_augmented_portable_write native_read_portable_write native_mutation hybrid_native_owned unavailable ].freeze
Instance Attribute Summary collapse
-
#details ⇒ Object
readonly
Returns the value of attribute details.
-
#style ⇒ Object
readonly
Returns the value of attribute style.
Class Method Summary collapse
-
.hybrid_native_owned(**details) ⇒ SupportStyle
Build a support style that mixes native-owned and synthetic comment output.
-
.native_mutation(**details) ⇒ SupportStyle
Build a support style that mutates and emits comments via the native parser AST.
-
.native_read_portable_write(**details) ⇒ SupportStyle
Build a support style that reads parser-native comments but emits them through the merge layer's portable write contract.
-
.source_augmented_portable_write(**details) ⇒ SupportStyle
Build a support style that scans or tracks comments from source and emits them entirely through the merge layer.
-
.unavailable(**details) ⇒ SupportStyle
Build a support style describing no usable comment pipeline.
Instance Method Summary collapse
- #available? ⇒ Boolean
- #hybrid_native_owned? ⇒ Boolean
- #initialize(style:, details: {}, **options) ⇒ void constructor
-
#inspect ⇒ String
Return a concise debug representation of the support style.
- #native_mutation? ⇒ Boolean
- #native_read? ⇒ Boolean
- #native_read_portable_write? ⇒ Boolean
- #native_write? ⇒ Boolean
- #portable_write? ⇒ Boolean
- #source_augmented_portable_write? ⇒ Boolean
-
#to_h ⇒ Hash
Return the support style as a normalized Hash.
- #unavailable? ⇒ Boolean
Constructor Details
#initialize(style:, details: {}, **options) ⇒ void
78 79 80 81 |
# File 'lib/ast/merge/comment/support_style.rb', line 78 def initialize(style:, details: {}, **) @style = normalize_style(style) @details = details.merge().freeze end |
Instance Attribute Details
#details ⇒ Object (readonly)
Returns the value of attribute details.
26 27 28 |
# File 'lib/ast/merge/comment/support_style.rb', line 26 def details @details end |
#style ⇒ Object (readonly)
Returns the value of attribute style.
26 27 28 |
# File 'lib/ast/merge/comment/support_style.rb', line 26 def style @style end |
Class Method Details
.hybrid_native_owned(**details) ⇒ SupportStyle
Build a support style that mixes native-owned and synthetic comment output. This should remain an escape hatch, not the default target.
61 62 63 |
# File 'lib/ast/merge/comment/support_style.rb', line 61 def hybrid_native_owned(**details) new(style: :hybrid_native_owned, details: details) end |
.native_mutation(**details) ⇒ SupportStyle
Build a support style that mutates and emits comments via the native parser AST.
52 53 54 |
# File 'lib/ast/merge/comment/support_style.rb', line 52 def native_mutation(**details) new(style: :native_mutation, details: details) end |
.native_read_portable_write(**details) ⇒ SupportStyle
Build a support style that reads parser-native comments but emits them through the merge layer's portable write contract.
43 44 45 |
# File 'lib/ast/merge/comment/support_style.rb', line 43 def native_read_portable_write(**details) new(style: :native_read_portable_write, details: details) end |
.source_augmented_portable_write(**details) ⇒ SupportStyle
Build a support style that scans or tracks comments from source and emits them entirely through the merge layer.
34 35 36 |
# File 'lib/ast/merge/comment/support_style.rb', line 34 def source_augmented_portable_write(**details) new(style: :source_augmented_portable_write, details: details) end |
.unavailable(**details) ⇒ SupportStyle
Build a support style describing no usable comment pipeline.
69 70 71 |
# File 'lib/ast/merge/comment/support_style.rb', line 69 def unavailable(**details) new(style: :unavailable, details: details) end |
Instance Method Details
#available? ⇒ Boolean
115 116 117 |
# File 'lib/ast/merge/comment/support_style.rb', line 115 def available? !unavailable? end |
#hybrid_native_owned? ⇒ Boolean
95 96 97 |
# File 'lib/ast/merge/comment/support_style.rb', line 95 def hybrid_native_owned? style == :hybrid_native_owned end |
#inspect ⇒ String
Return a concise debug representation of the support style.
136 137 138 |
# File 'lib/ast/merge/comment/support_style.rb', line 136 def inspect "#<#{self.class.name} style=#{style} details=#{details.inspect}>" end |
#native_mutation? ⇒ Boolean
91 92 93 |
# File 'lib/ast/merge/comment/support_style.rb', line 91 def native_mutation? style == :native_mutation end |
#native_read? ⇒ Boolean
107 108 109 |
# File 'lib/ast/merge/comment/support_style.rb', line 107 def native_read? native_read_portable_write? || native_mutation? || hybrid_native_owned? end |
#native_read_portable_write? ⇒ Boolean
87 88 89 |
# File 'lib/ast/merge/comment/support_style.rb', line 87 def native_read_portable_write? style == :native_read_portable_write end |
#native_write? ⇒ Boolean
111 112 113 |
# File 'lib/ast/merge/comment/support_style.rb', line 111 def native_write? native_mutation? || hybrid_native_owned? end |
#portable_write? ⇒ Boolean
103 104 105 |
# File 'lib/ast/merge/comment/support_style.rb', line 103 def portable_write? source_augmented_portable_write? || native_read_portable_write? end |
#source_augmented_portable_write? ⇒ Boolean
83 84 85 |
# File 'lib/ast/merge/comment/support_style.rb', line 83 def source_augmented_portable_write? style == :source_augmented_portable_write end |
#to_h ⇒ Hash
Return the support style as a normalized Hash.
122 123 124 125 126 127 128 129 130 131 |
# File 'lib/ast/merge/comment/support_style.rb', line 122 def to_h { style: style, details: details, portable_write: portable_write?, native_read: native_read?, native_write: native_write?, available: available? } end |
#unavailable? ⇒ Boolean
99 100 101 |
# File 'lib/ast/merge/comment/support_style.rb', line 99 def unavailable? style == :unavailable end |