Class: Solargraph::LanguageServer::Host

Inherits:
Object
  • Object
show all
Includes:
Observable, Dispatch, UriHelpers, Solargraph::Logging
Defined in:
lib/solargraph/language_server/host.rb,
lib/solargraph/language_server/host/sources.rb,
lib/solargraph/language_server/host/dispatch.rb,
lib/solargraph/language_server/host/cataloger.rb,
lib/solargraph/language_server/host/diagnoser.rb,
lib/solargraph/language_server/host/message_worker.rb

Overview

The language server protocol’s data provider. Hosts are responsible for querying the library and processing messages. They also provide thread safety for multi-threaded transports.

Defined Under Namespace

Modules: Dispatch Classes: Cataloger, Diagnoser, MessageWorker, Sources

Constant Summary

Constants included from Solargraph::Logging

Solargraph::Logging::DEFAULT_LOG_LEVEL, Solargraph::Logging::LOG_LEVELS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Dispatch

#explicit_library_for, #generic_library, #generic_library_for, #implicit_library_for, #libraries, #library_for, #sources, #update_libraries

Methods included from Solargraph::Logging

logger

Methods included from UriHelpers

decode, encode, file_to_uri, uri_to_file

Constructor Details

#initializeHost

Returns a new instance of Host.



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/solargraph/language_server/host.rb', line 27

def initialize
  @cancel_semaphore = Mutex.new
  @buffer_semaphore = Mutex.new
  @request_mutex = Mutex.new
  @cancel = []
  @buffer = String.new
  @stopped = true
  @next_request_id = 1
  @dynamic_capabilities = Set.new
  @registered_capabilities = Set.new
end

Instance Attribute Details

#client_capabilitiesHash{String => BasicObject}

Returns:

  • (Hash{String => BasicObject})


688
689
690
# File 'lib/solargraph/language_server/host.rb', line 688

def client_capabilities
  @client_capabilities ||= {}
end

Instance Method Details

#allow_registration(method) ⇒ void

This method returns an undefined value.

Flag a method as available for dynamic registration.

Parameters:

  • method (String)

    The method name, e.g., ‘textDocument/completion’



432
433
434
# File 'lib/solargraph/language_server/host.rb', line 432

def allow_registration method
  @dynamic_capabilities.add method
end

#can_register?(method) ⇒ Boolean

True if the specified LSP method can be dynamically registered.

Parameters:

  • method (String)

Returns:

  • (Boolean)


440
441
442
# File 'lib/solargraph/language_server/host.rb', line 440

def can_register? method
  @dynamic_capabilities.include?(method)
end

#cancel(id) ⇒ void

This method returns an undefined value.

Cancel the method with the specified ID.

Parameters:

  • id (Integer)


70
71
72
# File 'lib/solargraph/language_server/host.rb', line 70

def cancel id
  @cancel_semaphore.synchronize { @cancel.push id }
end

#cancel?(id) ⇒ Boolean

True if the host received a request to cancel the method with the specified ID.

Parameters:

  • id (Integer)

Returns:

  • (Boolean)


79
80
81
82
83
# File 'lib/solargraph/language_server/host.rb', line 79

def cancel? id
  result = false
  @cancel_semaphore.synchronize { result = @cancel.include? id }
  result
end

#catalogvoid

This method returns an undefined value.



682
683
684
685
# File 'lib/solargraph/language_server/host.rb', line 682

def catalog
  return unless libraries.all?(&:mapped?)
  libraries.each(&:catalog)
end

#change(params) ⇒ void

This method returns an undefined value.

Update a document from the parameters of a textDocument/didChange method.

Parameters:

  • params (Hash)


254
255
256
257
258
# File 'lib/solargraph/language_server/host.rb', line 254

def change params
  updater = generate_updater(params)
  sources.async_update params['textDocument']['uri'], updater
  diagnoser.schedule params['textDocument']['uri']
end

#clear(id) ⇒ void

This method returns an undefined value.

Delete the specified ID from the list of cancelled IDs if it exists.

Parameters:

  • id (Integer)


89
90
91
# File 'lib/solargraph/language_server/host.rb', line 89

def clear id
  @cancel_semaphore.synchronize { @cancel.delete id }
end

#close(uri) ⇒ void

This method returns an undefined value.

Close the file specified by the URI.

Parameters:

  • uri (String)


