Class: LanguageServer::Protocol::Interface::CompletionList

Inherits:
Object
  • Object
show all
Defined in:
lib/language_server/protocol/interface/completion_list.rb

Overview

Represents a collection of [completion items](#CompletionItem) to be presented in the editor.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(is_incomplete:, item_defaults: nil, items:) ⇒ CompletionList

Returns a new instance of CompletionList.



9
10
11
12
13
14
15
16
17
# File 'lib/language_server/protocol/interface/completion_list.rb', line 9

def initialize(is_incomplete:, item_defaults: nil, items:)
  @attributes = {}

  @attributes[:isIncomplete] = is_incomplete
  @attributes[:itemDefaults] = item_defaults if item_defaults
  @attributes[:items] = items

  @attributes.freeze
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



58
59
60
# File 'lib/language_server/protocol/interface/completion_list.rb', line 58

def attributes
  @attributes
end

Instance Method Details

#is_incompleteboolean

This list it not complete. Further typing results in recomputing this list.

Recomputed lists have all their items replaced (not appended) in the incomplete completion sessions.

Returns:

  • (boolean)


26
27
28
# File 'lib/language_server/protocol/interface/completion_list.rb', line 26

def is_incomplete
  attributes.fetch(:isIncomplete)
end

#item_defaults{ commitCharacters:string[], editRange:Range | { insert:Range, replace:Range }, insertTextFormat:InsertTextFormat, insertTextMode:InsertTextMode, data:LSPAny } | nil

In many cases the items of an actual completion result share the same value for properties like commitCharacters or the range of a text edit. A completion list can therefore define item defaults which will be used if a completion item itself doesn’t specify the value.

If a completion list specifies a default value and a completion item also specifies a corresponding value the one from the item is used.

Servers are only allowed to return default values if the client signals support for this via the completionList.itemDefaults capability.

Returns:

  • ({ commitCharacters:string[], editRange:Range | { insert:Range, replace:Range }, insertTextFormat:InsertTextFormat, insertTextMode:InsertTextMode, data:LSPAny } | nil)

Since:

  • 3.17.0



46
47
48
# File 'lib/language_server/protocol/interface/completion_list.rb', line 46

def item_defaults
  attributes.fetch(:itemDefaults)
end

#itemsCompletionItem[]

The completion items.

Returns:



54
55
56
# File 'lib/language_server/protocol/interface/completion_list.rb', line 54

def items
  attributes.fetch(:items)
end

#to_hashObject



60
61
62
# File 'lib/language_server/protocol/interface/completion_list.rb', line 60

def to_hash
  attributes
end

#to_json(*args) ⇒ Object



64
65
66
# File 'lib/language_server/protocol/interface/completion_list.rb', line 64

def to_json(*args)
  to_hash.to_json(*args)
end