yoda-language-server 0.6.1 → 0.6.2

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: 026ad978f889f457cfac675feadfd43524331de432d3b8999470e250609fc2c1
4
- data.tar.gz: ba929d2e80bd0d6dcef240517f2bc73ae4a9d138f0319317396f7d1a469e9d73
3
+ metadata.gz: 45f3bb7e65e24213b3d1c0e60110c08498d765e6a27732800d2c02e3508b03e4
4
+ data.tar.gz: 4e99d7cba046557256be92cfcf747e194086c52dedd94e7db344cc6fb8e9a2b1
5
5
  SHA512:
6
- metadata.gz: 4185217b437afa69a84c3ccbd5a0b8611aa29542116333062b03132d27dc9941d45a6c3718e03fcee634816cb7f4647fe9945779d8b46a1f2c0bee2841231f3f
7
- data.tar.gz: 4f4773144dbd6807ce54d19acea3b5f3725201615379e312f47e6739fe9559dc5159557f6ea62b10823b17d4ffc99246f173cae2421822fb9c451f4e764a353a
6
+ metadata.gz: a278106001664f9468805400c571a333765c16f9557345d9295e2afee2a1a1a82e7d3a3022aaaefee04c7ee6b2c9d3dd23b3f634bca35c5150d5f99dd7cc8916
7
+ data.tar.gz: d13b8b7bde1b5b0dc7028f8df270186e767bae83e901885288b677ca64c9e0326ef788eed7c1578a5a0b359fb33716c89fdad2f203244fb3b14eb796d3fca465
data/client/atom/main.js CHANGED
@@ -2,28 +2,27 @@ const { AutoLanguageClient } = require('atom-languageclient')
2
2
  const { spawn } = require('child_process')
3
3
  const { resolve } = require('path')
4
4
 
