Class: Ibex::Runtime::SyntaxRepairPlan
- Inherits:
-
Object
- Object
- Ibex::Runtime::SyntaxRepairPlan
- Defined in:
- lib/ibex/runtime/syntax_repair.rb,
sig/ibex/runtime/syntax_repair.rbs
Overview
One selected runtime plan plus its source-oriented edit projection.
Instance Attribute Summary collapse
- #configurations ⇒ Integer readonly
- #cost ⇒ Integer readonly
- #edits ⇒ Array[SyntaxRepairEdit] readonly
- #runtime_plan ⇒ RepairPlan readonly
Instance Method Summary collapse
-
#initialize(runtime_plan:, edits:) ⇒ SyntaxRepairPlan
constructor
rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity.
Constructor Details
#initialize(runtime_plan:, edits:) ⇒ SyntaxRepairPlan
rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/ibex/runtime/syntax_repair.rb', line 97 def initialize(runtime_plan:, edits:) unless runtime_plan.is_a?(RepairPlan) && edits.is_a?(Array) && edits.all?(SyntaxRepairEdit) raise ArgumentError, "syntax repair plan requires one runtime plan and syntax edits" end raise ArgumentError, "syntax repair edit count must match the runtime plan" unless runtime_plan.edits.length == edits.length runtime_plan.edits.each_with_index do |runtime_edit, index| syntax_edit = edits.fetch(index) next if runtime_edit.kind == syntax_edit.kind && runtime_edit.position == syntax_edit.position && runtime_edit.token_id == syntax_edit.token_id && runtime_edit.token_name == syntax_edit.token_name && runtime_edit.cost == syntax_edit.cost raise ArgumentError, "syntax repair edit metadata must match its runtime plan" end @runtime_plan = runtime_plan @edits = edits.dup.freeze @cost = runtime_plan.cost @configurations = runtime_plan.configurations freeze end |
Instance Attribute Details
#configurations ⇒ Integer (readonly)
93 94 95 |
# File 'lib/ibex/runtime/syntax_repair.rb', line 93 def configurations @configurations end |
#cost ⇒ Integer (readonly)
92 93 94 |
# File 'lib/ibex/runtime/syntax_repair.rb', line 92 def cost @cost end |
#edits ⇒ Array[SyntaxRepairEdit] (readonly)
91 92 93 |
# File 'lib/ibex/runtime/syntax_repair.rb', line 91 def edits @edits end |
#runtime_plan ⇒ RepairPlan (readonly)
90 91 92 |
# File 'lib/ibex/runtime/syntax_repair.rb', line 90 def runtime_plan @runtime_plan end |