Class: PlatformosCheck::LanguageServer::Diagnostic
- Inherits:
-
Object
- Object
- PlatformosCheck::LanguageServer::Diagnostic
- Includes:
- URIHelper
- Defined in:
- lib/platformos_check/language_server/diagnostic.rb
Instance Attribute Summary collapse
-
#offense ⇒ Object
readonly
Returns the value of attribute offense.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #absolute_path ⇒ Object
- #code ⇒ Object
- #code_description ⇒ Object
- #correctable? ⇒ Boolean
- #data ⇒ Object
- #end_index ⇒ Object
- #file_version ⇒ Object
-
#initialize(offense) ⇒ Diagnostic
constructor
A new instance of Diagnostic.
- #message ⇒ Object
- #range ⇒ Object
- #relative_path ⇒ Object
- #severity ⇒ Object
- #single_file? ⇒ Boolean
- #start_index ⇒ Object
- #to_h ⇒ Object
- #to_s ⇒ Object
- #uri ⇒ Object
- #whole_platformos_app? ⇒ Boolean
Methods included from URIHelper
Constructor Details
#initialize(offense) ⇒ Diagnostic
Returns a new instance of Diagnostic.
10 11 12 13 |
# File 'lib/platformos_check/language_server/diagnostic.rb', line 10 def initialize(offense) @offense = offense @diagnostic = nil end |
Instance Attribute Details
#offense ⇒ Object (readonly)
Returns the value of attribute offense.
8 9 10 |
# File 'lib/platformos_check/language_server/diagnostic.rb', line 8 def offense @offense end |
Instance Method Details
#==(other) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/platformos_check/language_server/diagnostic.rb', line 15 def ==(other) case other when Hash, Diagnostic to_h == other.to_h else raise ArgumentError end end |
#absolute_path ⇒ Object
103 104 105 |
# File 'lib/platformos_check/language_server/diagnostic.rb', line 103 def absolute_path @absolute_path ||= offense&.app_file&.path end |
#code ⇒ Object
55 56 57 |
# File 'lib/platformos_check/language_server/diagnostic.rb', line 55 def code offense.code_name end |
#code_description ⇒ Object
63 64 65 66 67 |
# File 'lib/platformos_check/language_server/diagnostic.rb', line 63 def code_description { href: offense.doc } end |
#correctable? ⇒ Boolean
51 52 53 |
# File 'lib/platformos_check/language_server/diagnostic.rb', line 51 def correctable? offense.correctable? end |
#data ⇒ Object
119 120 121 122 123 124 125 126 |
# File 'lib/platformos_check/language_server/diagnostic.rb', line 119 def data { absolute_path: absolute_path.to_s, relative_path: relative_path.to_s, uri:, version: file_version } end |
#end_index ⇒ Object
99 100 101 |
# File 'lib/platformos_check/language_server/diagnostic.rb', line 99 def end_index offense.end_index end |
#file_version ⇒ Object
115 116 117 |
# File 'lib/platformos_check/language_server/diagnostic.rb', line 115 def file_version @version ||= offense&.version end |
#message ⇒ Object
59 60 61 |
# File 'lib/platformos_check/language_server/diagnostic.rb', line 59 def offense. end |
#range ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/platformos_check/language_server/diagnostic.rb', line 82 def range { start: { line: offense.start_row, character: offense.start_column }, end: { line: offense.end_row, character: offense.end_column } } end |
#relative_path ⇒ Object
107 108 109 |
# File 'lib/platformos_check/language_server/diagnostic.rb', line 107 def relative_path @relative_path ||= offense&.app_file&.relative_path end |
#severity ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/platformos_check/language_server/diagnostic.rb', line 69 def severity case offense.severity when :error 1 when :suggestion 2 when :style 3 else 4 end end |
#single_file? ⇒ Boolean
43 44 45 |
# File 'lib/platformos_check/language_server/diagnostic.rb', line 43 def single_file? offense.single_file? end |
#start_index ⇒ Object
95 96 97 |
# File 'lib/platformos_check/language_server/diagnostic.rb', line 95 def start_index offense.start_index end |
#to_h ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/platformos_check/language_server/diagnostic.rb', line 24 def to_h return @diagnostic unless @diagnostic.nil? @diagnostic = { source: "platformos-check", code:, message:, range:, severity:, data: } @diagnostic[:codeDescription] = code_description unless offense.doc.nil? @diagnostic end |
#to_s ⇒ Object
39 40 41 |
# File 'lib/platformos_check/language_server/diagnostic.rb', line 39 def to_s to_h.to_s end |
#uri ⇒ Object
111 112 113 |
# File 'lib/platformos_check/language_server/diagnostic.rb', line 111 def uri @uri ||= absolute_path && file_uri(absolute_path) end |
#whole_platformos_app? ⇒ Boolean
47 48 49 |
# File 'lib/platformos_check/language_server/diagnostic.rb', line 47 def whole_platformos_app? offense.whole_platformos_app? end |