Class: Ibex::Runtime::SyntaxRepairResult
- Inherits:
-
Object
- Object
- Ibex::Runtime::SyntaxRepairResult
- Defined in:
- lib/json5/generated_parser.rb
Overview
Immutable syntax-only repair attempt. There is deliberately no value.
Constant Summary collapse
- STATUSES =
%i[accepted progress rejected unavailable exhausted not_found].freeze
- BOUNDED_STATUSES =
%i[selected exhausted not_found].freeze
Instance Attribute Summary collapse
- #bounded_status ⇒ Object readonly
- #diagnostics ⇒ Object readonly
- #plan ⇒ Object readonly
- #reason ⇒ Object readonly
- #status ⇒ Object readonly
- #syntax_root ⇒ Object readonly
- #text_edits ⇒ Object readonly
- #updated_source ⇒ Object readonly
- #validation ⇒ Object readonly
Instance Method Summary collapse
- #accepted? ⇒ Boolean
-
#initialize(status:, bounded_status:, reason:, plan:, text_edits:, syntax_root:, diagnostics:, updated_source:, validation:) ⇒ SyntaxRepairResult
constructor
rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity.
- #progress? ⇒ Boolean
Constructor Details
#initialize(status:, bounded_status:, reason:, plan:, text_edits:, syntax_root:, diagnostics:, updated_source:, validation:) ⇒ SyntaxRepairResult
rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 |
# File 'lib/json5/generated_parser.rb', line 5208 def initialize(status:, bounded_status:, reason:, plan:, text_edits:, syntax_root:, diagnostics:, updated_source:, validation:) raise ArgumentError, "unknown syntax repair status #{status.inspect}" unless STATUSES.include?(status) unless BOUNDED_STATUSES.include?(bounded_status) raise ArgumentError, "unknown syntax repair bounded status #{bounded_status.inspect}" end unless text_edits.is_a?(Array) && text_edits.all?(CST::TextEdit) raise ArgumentError, "syntax repair text_edits must contain only CST::TextEdit values" end unless diagnostics.is_a?(Array) && diagnostics.all?(SyntaxSessionDiagnostic) raise ArgumentError, "syntax repair diagnostics must be immutable syntax-session diagnostics" end raise ArgumentError, "syntax_root must be a CST::SyntaxNode" unless syntax_root.is_a?(CST::SyntaxNode) raise ArgumentError, "syntax repair reason must be a Symbol or nil" unless reason.nil? || reason.is_a?(Symbol) unless plan.nil? || plan.is_a?(SyntaxRepairPlan) raise ArgumentError, "syntax repair plan must be a SyntaxRepairPlan or nil" end unless updated_source.nil? || updated_source.is_a?(CST::SourceText) raise ArgumentError, "updated_source must be a CST::SourceText or nil" end unless validation.nil? || validation.is_a?(SyntaxSessionResult) raise ArgumentError, "validation must be a SyntaxSessionResult or nil" end validate_result_shape!(status, bounded_status, reason, plan, text_edits, updated_source, validation) @status = status @bounded_status = bounded_status @reason = reason @plan = plan @text_edits = text_edits.dup.freeze @syntax_root = syntax_root @diagnostics = diagnostics.dup.freeze @updated_source = updated_source @validation = validation freeze end |
Instance Attribute Details
#bounded_status ⇒ Object (readonly)
5194 5195 5196 |
# File 'lib/json5/generated_parser.rb', line 5194 def bounded_status @bounded_status end |
#diagnostics ⇒ Object (readonly)
5199 5200 5201 |
# File 'lib/json5/generated_parser.rb', line 5199 def diagnostics @diagnostics end |
#plan ⇒ Object (readonly)
5196 5197 5198 |
# File 'lib/json5/generated_parser.rb', line 5196 def plan @plan end |
#reason ⇒ Object (readonly)
5195 5196 5197 |
# File 'lib/json5/generated_parser.rb', line 5195 def reason @reason end |
#status ⇒ Object (readonly)
5193 5194 5195 |
# File 'lib/json5/generated_parser.rb', line 5193 def status @status end |
#syntax_root ⇒ Object (readonly)
5198 5199 5200 |
# File 'lib/json5/generated_parser.rb', line 5198 def syntax_root @syntax_root end |
#text_edits ⇒ Object (readonly)
5197 5198 5199 |
# File 'lib/json5/generated_parser.rb', line 5197 def text_edits @text_edits end |
#updated_source ⇒ Object (readonly)
5200 5201 5202 |
# File 'lib/json5/generated_parser.rb', line 5200 def updated_source @updated_source end |
#validation ⇒ Object (readonly)
5201 5202 5203 |
# File 'lib/json5/generated_parser.rb', line 5201 def validation @validation end |
Instance Method Details
#accepted? ⇒ Boolean
5248 |
# File 'lib/json5/generated_parser.rb', line 5248 def accepted? = @status == :accepted |
#progress? ⇒ Boolean
5251 |
# File 'lib/json5/generated_parser.rb', line 5251 def progress? = %i[accepted progress].include?(@status) |