Class: DSP::CompletionItem

Inherits:
DSPBase
  • Object
show all
Defined in:
lib/dsp/dsp_protocol.rb

Overview

interface CompletionItem {

    /** The label of this completion item. By default this is also the text that is inserted when selecting this completion. */
    label: string;
    /** If text is not falsy then it is inserted instead of the label. */
    text?: string;
    /** A string that should be used when comparing this item with other items. When `falsy` the label is used. */
    sortText?: string;
    /** The item's type. Typically the client uses this information to render the item in the UI with an icon. */
    type?: CompletionItemType;
    /** This value determines the location (in the CompletionsRequest's 'text' attribute) where the completion text is added.
        If missing the text is added at the location specified by the CompletionsRequest's 'column' attribute.
    */
    start?: number;
    /** This value determines how many characters are overwritten by the completion text.
        If missing the value 0 is assumed which results in the completion text being inserted.
    */
    length?: number;
    /** Determines the start of the new selection after the text has been inserted (or replaced).
        The start position must in the range 0 and length of the completion text.
        If omitted the selection starts at the end of the completion text.
    */
    selectionStart?: number;
    /** Determines the length of the new selection after the text has been inserted (or replaced).
        The selection can not extend beyond the bounds of the completion text.
        If omitted the length is assumed to be 0.
    */
    selectionLength?: number;
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from DSPBase

#to_h, #to_json

Constructor Details

#initialize(initial_hash = nil) ⇒ CompletionItem

Returns a new instance of CompletionItem.



4395
4396
4397
4398
# File 'lib/dsp/dsp_protocol.rb', line 4395

def initialize(initial_hash = nil)
  super
  @optional_method_names = %i[text sortText type start length selectionStart selectionLength]
end

Instance Attribute Details

#labelObject

type: string # type: string # type: string # type: CompletionItemType # type: number # type: number # type: number # type: number



4393
4394
4395
# File 'lib/dsp/dsp_protocol.rb', line 4393

def label
  @label
end

#lengthObject

type: string # type: string # type: string # type: CompletionItemType # type: number # type: number # type: number # type: number



4393
4394
4395
# File 'lib/dsp/dsp_protocol.rb', line 4393

def length
  @length
end

#selectionLengthObject

type: string # type: string # type: string # type: CompletionItemType # type: number # type: number # type: number # type: number



4393
4394
4395
# File 'lib/dsp/dsp_protocol.rb', line 4393

def selectionLength
  @selectionLength
end

#selectionStartObject

type: string # type: string # type: string # type: CompletionItemType # type: number # type: number # type: number # type: number



4393
4394
4395
# File 'lib/dsp/dsp_protocol.rb', line 4393

def selectionStart
  @selectionStart
end

#sortTextObject

type: string # type: string # type: string # type: CompletionItemType # type: number # type: number # type: number # type: number



4393
4394
4395
# File 'lib/dsp/dsp_protocol.rb', line 4393

def sortText
  @sortText
end

#startObject

type: string # type: string # type: string # type: CompletionItemType # type: number # type: number # type: number # type: number



4393
4394
4395
# File 'lib/dsp/dsp_protocol.rb', line 4393

def start
  @start
end

#textObject

type: string # type: string # type: string # type: CompletionItemType # type: number # type: number # type: number # type: number



4393
4394
4395
# File 'lib/dsp/dsp_protocol.rb', line 4393

def text
  @text
end

#typeObject

type: string # type: string # type: string # type: CompletionItemType # type: number # type: number # type: number # type: number



4393
4394
4395
# File 'lib/dsp/dsp_protocol.rb', line 4393

def type
  @type
end

Instance Method Details

#from_h!(value) ⇒ Object



4400
4401
4402
4403
4404
4405
4406
4407
4408
4409
4410
4411
# File 'lib/dsp/dsp_protocol.rb', line 4400

def from_h!(value)
  value = {} if value.nil?
  self.label = value['label']
  self.text = value['text']
  self.sortText = value['sortText']
  self.type = value['type'] # Unknown type
  self.start = value['start']
  self.length = value['length']
  self.selectionStart = value['selectionStart']
  self.selectionLength = value['selectionLength']
  self
end