Class: PlatformosCheck::LanguageServer::Configuration
- Inherits:
-
Object
- Object
- PlatformosCheck::LanguageServer::Configuration
- Defined in:
- lib/platformos_check/language_server/configuration.rb
Constant Summary collapse
- CHECK_ON_OPEN =
:'platformosCheck.checkOnOpen'
- CHECK_ON_SAVE =
:'platformosCheck.checkOnSave'
- CHECK_ON_CHANGE =
:'platformosCheck.checkOnChange'
- ONLY_SINGLE_FILE =
:'platformosCheck.onlySingleFileChecks'
Instance Method Summary collapse
- #check_on_change? ⇒ Boolean
- #check_on_open? ⇒ Boolean
- #check_on_save? ⇒ Boolean
- #fetch(force: nil) ⇒ Object
-
#initialize(bridge, capabilities) ⇒ Configuration
constructor
A new instance of Configuration.
- #initialized? ⇒ Boolean
- #null_coalesce(value, default) ⇒ Object
- #only_single_file? ⇒ Boolean
- #register_did_change_capability ⇒ Object
Constructor Details
#initialize(bridge, capabilities) ⇒ Configuration
Returns a new instance of Configuration.
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/platformos_check/language_server/configuration.rb', line 11 def initialize(bridge, capabilities) @bridge = bridge @capabilities = capabilities @mutex = Mutex.new @initialized = false @config = { CHECK_ON_OPEN => null_coalesce(@capabilities.initialization_option(CHECK_ON_OPEN), true), CHECK_ON_SAVE => null_coalesce(@capabilities.initialization_option(CHECK_ON_SAVE), true), CHECK_ON_CHANGE => null_coalesce(@capabilities.initialization_option(CHECK_ON_CHANGE), true), ONLY_SINGLE_FILE => null_coalesce(@capabilities.initialization_option(ONLY_SINGLE_FILE), true) } end |
Instance Method Details
#check_on_change? ⇒ Boolean
74 75 76 77 |
# File 'lib/platformos_check/language_server/configuration.rb', line 74 def check_on_change? fetch # making sure we have for an initialized value @config[CHECK_ON_CHANGE] end |
#check_on_open? ⇒ Boolean
64 65 66 67 |
# File 'lib/platformos_check/language_server/configuration.rb', line 64 def check_on_open? fetch # making sure we have an initialized value @config[CHECK_ON_OPEN] end |
#check_on_save? ⇒ Boolean
69 70 71 72 |
# File 'lib/platformos_check/language_server/configuration.rb', line 69 def check_on_save? fetch # making sure we have for an initialized value @config[CHECK_ON_SAVE] end |
#fetch(force: nil) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/platformos_check/language_server/configuration.rb', line 24 def fetch(force: nil) @mutex.synchronize do return unless @capabilities.supports_workspace_configuration? return if initialized? && !force keys = [ CHECK_ON_OPEN, CHECK_ON_SAVE, CHECK_ON_CHANGE, ONLY_SINGLE_FILE ] configs = @bridge.send_request( "workspace/configuration", items: keys.map do |key| { section: key } end ) keys.each.with_index do |key, i| @config[key] = configs[i] unless configs[i].nil? end @initialized = true end end |
#initialized? ⇒ Boolean
60 61 62 |
# File 'lib/platformos_check/language_server/configuration.rb', line 60 def initialized? @initialized end |
#null_coalesce(value, default) ⇒ Object
84 85 86 |
# File 'lib/platformos_check/language_server/configuration.rb', line 84 def null_coalesce(value, default) value.nil? ? default : value end |
#only_single_file? ⇒ Boolean
79 80 81 82 |
# File 'lib/platformos_check/language_server/configuration.rb', line 79 def only_single_file? fetch # making sure we have for an initialized value @config[ONLY_SINGLE_FILE] end |
#register_did_change_capability ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/platformos_check/language_server/configuration.rb', line 51 def register_did_change_capability return unless @capabilities.supports_workspace_did_change_configuration_dynamic_registration? @bridge.send_request('client/registerCapability', registrations: [{ id: "workspace/didChangeConfiguration", method: "workspace/didChangeConfiguration" }]) end |