Class: Solargraph::LanguageServer::Message::Initialize

Inherits:
Base
  • Object
show all
Defined in:
lib/solargraph/language_server/message/initialize.rb

Instance Attribute Summary

Attributes inherited from Base

#error, #host, #id, #method, #params, #request, #result

Instance Method Summary collapse

Methods inherited from Base

#initialize, #post_initialize, #send_response, #set_error, #set_result

Constructor Details

This class inherits a constructor from Solargraph::LanguageServer::Message::Base

Instance Method Details

#processObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/solargraph/language_server/message/initialize.rb', line 9

def process
  bm = Benchmark.measure {
    host.configure params['initializationOptions']
    host.client_capabilities = params['capabilities']
    if support_workspace_folders?
      host.prepare_folders params['workspaceFolders']
    elsif params['rootUri']
      host.prepare UriHelpers.uri_to_file(params['rootUri'])
    else
      host.prepare params['rootPath']
    end
    result = {
      capabilities: {
        textDocumentSync: 2, # @todo What should this be?
        workspace: {
          workspaceFolders: {
            supported: true,
            changeNotifications: true
          }
        }
      }
    }
    result[:capabilities].merge! static_completion unless dynamic_registration_for?('textDocument', 'completion')
    result[:capabilities].merge! static_signature_help unless dynamic_registration_for?('textDocument', 'signatureHelp')
    # result[:capabilities].merge! static_on_type_formatting unless dynamic_registration_for?('textDocument', 'onTypeFormatting')
    result[:capabilities].merge! static_hover unless dynamic_registration_for?('textDocument', 'hover')
    result[:capabilities].merge! static_document_formatting unless dynamic_registration_for?('textDocument', 'formatting')
    result[:capabilities].merge! static_document_symbols unless dynamic_registration_for?('textDocument', 'documentSymbol')
    result[:capabilities].merge! static_definitions unless dynamic_registration_for?('textDocument', 'definition')
    result[:capabilities].merge! static_rename unless dynamic_registration_for?('textDocument', 'rename')
    result[:capabilities].merge! static_references unless dynamic_registration_for?('textDocument', 'references')
    result[:capabilities].merge! static_workspace_symbols unless dynamic_registration_for?('workspace', 'symbol')
    result[:capabilities].merge! static_folding_range unless dynamic_registration_for?('textDocument', 'foldingRange')
    # @todo Temporarily disabled
    # result[:capabilities].merge! static_code_action unless dynamic_registration_for?('textDocument', 'codeAction')
    set_result result
  }
  Solargraph.logger.unknown "Solargraph initialized (#{bm.real} seconds)"
end