201
202
203
204
205
# File 'lib/solargraph/language_server/host.rb', line 201

def close uri
  logger.info "Closing #{uri}"
  sources.close uri
  diagnoser.schedule uri
end

#completions_at(uri, line, column) ⇒ Solargraph::SourceMap::Completion

Parameters:

  • uri (String)
  • line (Integer)
  • column (Integer)

Returns:



538
539
540
541
# File 'lib/solargraph/language_server/host.rb', line 538

def completions_at uri, line, column
  library = library_for(uri)
  library.completions_at uri_to_file(uri), line, column
end

#configure(update) ⇒ void

This method returns an undefined value.

Update the configuration options with the provided hash.

Parameters:

  • update (Hash)


55
56
57
58
59
# File 'lib/solargraph/language_server/host.rb', line 55

def configure update
  return if update.nil?
  options.merge! update
  logger.level = LOG_LEVELS[options['logLevel']] || DEFAULT_LOG_LEVEL
end

#create(*uris) ⇒ Boolean

Respond to a notification that files were created in the workspace. The libraries will determine whether the files should be merged; see Solargraph::Library#create_from_disk.

Parameters:

  • uris (Array<String>)

    The URIs of the files.

Returns:

  • (Boolean)

    True if at least one library accepted at least one file.



139
140
141
142
143
144
145
146
147
148
149
# File 'lib/solargraph/language_server/host.rb', line 139

def create *uris
  filenames = uris.map { |uri| uri_to_file(uri) }
  result = false
  libraries.each do |lib|
    result = true if lib.create_from_disk(*filenames)
  end
  uris.each do |uri|
    diagnoser.schedule uri if open?(uri)
  end
  result
end

#default_configurationHash{String => [Boolean,String]}

Returns:

  • (Hash{String => [Boolean,String]})


657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
# File 'lib/solargraph/language_server/host.rb', line 657

def default_configuration
  {
    'completion' => true,
    'hover' => true,
    'symbols' => true,
    'definitions' => true,
    'typeDefinitions' => true,
    'rename' => true,
    'references' => true,
    'autoformat' => false,
    'diagnostics' => true,
    'formatting' => false,
    'folding' => true,
    'highlights' => true,
    'logLevel' => 'warn'
  }
end

#definitions_at(uri, line, column) ⇒ Array<Solargraph::Pin::Base>

Parameters:

  • uri (String)
  • line (Integer)
  • column (Integer)

Returns:



552
553
554
555
# File 'lib/solargraph/language_server/host.rb', line 552

def definitions_at uri, line, column
  library = library_for(uri)
  library.definitions_at(uri_to_file(uri), line, column)
end

#delete(*uris) ⇒ void

This method returns an undefined value.

Delete the specified files from the library.

Parameters:

  • uris (Array<String>)

    The file uris.



155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/solargraph/language_server/host.rb', line 155

def delete *uris
  filenames = uris.map { |uri| uri_to_file(uri) }
  libraries.each do |lib|
    lib.delete(*filenames)
  end
  uris.each do |uri|
    send_notification "textDocument/publishDiagnostics", {
      uri: uri,
      diagnostics: []
    }
  end
end

#diagnose(uri) ⇒ void

This method returns an undefined value.

Parameters:

  • uri (String)


209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# File 'lib/solargraph/language_server/host.rb', line 209

def diagnose uri
  if sources.include?(uri)
    library = library_for(uri)
    if library.mapped? && library.synchronized?
      logger.info "Diagnosing #{uri}"
      begin
        results = library.diagnose uri_to_file(uri)
        send_notification "textDocument/publishDiagnostics", {
          uri: uri,
          diagnostics: results
        }
      rescue DiagnosticsError => e
        logger.warn "Error in diagnostics: #{e.message}"
        options['diagnostics'] = false
        send_notification 'window/showMessage', {
          type: LanguageServer::MessageTypes::ERROR,
          message: "Error in diagnostics: #{e.message}"
        }
      rescue FileNotFoundError => e
        # @todo This appears to happen when an external file is open and
        #   scheduled for diagnosis, but the file was closed (i.e., the
        #   editor moved to a different file) before diagnosis started
        logger.warn "Unable to diagnose #{uri} : #{e.message}"
        send_notification 'textDocument/publishDiagnostics', {
          uri: uri,
          diagnostics: []
        }
      end
    else
      logger.info "Deferring diagnosis of #{uri}"
      diagnoser.schedule uri
    end
  else
    send_notification 'textDocument/publishDiagnostics', {
      uri: uri,
      diagnostics: []
    }
  end
