Class: Ibex::Runtime::SyntaxRepairPlan

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(runtime_plan:, edits:) ⇒ SyntaxRepairPlan

rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity

RBS:

  • (runtime_plan: RepairPlan, edits: Array[SyntaxRepairEdit]) -> void

Parameters:



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

#configurationsInteger (readonly)

Signature:

  • Integer

Returns:

  • (Integer)


93
94
95
# File 'lib/ibex/runtime/syntax_repair.rb', line 93

def configurations
  @configurations
end

#costInteger (readonly)

Signature:

  • Integer

Returns:

  • (Integer)


92
93
94
# File 'lib/ibex/runtime/syntax_repair.rb', line 92

def cost
  @cost
end

#editsArray[SyntaxRepairEdit] (readonly)

Signature:

  • Array[SyntaxRepairEdit]

Returns:



91
92
93
# File 'lib/ibex/runtime/syntax_repair.rb', line 91

def edits
  @edits
end

#runtime_planRepairPlan (readonly)

Signature:

  • RepairPlan

Returns:



90
91
92
# File 'lib/ibex/runtime/syntax_repair.rb', line 90

def runtime_plan
  @runtime_plan
end