Class: LanguageServer::Protocol::Interface::DocumentOnTypeFormattingRegistrationOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/language_server/protocol/interface/document_on_type_formatting_registration_options.rb,
sig/language_server/protocol/interface/document_on_type_formatting_registration_options.rbs

Overview

Registration options for a DocumentOnTypeFormattingRequest.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(document_selector:, first_trigger_character:, more_trigger_character: nil) ⇒ DocumentOnTypeFormattingRegistrationOptions

Returns a new instance of DocumentOnTypeFormattingRegistrationOptions.

Parameters:

  • document_selector: (Object)
  • first_trigger_character: (String)
  • more_trigger_character: (Array[String]) (defaults to: nil)


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

def initialize(document_selector:, first_trigger_character:, more_trigger_character: nil)
  @attributes = {}

  @attributes[:documentSelector] = document_selector
  @attributes[:firstTriggerCharacter] = first_trigger_character
  @attributes[:moreTriggerCharacter] = more_trigger_character if more_trigger_character

  @attributes.freeze
end

Instance Attribute Details

#attributesHash[Symbol, untyped] (readonly)

Returns the value of attribute attributes.

Returns:

  • (Hash[Symbol, untyped])


43
44
45
# File 'lib/language_server/protocol/interface/document_on_type_formatting_registration_options.rb', line 43

def attributes
  @attributes
end

Instance Method Details

#document_selectorDocumentSelector | nil

A document selector to identify the scope of the registration. If set to null the document selector provided on the client side will be used.

Returns:

  • (DocumentSelector | nil)


23
24
25
# File 'lib/language_server/protocol/interface/document_on_type_formatting_registration_options.rb', line 23

def document_selector
  attributes.fetch(:documentSelector)
end

#first_trigger_characterstring

A character on which formatting should be triggered, like {.

Returns:

  • (string)


31
32
33
# File 'lib/language_server/protocol/interface/document_on_type_formatting_registration_options.rb', line 31

def first_trigger_character
  attributes.fetch(:firstTriggerCharacter)
end

#more_trigger_characterstring[]

More trigger characters.

Returns:

  • (string[])


39
40
41
# File 'lib/language_server/protocol/interface/document_on_type_formatting_registration_options.rb', line 39

def more_trigger_character
  attributes.fetch(:moreTriggerCharacter)
end

#to_hashHash[Symbol, untyped]

Returns:

  • (Hash[Symbol, untyped])


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

def to_hash
  attributes
end

#to_json(*args) ⇒ String

Parameters:

  • (Object)

Returns:

  • (String)


49
50
51
# File 'lib/language_server/protocol/interface/document_on_type_formatting_registration_options.rb', line 49

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