File tree Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Expand file tree Collapse file tree 1 file changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -83,14 +83,10 @@ module Source
8383 # @!attribute [r] source_buffer
8484 # @return [Source::Buffer]
8585 #
86- # @!attribute [r] diagnostics
87- # @return [Diagnostic::Engine]
88- #
8986 # @api public
9087 #
9188 class TreeRewriter
9289 attr_reader :source_buffer
93- attr_reader :diagnostics
9490
9591 ##
9692 # @param [Source::Buffer] source_buffer
@@ -99,9 +95,6 @@ def initialize(source_buffer,
9995 crossing_deletions : :accept ,
10096 different_replacements : :accept ,
10197 swallowed_insertions : :accept )
102- @diagnostics = Diagnostic ::Engine . new
103- @diagnostics . consumer = -> diag { $stderr. puts diag . render }
104-
10598 @source_buffer = source_buffer
10699 @in_transaction = false
107100
@@ -324,6 +317,16 @@ def transaction
324317 @in_transaction = previous
325318 end
326319
320+ ##
321+ # Provides access to a diagnostic engine.
322+ # By default outputs diagnostic to $stderr
323+ #
324+ def diagnostics
325+ @diagnostics ||= Diagnostic ::Engine . new . tap do |engine |
326+ engine . consumer = -> diag { $stderr. puts diag . render }
327+ end
328+ end
329+
327330 def in_transaction?
328331 @in_transaction
329332 end
You can’t perform that action at this time.
0 commit comments