Class: Oxc::Diagnostic
- Inherits:
-
Object
- Object
- Oxc::Diagnostic
- Defined in:
- lib/oxc/diagnostic.rb,
sig/oxc/diagnostic.rbs
Constant Summary collapse
- ERROR =
"error"- WARNING =
"warning"
Instance Attribute Summary collapse
- #codeframe ⇒ String? readonly
- #help ⇒ String? readonly
- #labels ⇒ Array[Oxc::Label] readonly
- #message ⇒ String readonly
- #severity ⇒ String readonly
Class Method Summary collapse
-
.from_hash(parsed) ⇒ Oxc::Diagnostic
: (Hash[String, untyped]) -> Oxc::Diagnostic.
Instance Method Summary collapse
-
#error? ⇒ Boolean
: () -> bool.
-
#initialize(severity:, message:, labels:, help: nil, codeframe: nil) ⇒ Diagnostic
constructor
: (severity: String, message: String, labels: Array, ?help: String?, ?codeframe: String?) -> void.
-
#inspect ⇒ String
: () -> String.
-
#to_s ⇒ String
: () -> String.
-
#warning? ⇒ Boolean
: () -> bool.
Constructor Details
#initialize(severity:, message:, labels:, help: nil, codeframe: nil) ⇒ Diagnostic
: (severity: String, message: String, labels: Array, ?help: String?, ?codeframe: String?) -> void
26 27 28 29 30 31 32 33 34 |
# File 'lib/oxc/diagnostic.rb', line 26 def initialize(severity:, message:, labels:, help: nil, codeframe: nil) @severity = severity @message = @labels = labels.freeze @help = help @codeframe = codeframe freeze end |
Instance Attribute Details
#codeframe ⇒ String? (readonly)
12 13 14 |
# File 'lib/oxc/diagnostic.rb', line 12 def codeframe @codeframe end |
#help ⇒ String? (readonly)
11 12 13 |
# File 'lib/oxc/diagnostic.rb', line 11 def help @help end |
#labels ⇒ Array[Oxc::Label] (readonly)
10 11 12 |
# File 'lib/oxc/diagnostic.rb', line 10 def labels @labels end |
#message ⇒ String (readonly)
9 10 11 |
# File 'lib/oxc/diagnostic.rb', line 9 def @message end |
#severity ⇒ String (readonly)
8 9 10 |
# File 'lib/oxc/diagnostic.rb', line 8 def severity @severity end |
Class Method Details
.from_hash(parsed) ⇒ Oxc::Diagnostic
: (Hash[String, untyped]) -> Oxc::Diagnostic
15 16 17 18 19 20 21 22 23 |
# File 'lib/oxc/diagnostic.rb', line 15 def self.from_hash(parsed) new( severity: parsed.fetch("severity"), message: parsed.fetch("message"), labels: parsed.fetch("labels").map { |label| Label.from_hash(label) }, help: parsed["help"], codeframe: parsed["codeframe"] ) end |
Instance Method Details
#error? ⇒ Boolean
: () -> bool
37 38 39 |
# File 'lib/oxc/diagnostic.rb', line 37 def error? severity == ERROR end |
#inspect ⇒ String
: () -> String
52 53 54 |
# File 'lib/oxc/diagnostic.rb', line 52 def inspect "#<#{self.class.name} #{severity} #{.inspect}>" end |
#to_s ⇒ String
: () -> String
47 48 49 |
# File 'lib/oxc/diagnostic.rb', line 47 def to_s end |
#warning? ⇒ Boolean
: () -> bool
42 43 44 |
# File 'lib/oxc/diagnostic.rb', line 42 def warning? severity == WARNING end |