Class: LanguageServer::Protocol::Interface::FormattingOptions
- Inherits:
-
Object
- Object
- LanguageServer::Protocol::Interface::FormattingOptions
- Defined in:
- lib/language_server/protocol/interface/formatting_options.rb
Overview
Value-object describing what options formatting should use.
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Instance Method Summary collapse
-
#initialize(tab_size:, insert_spaces:, trim_trailing_whitespace: nil, insert_final_newline: nil, trim_final_newlines: nil) ⇒ FormattingOptions
constructor
A new instance of FormattingOptions.
-
#insert_final_newline ⇒ boolean
Insert a newline character at the end of the file if one does not exist.
-
#insert_spaces ⇒ boolean
Prefer spaces over tabs.
-
#tab_size ⇒ number
Size of a tab in spaces.
- #to_hash ⇒ Object
- #to_json(*args) ⇒ Object
-
#trim_final_newlines ⇒ boolean
Trim all newlines after the final newline at the end of the file.
-
#trim_trailing_whitespace ⇒ boolean
Trim trailing whitespace on a line.
Constructor Details
#initialize(tab_size:, insert_spaces:, trim_trailing_whitespace: nil, insert_final_newline: nil, trim_final_newlines: nil) ⇒ FormattingOptions
Returns a new instance of FormattingOptions.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/language_server/protocol/interface/formatting_options.rb', line 8 def initialize(tab_size:, insert_spaces:, trim_trailing_whitespace: nil, insert_final_newline: nil, trim_final_newlines: nil) @attributes = {} @attributes[:tabSize] = tab_size @attributes[:insertSpaces] = insert_spaces @attributes[:trimTrailingWhitespace] = trim_trailing_whitespace if trim_trailing_whitespace @attributes[:insertFinalNewline] = insert_final_newline if insert_final_newline @attributes[:trimFinalNewlines] = trim_final_newlines if trim_final_newlines @attributes.freeze end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
60 61 62 |
# File 'lib/language_server/protocol/interface/formatting_options.rb', line 60 def attributes @attributes end |
Instance Method Details
#insert_final_newline ⇒ boolean
Insert a newline character at the end of the file if one does not exist.
48 49 50 |
# File 'lib/language_server/protocol/interface/formatting_options.rb', line 48 def insert_final_newline attributes.fetch(:insertFinalNewline) end |
#insert_spaces ⇒ boolean
Prefer spaces over tabs.
32 33 34 |
# File 'lib/language_server/protocol/interface/formatting_options.rb', line 32 def insert_spaces attributes.fetch(:insertSpaces) end |
#tab_size ⇒ number
Size of a tab in spaces.
24 25 26 |
# File 'lib/language_server/protocol/interface/formatting_options.rb', line 24 def tab_size attributes.fetch(:tabSize) end |
#to_hash ⇒ Object
62 63 64 |
# File 'lib/language_server/protocol/interface/formatting_options.rb', line 62 def to_hash attributes end |
#to_json(*args) ⇒ Object
66 67 68 |
# File 'lib/language_server/protocol/interface/formatting_options.rb', line 66 def to_json(*args) to_hash.to_json(*args) end |
#trim_final_newlines ⇒ boolean
Trim all newlines after the final newline at the end of the file.
56 57 58 |
# File 'lib/language_server/protocol/interface/formatting_options.rb', line 56 def trim_final_newlines attributes.fetch(:trimFinalNewlines) end |
#trim_trailing_whitespace ⇒ boolean
Trim trailing whitespace on a line.
40 41 42 |
# File 'lib/language_server/protocol/interface/formatting_options.rb', line 40 def trim_trailing_whitespace attributes.fetch(:trimTrailingWhitespace) end |