Class: PuppetLanguageServer::DisabledMessageHandler

Inherits:
PuppetEditorServices::Handler::JsonRPC show all
Defined in:
lib/puppet-languageserver/message_handler.rb

Instance Attribute Summary

Attributes inherited from PuppetEditorServices::Handler::Base

#protocol

Instance Method Summary collapse

Methods inherited from PuppetEditorServices::Handler::JsonRPC

#handle, #unhandled_exception

Methods inherited from PuppetEditorServices::Handler::Base

#handle, #initialize

Constructor Details

This class inherits a constructor from PuppetEditorServices::Handler::Base

Instance Method Details

#notification_exit(_, _json_rpc_message) ⇒ Object



457
458
459
460
# File 'lib/puppet-languageserver/message_handler.rb', line 457

def notification_exit(_, _json_rpc_message)
  PuppetLanguageServer.log_message(:info, 'Received exit notification.  Closing connection to client...')
  protocol.close_connection
end

#notification_initialized(_, _json_rpc_message) ⇒ Object



445
446
447
448
449
450
451
452
453
454
455
# File 'lib/puppet-languageserver/message_handler.rb', line 445

def notification_initialized(_, _json_rpc_message)
  PuppetLanguageServer.log_message(:info, 'Client has received initialization')

  protocol.encode_and_send(
    ::PuppetEditorServices::Protocol::JsonRPCMessages.new_notification(
      'window/showMessage',
      'type' => LSP::MessageType::WARNING,
      'message' => 'An error occured while starting the Language Server. The server has been disabled.'
    )
  )
end

#request_initialize(_, _json_rpc_message) ⇒ Object



420
421
422
423
424
# File 'lib/puppet-languageserver/message_handler.rb', line 420

def request_initialize(_, _json_rpc_message)
  PuppetLanguageServer.log_message(:debug, 'Received initialize method')
  # If the Language Server is not active then we can not respond to any capability
  { 'capabilities' => PuppetLanguageServer::ServerCapabilites.no_capabilities }
end

#request_puppet_getversion(_, _json_rpc_message) ⇒ Object



431
432
433
434
435
436
437
438
439
440
441
442
443
# File 'lib/puppet-languageserver/message_handler.rb', line 431

def request_puppet_getversion(_, _json_rpc_message)
  # Clients may use the getVersion request to figure out when the server has "finished" loading. In this
  # case just fake the response that we are fully loaded with unknown gem versions
  LSP::PuppetVersion.new(
    'languageServerVersion' => PuppetEditorServices.version,
    'puppetVersion' => 'Unknown',
    'facterVersion' => 'Unknown',
    'factsLoaded' => true,
    'functionsLoaded' => true,
    'typesLoaded' => true,
    'classesLoaded' => true
  )
end

#request_shutdown(_, _json_rpc_message) ⇒ Object



426
427
428
429
# File 'lib/puppet-languageserver/message_handler.rb', line 426

def request_shutdown(_, _json_rpc_message)
  PuppetLanguageServer.log_message(:debug, 'Received shutdown method')
  nil
end