Module: Oselvar::Var::Core::Diagnostics

Defined in:
lib/oselvar/var/core/diagnostics.rb

Class Method Summary collapse

Class Method Details

.ambiguous_match(input) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/oselvar/var/core/diagnostics.rb', line 16

def ambiguous_match(input)
  lines = input.candidates.map do |c|
    "  '#{c.expression}'    at #{c.source_file}:#{c.source_line}"
  end.join("\n")
  Diagnostic.new(
    severity: 'error',
    code: 'ambiguous-match',
    message: "Ambiguous step: \"#{input.text}\"\nMatched by:\n#{lines}",
    span: input.span
  )
end

.drift_detected(name, span) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/oselvar/var/core/diagnostics.rb', line 28

def drift_detected(name, span)
  Diagnostic.new(
    severity: 'error',
    code: 'drift',
    message: "This paragraph was an example and no longer matches any step (drift): \"#{name}\".\n" \
             'Fix the step so it matches again, or accept it as prose (run in update mode).',
    span: span
  )
end

.error_fence_without_step(span) ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'lib/oselvar/var/core/diagnostics.rb', line 38

def error_fence_without_step(span)
  Diagnostic.new(
    severity: 'error',
    code: 'error-fence-without-step',
    message: 'This `error` fence marks the example as expected-to-fail, ' \
             'but the example has no step to run.',
    span: span
  )
end