Class: ThemeCheck::LanguageServer::Handler

Inherits:
Object
  • Object
show all
Defined in:
lib/theme_check/language_server/handler.rb

Constant Summary collapse

CAPABILITIES =
{
  textDocumentSync: {
    openClose: true,
    change: false,
    willSave: false,
    save: true,
  },
}

Instance Method Summary collapse

Constructor Details

#initialize(server) ⇒ Handler

Returns a new instance of Handler.



15
16
17
18
# File 'lib/theme_check/language_server/handler.rb', line 15

def initialize(server)
  @server = server
  @previously_reported_files = Set.new
end

Instance Method Details

#on_exit(_id, _params) ⇒ Object



31
32
33
# File 'lib/theme_check/language_server/handler.rb', line 31

def on_exit(_id, _params)
  close!
end

#on_initialize(id, params) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/theme_check/language_server/handler.rb', line 20

def on_initialize(id, params)
  @root_path = params["rootPath"]
  # https://microsoft.github.io/language-server-protocol/specifications/specification-current/#responseMessage
  send_response(
    id: id,
    result: {
      capabilities: CAPABILITIES,
    }
  )
end

#on_text_document_did_open(_id, params) ⇒ Object Also known as: on_text_document_did_save



35
36
37
# File 'lib/theme_check/language_server/handler.rb', line 35

def on_text_document_did_open(_id, params)
  analyze_and_send_offenses(params.dig('textDocument', 'uri').sub('file://', ''))
end