end

#document(query) ⇒ Array

Parameters:

  • query (String)

Returns:

  • (Array)


604
605
606
607
608
# File 'lib/solargraph/language_server/host.rb', line 604

def document query
  result = []
  libraries.each { |lib| result.concat lib.document(query) }
  result
end

#document_symbols(uri) ⇒ Array<Solargraph::Pin::Base>

Parameters:

  • uri (String)

Returns:



612
613
614
615
616
617
618
# File 'lib/solargraph/language_server/host.rb', line 612

def document_symbols uri
  library = library_for(uri)
  # At this level, document symbols should be unique; e.g., a
  # module_function method should return the location for Module.method
  # or Module#method, but not both.
  library.document_symbols(uri_to_file(uri)).uniq(&:location)
end

#flushString

Clear the message buffer and return the most recent data.

Returns:

  • (String)

    The most recent data or an empty string.



273
274
275
276
277
278
279
280
# File 'lib/solargraph/language_server/host.rb', line 273

def flush
  tmp = ''
  @buffer_semaphore.synchronize do
    tmp = @buffer.clone
    @buffer.clear
  end
  tmp
end

#foldersArray<String>

Returns:

  • (Array<String>)


340
341
342
# File 'lib/solargraph/language_server/host.rb', line 340

def folders
  libraries.map { |lib| lib.workspace.directory }
end

#folding_ranges(uri) ⇒ Array<Range>

Parameters:

  • uri (String)

Returns:



677
678
679
# File 'lib/solargraph/language_server/host.rb', line 677

def folding_ranges uri
  sources.find(uri).folding_ranges
end

#formatter_config(uri) ⇒ Hash

Parameters:

  • uri (String)

Returns:

  • (Hash)


529
530
531
532
# File 'lib/solargraph/language_server/host.rb', line 529

def formatter_config uri
  library = library_for(uri)
  library.workspace.config.formatter
end

#has_pending_completions?Bool

Returns if has pending completion request.

Returns:

  • (Bool)

    if has pending completion request



544
545
546
# File 'lib/solargraph/language_server/host.rb', line 544

def has_pending_completions?
  message_worker.messages.reverse_each.any? { |req| req['method'] == 'textDocument/completion' }
end

#locate_pins(params) ⇒ Array<Pin::Base>

Locate multiple pins that match a completion item. The first match is based on the corresponding location in a library source if available. Subsequent matches are based on path.

Parameters:

  • params (Hash)

    A hash representation of a completion item

Returns:



478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
# File 'lib/solargraph/language_server/host.rb', line 478

def locate_pins params
  return [] unless params['data'] && params['data']['uri']
  library = library_for(params['data']['uri'])
  result = []
  if params['data']['location']
    location = Location.new(
      params['data']['location']['filename'],
      Range.from_to(
        params['data']['location']['range']['start']['line'],
        params['data']['location']['range']['start']['character'],
        params['data']['location']['range']['end']['line'],
        params['data']['location']['range']['end']['character']
      )
    )
    result.concat library.locate_pins(location).select{ |pin| pin.name == params['label'] }
  end
  if params['data']['path']
    result.concat library.path_pins(params['data']['path'])
    # @todo This exception is necessary because `Library#path_pins` does
    #   not perform a namespace method query, so the implicit `.new` pin
    #   might not exist.
    if result.empty? && params['data']['path'] =~ /\.new$/
      result.concat(library.path_pins(params['data']['path'].sub(/\.new$/, '#initialize')).map do |pin|
        next pin unless pin.name == 'initialize'

        Pin::Method.new(
          name: 'new',
          scope: :class,
          location: pin.location,
          parameters: pin.parameters,
          return_type: ComplexType.try_parse(params['data']['path']),
          comments: pin.comments,
          closure: pin.closure
        )
      end)
    end
  end
  # Selecting by both location and path can result in duplicate pins
  result.uniq { |p| [p.path, p.location] }
end

#open(uri, text, version) ⇒ void

This method returns an undefined value.

Open the specified file in the library.

