Class: Holistic::LanguageServer::Lifecycle
- Inherits:
-
Object
- Object
- Holistic::LanguageServer::Lifecycle
- Defined in:
- lib/holistic/language_server/lifecycle.rb
Overview
Constant Summary collapse
- UnexpectedStateError =
::Class.new(::StandardError)
Instance Attribute Summary collapse
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Instance Method Summary collapse
- #accept?(method) ⇒ Boolean
-
#initialize ⇒ Lifecycle
constructor
A new instance of Lifecycle.
- #initialized! ⇒ Object
- #initialized? ⇒ Boolean
- #reject?(method) ⇒ Boolean
- #shutdown! ⇒ Object
- #waiting_initialized_event! ⇒ Object
Constructor Details
#initialize ⇒ Lifecycle
Returns a new instance of Lifecycle.
13 14 15 |
# File 'lib/holistic/language_server/lifecycle.rb', line 13 def initialize @state = :waiting_initialize_event end |
Instance Attribute Details
#state ⇒ Object (readonly)
Returns the value of attribute state.
11 12 13 |
# File 'lib/holistic/language_server/lifecycle.rb', line 11 def state @state end |
Instance Method Details
#accept?(method) ⇒ Boolean
45 46 47 48 49 50 51 52 53 |
# File 'lib/holistic/language_server/lifecycle.rb', line 45 def accept?(method) return true if method == "exit" return true if method == "initialize" && @state == :waiting_initialize_event return true if method == "initialized" && @state == :waiting_initialized_event return method != "initialize" && method != "initialized" if @state == :initialized false end |
#initialized! ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/holistic/language_server/lifecycle.rb', line 25 def initialized! if @state != :waiting_initialized_event raise UnexpectedStateError, "state must be :waiting_initialized_event, got: #{@state.inspect}" end @state = :initialized end |
#initialized? ⇒ Boolean
41 42 43 |
# File 'lib/holistic/language_server/lifecycle.rb', line 41 def initialized? @state == :initialized || @state == :shutdown end |
#reject?(method) ⇒ Boolean
55 56 57 |
# File 'lib/holistic/language_server/lifecycle.rb', line 55 def reject?(method) !accept?(method) end |
#shutdown! ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/holistic/language_server/lifecycle.rb', line 33 def shutdown! if @state != :initialized raise UnexpectedStateError, "state must be :initialized, got: #{@state.inspect}" end @state = :shutdown end |
#waiting_initialized_event! ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/holistic/language_server/lifecycle.rb', line 17 def waiting_initialized_event! if @state != :waiting_initialize_event raise UnexpectedStateError, "state must be :waiting_initialize_event, got: #{@state.inspect}" end @state = :waiting_initialized_event end |