Class: PuppetLanguageServer::ClientSessionState
- Inherits:
-
Object
- Object
- PuppetLanguageServer::ClientSessionState
- Defined in:
- lib/puppet-languageserver/client_session_state.rb
Instance Attribute Summary collapse
-
#connection_id ⇒ Object
readonly
Returns the value of attribute connection_id.
-
#documents ⇒ Object
readonly
Returns the value of attribute documents.
-
#language_client ⇒ Object
readonly
Returns the value of attribute language_client.
-
#object_cache ⇒ Object
readonly
Returns the value of attribute object_cache.
Instance Method Summary collapse
-
#default_classes_loaded? ⇒ Boolean
Helper methods to know the state of the object cache.
- #default_datatypes_loaded? ⇒ Boolean
- #default_functions_loaded? ⇒ Boolean
- #default_types_loaded? ⇒ Boolean
- #facts_loaded? ⇒ Boolean
-
#initialize(message_handler, options = {}) ⇒ ClientSessionState
constructor
A new instance of ClientSessionState.
-
#load_default_data!(async = true) ⇒ Object
Loaders for object cache information.
- #load_static_data!(async = true) ⇒ Object
- #load_workspace_data!(async = true) ⇒ Object
- #purge_workspace_data! ⇒ Object
- #static_data_loaded? ⇒ Boolean
Constructor Details
#initialize(message_handler, options = {}) ⇒ ClientSessionState
Returns a new instance of ClientSessionState.
11 12 13 14 15 16 |
# File 'lib/puppet-languageserver/client_session_state.rb', line 11 def initialize(, = {}) @documents = [:documents].nil? ? PuppetLanguageServer::SessionState::DocumentStore.new : [:documents] @language_client = [:language_client].nil? ? PuppetLanguageServer::SessionState::LanguageClient.new() : [:language_client] @object_cache = [:object_cache].nil? ? PuppetLanguageServer::SessionState::ObjectCache.new : [:object_cache] @connection_id = [:connection_id].nil? ? .protocol.connection.id : [:connection_id] end |
Instance Attribute Details
#connection_id ⇒ Object (readonly)
Returns the value of attribute connection_id.
9 10 11 |
# File 'lib/puppet-languageserver/client_session_state.rb', line 9 def connection_id @connection_id end |
#documents ⇒ Object (readonly)
Returns the value of attribute documents.
9 10 11 |
# File 'lib/puppet-languageserver/client_session_state.rb', line 9 def documents @documents end |
#language_client ⇒ Object (readonly)
Returns the value of attribute language_client.
9 10 11 |
# File 'lib/puppet-languageserver/client_session_state.rb', line 9 def language_client @language_client end |
#object_cache ⇒ Object (readonly)
Returns the value of attribute object_cache.
9 10 11 |
# File 'lib/puppet-languageserver/client_session_state.rb', line 9 def object_cache @object_cache end |
Instance Method Details
#default_classes_loaded? ⇒ Boolean
Helper methods to know the state of the object cache
19 20 21 |
# File 'lib/puppet-languageserver/client_session_state.rb', line 19 def default_classes_loaded? object_cache.section_in_origin_exist?(:class, :default) end |
#default_datatypes_loaded? ⇒ Boolean
23 24 25 |
# File 'lib/puppet-languageserver/client_session_state.rb', line 23 def default_datatypes_loaded? object_cache.section_in_origin_exist?(:datatype, :default) end |
#default_functions_loaded? ⇒ Boolean
27 28 29 |
# File 'lib/puppet-languageserver/client_session_state.rb', line 27 def default_functions_loaded? object_cache.section_in_origin_exist?(:function, :default) end |
#default_types_loaded? ⇒ Boolean
31 32 33 |
# File 'lib/puppet-languageserver/client_session_state.rb', line 31 def default_types_loaded? object_cache.section_in_origin_exist?(:type, :default) end |
#facts_loaded? ⇒ Boolean
35 36 37 |
# File 'lib/puppet-languageserver/client_session_state.rb', line 35 def facts_loaded? object_cache.section_in_origin_exist?(:fact, :default) end |
#load_default_data!(async = true) ⇒ Object
Loaders for object cache information
44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/puppet-languageserver/client_session_state.rb', line 44 def load_default_data!(async = true) PuppetLanguageServer.(:info, "Loading Default Data via aggregate #{'(Async)' if async}...") if async sidecar_queue.enqueue('default_aggregate', [], false, connection_id) sidecar_queue.enqueue('facts', [], false, connection_id) else sidecar_queue.execute('default_aggregate', [], false, connection_id) sidecar_queue.execute('facts', [], false, connection_id) end true end |
#load_static_data!(async = true) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/puppet-languageserver/client_session_state.rb', line 57 def load_static_data!(async = true) if async Thread.new do PuppetLanguageServer.(:info, 'Loading static data (Async)...') load_static_data_impl end else PuppetLanguageServer.(:info, 'Loading static data...') load_static_data_impl end true end |
#load_workspace_data!(async = true) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/puppet-languageserver/client_session_state.rb', line 71 def load_workspace_data!(async = true) return true if documents.store_root_path.nil? action_args = ['--local-workspace', documents.store_root_path] PuppetLanguageServer.(:info, "Loading Workspace Data via aggregate #{'(Async)' if async}...") if async sidecar_queue.enqueue('workspace_aggregate', action_args, false, connection_id) else sidecar_queue.execute('workspace_aggregate', action_args, false, connection_id) end true end |
#purge_workspace_data! ⇒ Object
85 86 87 |
# File 'lib/puppet-languageserver/client_session_state.rb', line 85 def purge_workspace_data! object_cache.remove_origin!(:workspace) end |
#static_data_loaded? ⇒ Boolean
39 40 41 |
# File 'lib/puppet-languageserver/client_session_state.rb', line 39 def static_data_loaded? object_cache.origin_exist?(:bolt) end |