5
+ const busyMessages = {
6
+ text_document_hover: 'Preparing hover help',
7
+ text_document_signature_help: 'Preparing signature help',
8
+ text_document_completion: 'Completing',
9
+ text_document_definition: 'Finding definition',
10
+ };
11
+
5
12
  class YodaClient extends AutoLanguageClient {
6
13
  constructor() {
7
14
  super()
15
+ this.busyHandlers = {};
8
16
  }
9
17
 
10
18
  preInitialization(connection) {
11
- connection.onTelemetryEvent(({ type, phase, message }) => {
12
- if (!this.busySignalService) { return; }
13
- if (type != 'initialization') { return; }
14
-
15
- if (this.initializationBusyMessage) {
16
- this.initializationBusyMessage.setTitle(message);
17
- } else {
18
- this.initializationBusyMessage = this.busySignalService.reportBusy(message);
19
- }
20
- });
19
+ connection.onTelemetryEvent((event) => this.handleTelemetryEvent(event));
21
20
  }
22
21
 
23
22
  postInitialization(_server) {
24
- if (this.initializationBusyMessage) {
25
- this.initializationBusyMessage.dispose();
26
- this.initializationBusyMessage = null;
23
+ if (this.busyHandlers.initialization) {
24
+ this.busyHandlers.initialization.dispose();
25
+ this.busyHandlers.initialization = null;
27
26
  }
28
27
  }
29
28
 
@@ -52,6 +51,44 @@ class YodaClient extends AutoLanguageClient {
52
51
  const commandOptions = { cwd: projectPath };
53
52
  return spawn(this.getServerPath(), ['server'], commandOptions);
54
53
  }
54
+
55
+ handleTelemetryEvent(eventBody) {
56
+ if (!this.busySignalService || !eventBody) { return; }
57
+ switch (eventBody.type) {
58
+ case 'initialization':
59
+ return this.handleInitializationEvent(eventBody);
60
+ case 'text_document_hover':
61
+ case 'text_document_completion':
62
+ case 'text_document_signature_help':
63
+ case 'text_document_completion':
64
+ return this.handleBusyEvent(eventBody.type, eventBody);
65
+ default:
66
+ }
67
+ }
68
+
69
+ handleInitializationEvent({ phase, message }) {
70
+ if (this.busyHandlers.initialization) {
71
+ this.busyHandlers.initialization.setTitle(message);
72
+ } else {
73
+ this.busyHandlers.initialization = this.busySignalService.reportBusy(message);
74
+ }
75
+ }
76
+
77
+ handleBusyEvent(handlerName, { phase, message }) {
78
+ switch (phase) {
79
+ case 'begin':
80
+ if (!this.busyHandlers[handlerName]) {
81
+ this.busyHandlers[handlerName] = this.busySignalService.reportBusy("(Yoda) " + busyMessages[handlerName]);
82
+ }
83
+ break;
84
+ case 'end':
85
+ if (this.busyHandlers[handlerName]) {
86
+ this.busyHandlers[handlerName].dispose();
87
+ this.busyHandlers[handlerName] = null;
88
+ }
89
+ break;
90
+ }
91
+ }
55
92
  }
56
93
 
57
94
  module.exports = new YodaClient()
@@ -1,5 +1,6 @@
1
1
  module Yoda
2
2
  module Evaluation
3
+ # CurrentNodeExplain shows help for the current node.
3
4
  class CurrentNodeExplain
4
5
  # @return [Store::Registry]
5
6
  attr_reader :registry
@@ -1,5 +1,7 @@
1
1
  module Yoda
2
2
  module Evaluation
3
+ # SignatureDiscovery infers method candidates for the nearest send node and specify the number of index of these parameters.
4
+ # SignatureDiscovery shows help for the current parameter of method candidates.
3
5
  class SignatureDiscovery
4
6
  # @return [Store::Registry]
5
7
  attr_reader :registry
@@ -5,6 +5,7 @@ module Yoda
5
5
  require 'yoda/model/descriptions/function_description'
6
6
  require 'yoda/model/descriptions/value_description'
7
7
  require 'yoda/model/descriptions/word_description'
8
+ require 'yoda/model/descriptions/node_description'
8
9
  end
9
10
  end
10
11
  end
@@ -0,0 +1,46 @@
1
+ require 'unparser'
2
+
3
+ module Yoda
4
+ module Model
5
+ module Descriptions
6
+ class NodeDescription < Base
7
+ # @return [::Parser::AST::Node]
8
+ attr_reader :node
9
+
10
+ # @return [Typing::Traces::Base]
11
+ attr_reader :trace
12
+
13
+ # @param node [::Parser::AST::Node]
14
+ # @param trace [Typing::Traces::Base]
15
+ def initialize(node, trace)
16
+ @node = node
17
+ @trace = trace
18
+ end
19
+
20
+ # @return [String]
21
+ def title
22
+ node_body
23
+ end
24
+
25
+ # @return [String]
26
+ def sort_text
27
+ node_body
28
+ end
29
+
30
+ # @return [String]
31
+ def to_markdown
32
+ <<~EOS
33
+ #{node_body.gsub("\n", ";")}: #{trace.type}
34
+ EOS
35
+ end
36
+
37
+ private
38
+
39
+ # @return [String]
40
+ def node_body
41
+ @node_body ||= Unparser.unparse(node)
42
+ end
43
+ end
44
+ end
45
+ end
46
+ end
@@ -1,7 +1,12 @@
1
1
  module Yoda
2
2
  module Model
3
3
  class NodeSignature
4
- attr_reader :node, :trace
4
+ # @return [::Parser::AST::Node]
5
+ attr_reader :node
6
+
7
+ # @return [Typing::Traces::Base]
8
+ attr_reader :trace
9
+
5
10
  # @param node [::Parser::AST::Node]
6
11
  # @param trace [Typing::Traces::Base]
7
12
  def initialize(node, trace)
@@ -16,6 +21,16 @@ module Yoda
16
21
 
17
22
  # @return [Array<Descriptions::Base>]
18
23
  def descriptions
24
+ [top_description, *type_descriptions]
25
+ end
26
+
27
+ # @return [Descriptions::NodeDescription]
28
+ def top_description
29
+ Descriptions::NodeDescription.new(node, trace)
30
+ end
31
+
32
+ # @return [Array<Descriptions::Base>]
33
+ def type_descriptions
19
34
  case trace
20
35
  when Typing::Traces::Send
21
36
  trace.functions.map { |function| Descriptions::FunctionDescription.new(function) }.take(1)
data/lib/yoda/server.rb CHANGED
@@ -213,28 +213,36 @@ module Yoda
213
213
  uri = params[:text_document][:uri]
214
214
  position = params[:position]
215
215
 
216
- completion_provider&.complete(uri, position)
216
+ notifier.busy(type: :text_document_completion) do
217
+ completion_provider&.complete(uri, position)
218
+ end
217
219
  end
218
220
 
219
221
  def handle_text_document_hover(params)
220
222
  uri = params[:text_document][:uri]
221
223
  position = params[:position]
222
224
 
223
- hover_provider&.request_hover(uri, position)
225
+ notifier.busy(type: :text_document_hover) do
226
+ hover_provider&.request_hover(uri, position)
227
+ end
224
228
  end
225
229
 
226
230
  def handle_text_document_signature_help(params)
227
231
  uri = params[:text_document][:uri]
228
232
  position = params[:position]
229
233
 
230
- signature_provider&.provide(uri, position)
234
+ notifier.busy(type: :text_document_signature_help) do
235
+ signature_provider&.provide(uri, position)
236
+ end
231
237
  end
232
238
 
233
239
  def handle_text_document_definition(params)
234
240
  uri = params[:text_document][:uri]
235
241
  position = params[:position]
236
242
 
237
- definition_provider&.provide(uri, position)
243
+ notifier.busy(type: :text_document_definition) do
244
+ definition_provider&.provide(uri, position)
245
+ end
238
246
  end
239
247
  end
240
248
  include TextDocument
@@ -1,6 +1,7 @@
1
1
  module Yoda
2
2
  class Server
3
3
  class HoverProvider
4
+ # @return [Session]
4
5
  attr_reader :session
5
6
 
6
7
  # @param session [Session]
@@ -6,6 +6,14 @@ module Yoda
6
6
  @server = server
7
7
  end
8
8
 
9
+ # @param type [Symbol]
10
+ def busy(type:)
11
+ event(type: type, phase: :begin)
12
+ yield
13
+ ensure
14
+ event(type: type, phase: :end)
15
+ end
16
+
9
17
  # @param params [Hash]
10
18
  def event(params)
11
19
  server.send_notification(method: 'telemetry/event', params: params)
@@ -12,6 +12,7 @@ module Yoda
12
12
  end
13
13
  end
14
14
 
15
+ # @param registry [Registry]
15
16
  def initialize(registry)
16
17
  @registry = registry
17
18
  end
@@ -58,6 +58,7 @@ module Yoda
58
58
  unless bundle_status.all_present?
59
59
  Logger.info 'Constructing database for the current project.'
60
60
  bundle_status = import_deps(bundle_status)
61
+ Instrument.instance.initialization_progress(phase: :save, message: 'Saving registry')
61
62
  registry.compress_and_save
62
63
  end
63
64
  bundle_status
data/lib/yoda/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Yoda
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
3
3
  end
@@ -25,6 +25,7 @@ Gem::Specification.new do |spec|
25
25
  spec.add_dependency 'thor', '~> 0.20.0'
26
26
  spec.add_dependency 'parslet', '~> 1.8'
27
27
  spec.add_dependency 'parser', '~> 2.0'
28
+ spec.add_dependency 'unparser', '~> 0.2.6'
28
29
  spec.add_dependency 'language_server-protocol', '~> 3.7.0.0'
29
30
  spec.add_dependency 'leveldb', '~> 0.1.9'
30
31
  spec.add_dependency 'lmdb', '~> 0.4.8'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yoda-language-server
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomoya Chiba
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-26 00:00:00.000000000 Z
11
+ date: 2018-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yard
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '2.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: unparser
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.2.6
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.2.6
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: language_server-protocol
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -298,6 +312,7 @@ files:
298
312
  - lib/yoda/model/descriptions.rb
299
313
  - lib/yoda/model/descriptions/base.rb
300
314
  - lib/yoda/model/descriptions/function_description.rb
315
+ - lib/yoda/model/descriptions/node_description.rb
301
316
  - lib/yoda/model/descriptions/value_description.rb
302
317
  - lib/yoda/model/descriptions/word_description.rb
303
318
  - lib/yoda/model/function_signatures.rb