solargraph 0.43.0 → 0.43.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 89a1a9d76094688ff7ebe1af3dec4452c379819408ffc458eddcd75f5b66d2eb
4
- data.tar.gz: 9b03143ba896ccd2d3bd0a44c9a1e90f06e3ed757a47a08e6b8aaf2a9f56e62e
3
+ metadata.gz: 48b532bf77bb72b9d2d111605cc86e97a21c372319a041ef5c4dfbd03a2b98d1
4
+ data.tar.gz: da953eea90b1215a794783723898277abe33a4b74e585eeb710f231b824321b7
5
5
  SHA512:
6
- metadata.gz: a6d4e99416af96a8a11ca569d096f4ba1491155f3fde1efc734e59c73d1794007d0b7b1e936c1dfb248472df1fa679c7701866176de99119e8f6a0b8eef721d4
7
- data.tar.gz: edd612d341e6c9bb421e4bbb8db04badc855e924eca469c47943c374813025810151aca1abdd0da13100597803799a50c7355a362b8a0ae65187c0760464e840
6
+ metadata.gz: c3f55a7eb1f0b08247d70f7a2c28422b6444e5102a96c7c9da88b5b9b5f558732f97dc186e6dc53650bd5af20747066dbf53272a15527f000607fca17583e6da
7
+ data.tar.gz: 7224059b6b2c757049bf27c4140c54063b035b13eeaf93f30c521393c5e8c863b72843c28edbfb9cbe2980fe28f79006195926f9c8bf79b204dd08a9895ec1e8
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 0.43.1
2
+ - Complete nested namespaces in open gates
3
+ - SourceMap::Mapper reports filename for encoding errors (#474)
4
+ - Handle request on a specific thread, and cancel completion when there has newer completion request (#459)
5
+ - Fix namespace links generated by views/_method.erb (#472)
6
+ - Source handles long squiggly heredocs (#460)
7
+
1
8
  ## 0.43.0 - July 25, 2021
2
9
  - Correct arity checks when restarg precedes arg (#418)
3
10
  - Improve the performance of catalog by 4 times (#457)
data/README.md CHANGED
@@ -34,7 +34,8 @@ Plug-ins and extensions are available for the following editors:
34
34
  * GitHub: https://github.com/autozimu/LanguageClient-neovim
35
35
 
36
36
  * **Emacs**
37
- * GitHub: https://github.com/guskovd/emacs-solargraph
37
+ * GitHub: `eglot.el`, https://github.com/joaotavora/eglot
38
+ * GitHub: `lsp-mode.el`, https://github.com/emacs-lsp/lsp-mode
38
39
 
39
40
  * **Eclipse**
40
41
  * Plugin: https://marketplace.eclipse.org/content/ruby-solargraph
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Solargraph
4
+ module LanguageServer
5
+ class Host
6
+ # A serial worker Thread to handle message.
7
+ #
8
+ # this make check pending message possible, and maybe cancelled to speedup process
9
+ class MessageWorker
10
+ # @param host [Host]
11
+ def initialize(host)
12
+ @host = host
13
+ @mutex = Mutex.new
14
+ @resource = ConditionVariable.new
15
+ @stopped = true
16
+ end
17
+
18
+ # pending handle messages
19
+ def messages
20
+ @messages ||= []
21
+ end
22
+
23
+ def stopped?
24
+ @stopped
25
+ end
26
+ def stop
27
+ @stopped = true
28
+ end
29
+
30
+ # @param message the message should be handle. will pass back to Host#receive
31
+ def queue(message)
32
+ @mutex.synchronize {
33
+ messages.push(message)
34
+ @resource.signal
35
+ }
36
+ end
37
+
38
+ def start
39
+ return unless @stopped
40
+ @stopped = false
41
+ Thread.new do
42
+ tick until stopped?
43
+ end
44
+ end
45
+ def tick
46
+ message = @mutex.synchronize {
47
+ @resource.wait(@mutex) if messages.empty?
48
+ messages.shift
49
+ }
50
+ message = @host.receive(message)
51
+ message && message.send_response
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -12,10 +12,12 @@ module Solargraph
12
12
  # safety for multi-threaded transports.
13
13
  #
14
14
  class Host
15
- autoload :Diagnoser, 'solargraph/language_server/host/diagnoser'
16
- autoload :Cataloger, 'solargraph/language_server/host/cataloger'
17
- autoload :Sources, 'solargraph/language_server/host/sources'
18
- autoload :Dispatch, 'solargraph/language_server/host/dispatch'
15
+ autoload :Diagnoser, 'solargraph/language_server/host/diagnoser'
16
+ autoload :Cataloger, 'solargraph/language_server/host/cataloger'
17
+ autoload :Sources, 'solargraph/language_server/host/sources'
18
+ autoload :Dispatch, 'solargraph/language_server/host/dispatch'
19
+ autoload :MessageWorker, 'solargraph/language_server/host/message_worker'
20
+
19
21
 
20
22
  include UriHelpers
21
23
  include Logging
@@ -45,6 +47,7 @@ module Solargraph
45
47
  diagnoser.start
46
48
  cataloger.start
47
49
  sources.start
50
+ message_worker.start
48
51
  end
49
52
 
50
53
  # Update the configuration options with the provided hash.
@@ -89,8 +92,13 @@ module Solargraph
89
92
  @cancel_semaphore.synchronize { @cancel.delete id }
90
93
  end
91
94
 
95
+ # called by adapter, to handle the request
96
+ def process request
97
+ message_worker.queue(request)
98
+ end
99
+
92
100
  # Start processing a request from the client. After the message is
93
- # processed, the transport is responsible for sending the response.
101
+ # processed, caller is responsible for sending the response.
94
102
  #
95
103
  # @param request [Hash] The contents of the message.
96
104
  # @return [Solargraph::LanguageServer::Message::Base] The message handler.
@@ -451,6 +459,7 @@ module Solargraph
451
459
  def stop
452
460
  return if @stopped
453
461
  @stopped = true
462
+ message_worker.stop
454
463
  cataloger.stop
455
464
  diagnoser.stop
456
465
  sources.stop
@@ -513,6 +522,11 @@ module Solargraph
513
522
  library.completions_at uri_to_file(uri), line, column
514
523
  end
515
524
 
525
+ # @return [Bool] if has pending completion request
526
+ def has_pending_completions?
527
+ message_worker.messages.reverse_each.any? { |req| req['method'] == 'textDocument/completion' }
528
+ end
529
+
516
530
  # @param uri [String]
517
531
  # @param line [Integer]
518
532
  # @param column [Integer]
@@ -646,6 +660,11 @@ module Solargraph
646
660
 
647
661
  private
648
662
 
663
+ # @return [MessageWorker]
664
+ def message_worker
665
+ @message_worker ||= MessageWorker.new(self)
666
+ end
667
+
649
668
  # @return [Diagnoser]
650
669
  def diagnoser
651
670
  @diagnoser ||= Diagnoser.new(self)
@@ -62,10 +62,14 @@ module Solargraph
62
62
  def send_response
63
63
  return if id.nil?
64
64
  if host.cancel?(id)
65
+ # https://microsoft.github.io/language-server-protocol/specifications/specification-current/#cancelRequest
66
+ # cancel should send response RequestCancelled
65
67
  Solargraph::Logging.logger.info "Cancelled response to #{method}"
66
- return
68
+ set_result nil
69
+ set_error ErrorCodes::REQUEST_CANCELLED, "cancelled by client"
70
+ else
71
+ Solargraph::Logging.logger.info "Sending response to #{method}"
67
72
  end
68
- Solargraph::Logging.logger.info "Sending response to #{method}"
69
73
  response = {
70
74
  jsonrpc: "2.0",
71
75
  id: id,
@@ -6,6 +6,8 @@ module Solargraph
6
6
  module TextDocument
7
7
  class Completion < Base
8
8
  def process
9
+ return set_error(ErrorCodes::REQUEST_CANCELLED, "cancelled by so many request") if host.has_pending_completions?
10
+
9
11
  line = params['position']['line']
10
12
  col = params['position']['character']
11
13
  begin
@@ -41,8 +41,7 @@ module Solargraph
41
41
  # @param request [String]
42
42
  # @return [void]
43
43
  def process request
44
- message = @host.receive(request)
45
- message && message.send_response
44
+ @host.process(request)
46
45
  end
47
46
 
48
47
  def shutdown
@@ -2,7 +2,7 @@ require 'ripper'
2
2
 
3
3
  module Solargraph
4
4
  module Parser
5
- class CommentRipper < Ripper::SexpBuilder
5
+ class CommentRipper < Ripper::SexpBuilderPP
6
6
  def initialize src, filename = '(ripper)', lineno = 0
7
7
  super
8
8
  @buffer = src
@@ -103,6 +103,31 @@ module Solargraph
103
103
  en = Position.new(node.loc.last_line, node.loc.last_column)
104
104
  Range.new(st, en)
105
105
  end
106
+
107
+ def string_ranges node
108
+ return [] unless is_ast_node?(node)
109
+ result = []
110
+ if node.type == :str
111
+ result.push Range.from_node(node)
112
+ elsif node.type == :dstr
113
+ here = Range.from_node(node)
114
+ there = Range.from_node(node.children[1])
115
+ result.push Range.new(here.start, there.start)
116
+ end
117
+ node.children.each do |child|
118
+ result.concat string_ranges(child)
119
+ end
120
+ if node.type == :dstr && node.children.last.nil?
121
+ # result.push Range.new(result.last.ending, result.last.ending)
122
+ last = node.children[-2]
123
+ unless last.nil?
124
+ rng = Range.from_node(last)
125
+ pos = Position.new(rng.ending.line, rng.ending.column - 1)
126
+ result.push Range.new(pos, pos)
127
+ end
128
+ end
129
+ result
130
+ end
106
131
  end
107
132
  end
108
133
  end
@@ -22,12 +22,18 @@ module Solargraph
22
22
  @closure = Solargraph::Pin::ROOT_PIN
23
23
  end
24
24
  @open_gates = gates
25
- if @open_gates.one? && @open_gates.first.empty? && @name.include?('::')
25
+ if @name.include?('::')
26
26
  # In this case, a chained namespace was opened (e.g., Foo::Bar)
27
27
  # but Foo does not exist.
28
28
  parts = @name.split('::')
29
29
  @name = parts.pop
30
- @closure = Pin::Namespace.new(name: parts.join('::'), gates: [parts.join('::')])
30
+ closure_name = if [Solargraph::Pin::ROOT_PIN, nil].include?(closure)
31
+ ''
32
+ else
33
+ closure.full_context.namespace + '::'
34
+ end
35
+ closure_name += parts.join('::')
36
+ @closure = Pin::Namespace.new(name: closure_name, gates: [parts.join('::')])
31
37
  @context = nil
32
38
  end
33
39
  end
@@ -204,6 +204,8 @@ module Solargraph
204
204
  com_pos = Position.new(line + 1 - comments.lines.length, 0)
205
205
  process_comment(src_pos, com_pos, comments)
206
206
  end
207
+ rescue StandardError => e
208
+ raise e.class, "Error processing comment directives in #{@filename}: #{e.message}"
207
209
  end
208
210
  end
209
211
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Solargraph
4
- VERSION = '0.43.0'
4
+ VERSION = '0.43.1'
5
5
  end
@@ -2,7 +2,7 @@
2
2
  Namespace:
3
3
  </h2>
4
4
  <p>
5
- <a href="command:solargraph._openDocument?<%= CGI.escape "\"solargraph:/document?query=#{object.namespace}\"" %>"><%= object.namespace %></a>
5
+ <a href="solargraph:/document?query=<%= CGI.escape object.namespace.path %>"><%= object.namespace %></a>
6
6
  </p>
7
7
  <h2>
8
8
  Overview:
data/lib/solargraph.rb CHANGED
@@ -57,6 +57,7 @@ module Solargraph
57
57
  # A helper method that runs Bundler.with_unbundled_env or falls back to
58
58
  # Bundler.with_clean_env for earlier versions of Bundler.
59
59
  #
60
+ # @return [void]
60
61
  def self.with_clean_env &block
61
62
  meth = if Bundler.respond_to?(:with_unbundled_env)
62
63
  :with_unbundled_env
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solargraph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.43.0
4
+ version: 0.43.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fred Snyder
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-07-25 00:00:00.000000000 Z
11
+ date: 2021-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: backport
@@ -350,6 +350,7 @@ files:
350
350
  - lib/solargraph/language_server/host/cataloger.rb
351
351
  - lib/solargraph/language_server/host/diagnoser.rb
352
352
  - lib/solargraph/language_server/host/dispatch.rb
353
+ - lib/solargraph/language_server/host/message_worker.rb
353
354
  - lib/solargraph/language_server/host/sources.rb
354
355
  - lib/solargraph/language_server/message.rb
355
356
  - lib/solargraph/language_server/message/base.rb