Parameters:

  • uri (String)

    The file uri.

  • text (String)

    The contents of the file.

  • version (Integer)

    A version number.



174
175
176
177
178
179
180
# File 'lib/solargraph/language_server/host.rb', line 174

def open uri, text, version
  src = sources.open(uri, text, version)
  libraries.each do |lib|
    lib.merge src
  end
  diagnoser.schedule uri
end

#open?(uri) ⇒ Boolean

True if the specified file is currently open in the library.

Parameters:

  • uri (String)

Returns:

  • (Boolean)


193
194
195
# File 'lib/solargraph/language_server/host.rb', line 193

def open? uri
  sources.include? uri
end

#open_from_disk(uri) ⇒ void

This method returns an undefined value.

Parameters:

  • uri (String)


184
185
186
187
# File 'lib/solargraph/language_server/host.rb', line 184

def open_from_disk uri
  sources.open_from_disk(uri)
  diagnoser.schedule uri
end

#optionsHash{String => [Boolean, String]}

Returns:

  • (Hash{String => [Boolean, String]})


62
63
64
# File 'lib/solargraph/language_server/host.rb', line 62

def options
  @options ||= default_configuration
end

#pending_requestsArray<Integer>

Get a list of IDs for server requests that are waiting for responses from the client.

Returns:

  • (Array<Integer>)


652
653
654
# File 'lib/solargraph/language_server/host.rb', line 652

def pending_requests
  requests.keys
end

#prepare(directory, name = nil) ⇒ void

This method returns an undefined value.

Prepare a library for the specified directory.

Parameters:

  • directory (String)
  • name (String, nil) (defaults to: nil)


287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
# File 'lib/solargraph/language_server/host.rb', line 287

def prepare directory, name = nil
  # No need to create a library without a directory. The generic library
  # will handle it.
  return if directory.nil?
  logger.info "Preparing library for #{directory}"
  path = ''
  path = normalize_separators(directory) unless directory.nil?
  begin
    workspace = Solargraph::Workspace.new(path, nil, options)
    lib = Solargraph::Library.new(workspace, name)
    libraries.push lib
    async_library_map lib
  rescue WorkspaceTooLargeError => e
    send_notification 'window/showMessage', {
      'type' => Solargraph::LanguageServer::MessageTypes::WARNING,
      'message' => e.message
    }
  end
end

#prepare_folders(array) ⇒ void

This method returns an undefined value.

Prepare multiple folders.

Parameters:

  • array (Array<Hash{String => String}>)


311
312
313
314
315
316
# File 'lib/solargraph/language_server/host.rb', line 311

def prepare_folders array
  return if array.nil?
  array.each do |folder|
    prepare uri_to_file(folder['uri']), folder['name']
  end
end

#process(request) ⇒ void

This method returns an undefined value.

Called by adapter, to handle the request

Parameters:

  • request (Hash)


96
97
98
# File 'lib/solargraph/language_server/host.rb', line 96

def process request
  message_worker.queue(request)
end

#query_symbols(query) ⇒ Array<Solargraph::Pin::Base>

Parameters:

  • query (String)

Returns:



588
589
590
591
592
# File 'lib/solargraph/language_server/host.rb', line 588

def query_symbols query
  result = []
  (libraries + [generic_library]).each { |lib| result.concat lib.query_symbols(query) }
  result.uniq
end

#queue(message) ⇒ void

This method returns an undefined value.

Queue a message to be sent to the client.

Parameters:

  • message (String)

    The message to send.



264
265
266
267
268
# File 'lib/solargraph/language_server/host.rb', line 264

def queue message
  @buffer_semaphore.synchronize { @buffer += message }
  changed
  notify_observers
end

#read_text(uri) ⇒ String

Parameters:

  • uri (String)

Returns:

  • (String)


521
522
523
524
525
# File 'lib/solargraph/language_server/host.rb', line 521

def read_text uri
  library = library_for(uri)
  filename = uri_to_file(uri)
  library.read_text(filename)
end

#receive(request) ⇒ Solargraph::LanguageServer::Message::Base?

Start processing a request from the client. After the message is processed, caller is responsible for sending the response.

Parameters:

  • request (Hash{String => unspecified})

    The contents of the message.

Returns:



105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/solargraph/language_server/host.rb', line 105

