Class: Steep::Drivers::DiagnosticPrinter

Inherits:
Object
  • Object
show all
Defined in:
lib/steep/drivers/diagnostic_printer.rb,
lib/steep/drivers/diagnostic_printer/base_formatter.rb,
lib/steep/drivers/diagnostic_printer/code_formatter.rb,
lib/steep/drivers/diagnostic_printer/github_actions_formatter.rb

Defined Under Namespace

Classes: BaseFormatter, CodeFormatter, GitHubActionsFormatter

Constant Summary collapse

LSP =
LanguageServer::Protocol

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(stdout:, buffer:, formatter: 'code') ⇒ DiagnosticPrinter

Returns a new instance of DiagnosticPrinter.



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/steep/drivers/diagnostic_printer.rb', line 10

def initialize(stdout:, buffer:, formatter: 'code')
  @stdout = stdout
  @buffer = buffer
  @formatter = case formatter
  when 'code'
    CodeFormatter.new(stdout: stdout, buffer: buffer)
  when 'github'
    GitHubActionsFormatter.new(stdout: stdout, buffer: buffer)
  else
    raise "Unknown formatter: #{formatter}"
  end
end

Instance Attribute Details

#bufferObject (readonly)

Returns the value of attribute buffer.



8
9
10
# File 'lib/steep/drivers/diagnostic_printer.rb', line 8

def buffer
  @buffer
end

#stdoutObject (readonly)

Returns the value of attribute stdout.



7
8
9
# File 'lib/steep/drivers/diagnostic_printer.rb', line 7

def stdout
  @stdout
end

Instance Method Details



23
24
25
# File 'lib/steep/drivers/diagnostic_printer.rb', line 23

def print(diagnostic, prefix: "", source: true)
  @formatter.print(diagnostic, prefix: prefix, source: source)
end