Class: LSP::Diagnostic

Inherits:
LSPBase show all
Defined in:
lib/lsp/lsp_types.rb

Overview

export interface Diagnostic

/**
 * The range at which the message applies
 */
range: Range;
/**
 * The diagnostic's severity. Can be omitted. If omitted it is up to the
 * client to interpret diagnostics as error, warning, info or hint.
 */
severity?: DiagnosticSeverity;
/**
 * The diagnostic's code, which usually appear in the user interface.
 */
code?: number | string;
/**
 * A human-readable string describing the source of this
 * diagnostic, e.g. 'typescript' or 'super lint'. It usually
 * appears in the user interface.
 */
source?: string;
/**
 * The diagnostic's message. It usually appears in the user interface
 */
message: string;
/**
 * Additional metadata about the diagnostic.
 */
tags?: DiagnosticTag[];
/**
 * An array of related diagnostic information, e.g. when symbol-names within
 * a scope collide all definitions can be marked via this property.
 */
relatedInformation?: DiagnosticRelatedInformation[];

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from LSPBase

#to_h, #to_json

Constructor Details

#initialize(initial_hash = nil) ⇒ Diagnostic

Returns a new instance of Diagnostic.



307
308
309
310
# File 'lib/lsp/lsp_types.rb', line 307

def initialize(initial_hash = nil)
  super
  @optional_method_names = %i[severity code source tags relatedInformation]
end

Instance Attribute Details

#codeObject

type: Range # type: DiagnosticSeverity # type: number | string # type: string # type: string # type: DiagnosticTag[] # type: DiagnosticRelatedInformation[]



305
306
307
# File 'lib/lsp/lsp_types.rb', line 305

def code
  @code
end

#messageObject

type: Range # type: DiagnosticSeverity # type: number | string # type: string # type: string # type: DiagnosticTag[] # type: DiagnosticRelatedInformation[]



305
306
307
# File 'lib/lsp/lsp_types.rb', line 305

def message
  @message
end

#rangeObject

type: Range # type: DiagnosticSeverity # type: number | string # type: string # type: string # type: DiagnosticTag[] # type: DiagnosticRelatedInformation[]



305
306
307
# File 'lib/lsp/lsp_types.rb', line 305

def range
  @range
end

#relatedInformationObject

type: Range # type: DiagnosticSeverity # type: number | string # type: string # type: string # type: DiagnosticTag[] # type: DiagnosticRelatedInformation[]



305
306
307
# File 'lib/lsp/lsp_types.rb', line 305

def relatedInformation
  @relatedInformation
end

#severityObject

type: Range # type: DiagnosticSeverity # type: number | string # type: string # type: string # type: DiagnosticTag[] # type: DiagnosticRelatedInformation[]



305
306
307
# File 'lib/lsp/lsp_types.rb', line 305

def severity
  @severity
end

#sourceObject

type: Range # type: DiagnosticSeverity # type: number | string # type: string # type: string # type: DiagnosticTag[] # type: DiagnosticRelatedInformation[]



305
306
307
# File 'lib/lsp/lsp_types.rb', line 305

def source
  @source
end

#tagsObject

type: Range # type: DiagnosticSeverity # type: number | string # type: string # type: string # type: DiagnosticTag[] # type: DiagnosticRelatedInformation[]



305
306
307
# File 'lib/lsp/lsp_types.rb', line 305

def tags
  @tags
end

Instance Method Details

#from_h!(value) ⇒ Object



312
313
314
315
316
317
318
319
320
321
322
# File 'lib/lsp/lsp_types.rb', line 312

def from_h!(value)
  value = {} if value.nil?
  self.range = Range.new(value['range']) unless value['range'].nil?
  self.severity = value['severity'] # Unknown type
  self.code = value['code'] # Unknown type
  self.source = value['source']
  self.message = value['message']
  self.tags = value['tags'].map { |val| val } unless value['tags'].nil? # Unknown array type
  self.relatedInformation = to_typed_aray(value['relatedInformation'], DiagnosticRelatedInformation)
  self
end