Class: Steep::Expectations::Diagnostic
- Defined in:
- lib/steep/expectations.rb
Constant Summary collapse
- DiagnosticSeverity =
LanguageServer::Protocol::Constant::DiagnosticSeverity
Instance Attribute Summary collapse
-
#code ⇒ Object
Returns the value of attribute code.
-
#end_position ⇒ Object
Returns the value of attribute end_position.
-
#message ⇒ Object
Returns the value of attribute message.
-
#severity ⇒ Object
Returns the value of attribute severity.
-
#start_position ⇒ Object
Returns the value of attribute start_position.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code
3 4 5 |
# File 'lib/steep/expectations.rb', line 3 def code @code end |
#end_position ⇒ Object
Returns the value of attribute end_position
3 4 5 |
# File 'lib/steep/expectations.rb', line 3 def end_position @end_position end |
#message ⇒ Object
Returns the value of attribute message
3 4 5 |
# File 'lib/steep/expectations.rb', line 3 def @message end |
#severity ⇒ Object
Returns the value of attribute severity
3 4 5 |
# File 'lib/steep/expectations.rb', line 3 def severity @severity end |
#start_position ⇒ Object
Returns the value of attribute start_position
3 4 5 |
# File 'lib/steep/expectations.rb', line 3 def start_position @start_position end |
Class Method Details
.from_hash(hash) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/steep/expectations.rb', line 6 def self.from_hash(hash) start_position = { line: hash.dig("range", "start", "line") - 1, character: hash.dig("range", "start", "character") } #: position end_position = { line: hash.dig("range", "end", "line") - 1, character: hash.dig("range", "end", "character") } #: position severity = case hash["severity"] || "ERROR" when "ERROR" :error when "WARNING" :warning when "INFORMATION" :information when "HINT" :hint end #: Steep::Diagnostic::LSPFormatter::severity Diagnostic.new( start_position: start_position, end_position: end_position, severity: severity, message: hash["message"], code: hash["code"] ) end |
.from_lsp(diagnostic) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/steep/expectations.rb', line 37 def self.from_lsp(diagnostic) start_position = { line: diagnostic.dig(:range, :start, :line), character: diagnostic.dig(:range, :start, :character) } #: position end_position = { line: diagnostic.dig(:range, :end, :line), character: diagnostic.dig(:range, :end, :character) } #: position severity = case diagnostic[:severity] when DiagnosticSeverity::ERROR :error when DiagnosticSeverity::WARNING :warning when DiagnosticSeverity::INFORMATION :information when DiagnosticSeverity::HINT :hint else :error end #: Steep::Diagnostic::LSPFormatter::severity Diagnostic.new( start_position: start_position, end_position: end_position, severity: severity, message: diagnostic[:message], code: diagnostic[:code] ) end |
Instance Method Details
#lsp_severity ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/steep/expectations.rb', line 88 def lsp_severity case severity when :error DiagnosticSeverity::ERROR when :warning DiagnosticSeverity::WARNING when :information DiagnosticSeverity::INFORMATION when :hint DiagnosticSeverity::HINT else raise end end |
#sort_key ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/steep/expectations.rb', line 121 def sort_key [ start_position[:line], start_position[:character], end_position[:line], end_position[:character], code, severity, ] end |
#to_hash ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/steep/expectations.rb', line 70 def to_hash { "range" => { "start" => { "line" => start_position[:line] + 1, "character" => start_position[:character] }, "end" => { "line" => end_position[:line] + 1, "character" => end_position[:character] } }, "severity" => severity.to_s.upcase, "message" => , "code" => code } end |
#to_lsp ⇒ Object
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/steep/expectations.rb', line 103 def to_lsp { range: { start: { line: start_position[:line], character: start_position[:character] }, end: { line: end_position[:line], character: end_position[:character] } }, severity: lsp_severity, message: , code: code } end |