def receive request
  if request['method']
    logger.info "Server received #{request['method']}"
    logger.debug request
    message = Message.select(request['method']).new(self, request)
    begin
      message.process
    rescue StandardError => e
      logger.warn "Error processing request: [#{e.class}] #{e.message}"
      logger.warn e.backtrace.join("\n")
      message.set_error Solargraph::LanguageServer::ErrorCodes::INTERNAL_ERROR, "[#{e.class}] #{e.message}"
    end
    message
  elsif request['id']
    if requests[request['id']]
      requests[request['id']].process(request['result'])
      requests.delete request['id']
    else
      logger.warn "Discarding client response to unrecognized message #{request['id']}"
      nil
    end
  else
    logger.warn "Invalid message received."
    logger.debug request
    nil
  end
end

#references_from(uri, line, column, strip: true, only: false) ⇒ Array<Solargraph::Range>

Parameters:

  • uri (String)
  • line (Integer)
  • column (Integer)
  • strip (Boolean) (defaults to: true)

    Strip special characters from variable names

  • only (Boolean) (defaults to: false)

    If true, search current file only

Returns:



581
582
583
584
# File 'lib/solargraph/language_server/host.rb', line 581

def references_from uri, line, column, strip: true, only: false
  library = library_for(uri)
  library.references_from(uri_to_file(uri), line, column, strip: strip, only: only)
end

#register_capabilities(methods) ⇒ void

This method returns an undefined value.

Register the methods as capabilities with the client. This method will avoid duplicating registrations and ignore methods that were not flagged for dynamic registration by the client.

Parameters:

  • methods (Array<String>)

    The methods to register



395
396
397
398
399
400
401
402
403
404
405
406
407
# File 'lib/solargraph/language_server/host.rb', line 395

def register_capabilities methods
  logger.debug "Registering capabilities: #{methods}"
  registrations = methods.select { |m| can_register?(m) and !registered?(m) }.map do |m|
    @registered_capabilities.add m
    {
      id: m,
      method: m,
      registerOptions: dynamic_capability_options[m]
    }
  end
  return if registrations.empty?
  send_request 'client/registerCapability', { registrations: registrations }
end

#registered?(method) ⇒ Boolean

True if the specified method has been registered.

Parameters:

  • method (String)

    The method name, e.g., ‘textDocument/completion’

Returns:

  • (Boolean)


448
449
450
# File 'lib/solargraph/language_server/host.rb', line 448

def registered? method
  @registered_capabilities.include?(method)
end

#remove(directory) ⇒ void

This method returns an undefined value.

Remove a directory.

Parameters:

  • directory (String)


322
323
324
325
326
327
328
329
# File 'lib/solargraph/language_server/host.rb', line 322

def remove directory
  logger.info "Removing library for #{directory}"
  # @param lib [Library]
  libraries.delete_if do |lib|
    next false if lib.workspace.directory != directory
    true
  end
end

#remove_folders(array) ⇒ void

This method returns an undefined value.

Parameters:

  • array (Array<Hash>)


333
334
335
336
337
# File 'lib/solargraph/language_server/host.rb', line 333

def remove_folders array
  array.each do |folder|
    remove uri_to_file(folder['uri'])
  end
end

#search(query) ⇒ Array<String>

Parameters:

  • query (String)

Returns:

  • (Array<String>)


596
597
598
599
600
# File 'lib/solargraph/language_server/host.rb', line 596

def search query
  result = []
  libraries.each { |lib| result.concat lib.search(query) }
  result
end

#send_notification(method, params) ⇒ void

This method returns an undefined value.

Send a notification to the client.

Parameters:

  • method (String)

    The message method

  • params (Hash)

    The method parameters



349
350
351
352
353
354
355
356
357
358
359
360
# File 'lib/solargraph/language_server/host.rb', line 349

def send_notification method, params
  response = {
    jsonrpc: "2.0",
    method: method,
    params: params
  }
  json = response.to_json
  envelope = "Content-Length: #{json.bytesize}\r\n\r\n#{json}"
  queue envelope
  logger.info "Server sent #{method}"
  logger.debug params
end

#send_request(method, params, &block) {|The| ... } ⇒ void

This method returns an undefined value.

Send a request to the client and execute the provided block to process the response. If an ID is not provided, the host will use an auto- incrementing integer.

Parameters:

  • method (String)

    The message method

  • params (Hash)

    The method parameters

  • block (Proc)

    The block that processes the response

