Class: ThemeCheck::LanguageServer::Configuration
- Inherits:
-
Object
- Object
- ThemeCheck::LanguageServer::Configuration
- Defined in:
- lib/theme_check/language_server/configuration.rb
Constant Summary collapse
- CHECK_ON_OPEN =
:"themeCheck.checkOnOpen"
- CHECK_ON_SAVE =
:"themeCheck.checkOnSave"
- CHECK_ON_CHANGE =
:"themeCheck.checkOnChange"
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
- #register_did_change_capability ⇒ Object
Constructor Details
#initialize(bridge, capabilities) ⇒ Configuration
Returns a new instance of Configuration.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/theme_check/language_server/configuration.rb', line 10 def initialize(bridge, capabilities) @bridge = bridge @capabilities = capabilities @mutex = Mutex.new @initialized = false @config = { CHECK_ON_OPEN => @capabilities.initialization_option(CHECK_ON_OPEN) || true, CHECK_ON_SAVE => @capabilities.initialization_option(CHECK_ON_SAVE) || true, CHECK_ON_CHANGE => @capabilities.initialization_option(CHECK_ON_CHANGE) || true, } end |
Instance Method Details
#check_on_change? ⇒ Boolean
63 64 65 66 |
# File 'lib/theme_check/language_server/configuration.rb', line 63 def check_on_change? fetch # making sure we have for an initialized value @config[CHECK_ON_CHANGE] end |
#check_on_open? ⇒ Boolean
53 54 55 56 |
# File 'lib/theme_check/language_server/configuration.rb', line 53 def check_on_open? fetch # making sure we have an initialized value @config[CHECK_ON_OPEN] end |
#check_on_save? ⇒ Boolean
58 59 60 61 |
# File 'lib/theme_check/language_server/configuration.rb', line 58 def check_on_save? fetch # making sure we have for an initialized value @config[CHECK_ON_SAVE] end |
#fetch(force: nil) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/theme_check/language_server/configuration.rb', line 22 def fetch(force: nil) @mutex.synchronize do return unless @capabilities.supports_workspace_configuration? return if initialized? && !force check_on_open, check_on_save, check_on_change = @bridge.send_request( "workspace/configuration", items: [ { section: CHECK_ON_OPEN }, { section: CHECK_ON_SAVE }, { section: CHECK_ON_CHANGE }, ], ) @config[CHECK_ON_OPEN] = check_on_open unless check_on_open.nil? @config[CHECK_ON_CHANGE] = check_on_change unless check_on_change.nil? @config[CHECK_ON_SAVE] = check_on_save unless check_on_save.nil? @initialized = true end end |
#initialized? ⇒ Boolean
49 50 51 |
# File 'lib/theme_check/language_server/configuration.rb', line 49 def initialized? @initialized end |
#register_did_change_capability ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/theme_check/language_server/configuration.rb', line 41 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 |