Class: Ibex::Runtime::SyntaxRepairResult

Inherits:
Object
  • Object
show all
Defined in:
lib/json5/generated_parser.rb

Overview

Immutable syntax-only repair attempt. There is deliberately no value.

Constant Summary collapse

STATUSES =

Signature:

  • Array[Symbol]

%i[accepted progress rejected unavailable exhausted not_found].freeze
BOUNDED_STATUSES =

Signature:

  • Array[Symbol]

%i[selected exhausted not_found].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

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

RBS:

  • (status: Symbol, bounded_status: Symbol, reason: Symbol?, plan: SyntaxRepairPlan?, text_edits: Array[CST::TextEdit], syntax_root: CST::SyntaxNode, diagnostics: Array[SyntaxSessionDiagnostic], updated_source: CST::SourceText?, validation: SyntaxSessionResult?) -> void

Raises:

  • (ArgumentError)


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_statusObject (readonly)

Signature:

  • Symbol



5194
5195
5196
# File 'lib/json5/generated_parser.rb', line 5194

def bounded_status
  @bounded_status
end

#diagnosticsObject (readonly)

Signature:

  • Array[SyntaxSessionDiagnostic]



5199
5200
5201
# File 'lib/json5/generated_parser.rb', line 5199

def diagnostics
  @diagnostics
end

#planObject (readonly)

Signature:

  • SyntaxRepairPlan?



5196
5197
5198
# File 'lib/json5/generated_parser.rb', line 5196

def plan
  @plan
end

#reasonObject (readonly)

Signature:

  • Symbol?



5195
5196
5197
# File 'lib/json5/generated_parser.rb', line 5195

def reason
  @reason
end

#statusObject (readonly)

Signature:

  • Symbol



5193
5194
5195
# File 'lib/json5/generated_parser.rb', line 5193

def status
  @status
end

#syntax_rootObject (readonly)

Signature:

  • CST::SyntaxNode



5198
5199
5200
# File 'lib/json5/generated_parser.rb', line 5198

def syntax_root
  @syntax_root
end

#text_editsObject (readonly)

Signature:

  • Array[CST::TextEdit]



5197
5198
5199
# File 'lib/json5/generated_parser.rb', line 5197

def text_edits
  @text_edits
end

#updated_sourceObject (readonly)

Signature:

  • CST::SourceText?



5200
5201
5202
# File 'lib/json5/generated_parser.rb', line 5200

def updated_source
  @updated_source
end

#validationObject (readonly)

Signature:

  • SyntaxSessionResult?



5201
5202
5203
# File 'lib/json5/generated_parser.rb', line 5201

def validation
  @validation
end

Instance Method Details

#accepted?Boolean

RBS:

  • () -> bool

Returns:

  • (Boolean)


5248
# File 'lib/json5/generated_parser.rb', line 5248

def accepted? = @status == :accepted

#progress?Boolean

RBS:

  • () -> bool

Returns:

  • (Boolean)


5251
# File 'lib/json5/generated_parser.rb', line 5251

def progress? = %i[accepted progress].include?(@status)