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.



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

def attributes
  @attributes
end

Instance Method Details

#is_incompleteboolean

This list is not complete. Further typing should result in recomputing this list.

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

Returns:

  • (boolean)


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

def is_incomplete
  attributes.fetch(:isIncomplete)
end

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

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; })


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

def item_defaults
  attributes.fetch(:itemDefaults)
end

#itemsCompletionItem[]

The completion items.

Returns:



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

def items
  attributes.fetch(:items)
end

#to_hashObject



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

def to_hash
  attributes
end

#to_json(*args) ⇒ Object



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

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