Yield Parameters:

  • The (Hash)

    result sent by the client



371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
# File 'lib/solargraph/language_server/host.rb', line 371

def send_request method, params, &block
  @request_mutex.synchronize do
    message = {
      jsonrpc: "2.0",
      method: method,
      params: params,
      id: @next_request_id
    }
    json = message.to_json
    requests[@next_request_id] = Request.new(@next_request_id, &block)
    envelope = "Content-Length: #{json.bytesize}\r\n\r\n#{json}"
    queue envelope
    @next_request_id += 1
    logger.info "Server sent #{method}"
    logger.debug params
  end
end

#show_message(text, type = LanguageServer::MessageTypes::INFO) ⇒ void

This method returns an undefined value.

Send a notification to the client.

Parameters:

  • text (String)
  • type (Integer) (defaults to: LanguageServer::MessageTypes::INFO)

    A MessageType constant



625
626
627
628
629
630
# File 'lib/solargraph/language_server/host.rb', line 625

def show_message text, type = LanguageServer::MessageTypes::INFO
  send_notification 'window/showMessage', {
    type: type,
    message: text
  }
end

#show_message_request(text, type, actions, &block) {|The| ... } ⇒ void

This method returns an undefined value.

Send a notification with optional responses.

Parameters:

  • text (String)
  • type (Integer)

    A MessageType constant

  • actions (Array<String>)

    Response options for the client

  • block

    The block that processes the response

Yield Parameters:

  • The (String)

    action received from the client



640
641
642
643
644
645
646
# File 'lib/solargraph/language_server/host.rb', line 640

def show_message_request text, type, actions, &block
  send_request 'window/showMessageRequest', {
    type: type,
    message: text,
    actions: actions
  }, &block
end

#signatures_at(uri, line, column) ⇒ Array<Solargraph::Pin::Base>

Parameters:

  • uri (String)
  • line (Integer)
  • column (Integer)

Returns:



570
571
572
573
# File 'lib/solargraph/language_server/host.rb', line 570

def signatures_at uri, line, column
  library = library_for(uri)
  library.signatures_at(uri_to_file(uri), line, column)
end

#startvoid

This method returns an undefined value.

Start asynchronous process handling.



42
43
44
45
46
47
48
49
# File 'lib/solargraph/language_server/host.rb', line 42

def start
  return unless stopped?
  @stopped = false
  diagnoser.start
  cataloger.start
  sources.start
  message_worker.start
end

#stopvoid

This method returns an undefined value.



457
458
459
460
461
462
463
464
465
466
# File 'lib/solargraph/language_server/host.rb', line 457

def stop
  return if @stopped
  @stopped = true
  message_worker.stop
  cataloger.stop
  diagnoser.stop
  sources.stop
  changed
  notify_observers
end

#stopped?Boolean

Returns:

  • (Boolean)


468
469
470
# File 'lib/solargraph/language_server/host.rb', line 468

def stopped?
  @stopped
end

#synchronizing?Boolean

Returns:

  • (Boolean)


452
453
454
# File 'lib/solargraph/language_server/host.rb', line 452

def synchronizing?
  !libraries.all?(&:synchronized?)
end

#type_definitions_at(uri, line, column) ⇒ Array<Solargraph::Pin::Base>

Parameters:

  • uri (String)
  • line (Integer)
  • column (Integer)

Returns:



561
562
563
564
# File 'lib/solargraph/language_server/host.rb', line 561

def type_definitions_at uri, line, column
  library = library_for(uri)
  library.type_definitions_at(uri_to_file(uri), line, column)
end

#unregister_capabilities(methods) ⇒ void

This method returns an undefined value.

Unregister the methods with the client. This method will avoid duplicating unregistrations and ignore methods that were not flagged for dynamic registration by the client.

Parameters:

  • methods (Array<String>)

    The methods to unregister



415
416
417
418
419
420
421
422
423
424
425
426
# File 'lib/solargraph/language_server/host.rb', line 415

def unregister_capabilities methods
  logger.debug "Unregistering capabilities: #{methods}"
  unregisterations = methods.select{|m| registered?(m)}.map{ |m|
    @registered_capabilities.delete m
    {
      id: m,
      method: m
    }
  }
  return if unregisterations.empty?
  send_request 'client/unregisterCapability', { unregisterations: unregisterations }
end