yoda-language-server 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +5 -3
  3. data/README.md +50 -48
  4. data/client/atom/main.js +13 -3
  5. data/client/vscode/.vscode/launch.json +7 -4
  6. data/client/vscode/package-lock.json +585 -1454
  7. data/client/vscode/package.json +10 -7
  8. data/client/vscode/src/extension.ts +3 -3
  9. data/client/vscode/src/test/completion.test.ts +39 -0
  10. data/client/vscode/src/test/helper.ts +38 -0
  11. data/client/vscode/src/test/index.ts +5 -3
  12. data/client/vscode/testFixture/completion.rb +1 -0
  13. data/exe/yoda +1 -20
  14. data/lib/yoda.rb +2 -1
  15. data/lib/yoda/commands.rb +34 -0
  16. data/lib/yoda/commands/base.rb +10 -0
  17. data/lib/yoda/commands/complete.rb +36 -0
  18. data/lib/yoda/commands/file_cursor_parsable.rb +29 -0
  19. data/lib/yoda/{runner → commands}/infer.rb +4 -9
  20. data/lib/yoda/commands/setup.rb +37 -0
  21. data/lib/yoda/errors.rb +34 -0
  22. data/lib/yoda/evaluation/evaluator.rb +2 -0
  23. data/lib/yoda/server.rb +60 -15
  24. data/lib/yoda/server/completion_provider.rb +8 -8
  25. data/lib/yoda/server/definition_provider.rb +8 -8
  26. data/lib/yoda/server/hover_provider.rb +6 -6
  27. data/lib/yoda/server/initialization_provider.rb +85 -0
  28. data/lib/yoda/server/{client_info.rb → session.rb} +6 -2
  29. data/lib/yoda/server/signature_provider.rb +6 -6
  30. data/lib/yoda/store/actions.rb +3 -1
  31. data/lib/yoda/store/actions/build_core_index.rb +44 -0
  32. data/lib/yoda/store/actions/import_core_library.rb +14 -9
  33. data/lib/yoda/store/actions/import_gem.rb +98 -0
  34. data/lib/yoda/store/actions/import_std_library.rb +35 -0
  35. data/lib/yoda/store/adapters.rb +1 -0
  36. data/lib/yoda/store/adapters/memory_adapter.rb +81 -0
  37. data/lib/yoda/store/objects.rb +4 -0
  38. data/lib/yoda/store/objects/addressable.rb +0 -12
  39. data/lib/yoda/store/objects/base.rb +4 -14
  40. data/lib/yoda/store/objects/merger.rb +4 -4
  41. data/lib/yoda/store/objects/patchable.rb +19 -0
  42. data/lib/yoda/store/objects/project_status.rb +169 -0
  43. data/lib/yoda/store/objects/serializable.rb +39 -0
  44. data/lib/yoda/store/project.rb +28 -114
  45. data/lib/yoda/store/project/cache.rb +79 -0
  46. data/lib/yoda/store/project/library_doc_loader.rb +102 -0
  47. data/lib/yoda/store/query/find_constant.rb +2 -1
  48. data/lib/yoda/store/registry.rb +15 -0
  49. data/lib/yoda/store/yard_importer.rb +58 -28
  50. data/lib/yoda/typing/evaluator.rb +8 -5
  51. data/lib/yoda/version.rb +1 -1
  52. data/package.json +32 -11
  53. data/scripts/benchmark.rb +1 -1
  54. data/yoda-language-server.gemspec +1 -0
  55. metadata +37 -7
  56. data/client/vscode/src/test/extension.test.ts +0 -22
  57. data/lib/yoda/runner/setup.rb +0 -26
  58. data/lib/yoda/store/actions/import_gems.rb +0 -91
@@ -200,8 +200,9 @@ module Yoda
200
200
  new_caller_object = context.lexical_scope.namespace
201
201
  method_object = Store::Query::FindSignature.new(context.registry).select(new_caller_object, node.children[-3].to_s).first
202
202
  new_context = context.derive(caller_object: new_caller_object)
203
- new_context.env.bind_method_parameters(method_object)
204
- self.class.new(new_context).process(node.children[-1])
203
+ new_context.env.bind_method_parameters(method_object) if method_object
204
+ method_body_node = node.children[-1]
205
+ method_body_node ? self.class.new(new_context).process(method_body_node) : nil_type
205
206
  end
206
207
 
207
208
  # @param node [::AST::Node]
@@ -211,9 +212,7 @@ module Yoda
211
212
  new_caller_object = type.resolve(context.registry).first
212
213
  method_object = Store::Query::FindSignature.new(context.registry).select(new_caller_object, node.children[-3].to_s).first
213
214
  new_context = context.derive(caller_object: new_caller_object)
214
- if method_object
215
- new_context.env.bind_method_parameters(method_object)
216
- end
215
+ new_context.env.bind_method_parameters(method_object) if method_object
217
216
  self.class.new(new_context).process(node.children[-1])
218
217
  end
219
218
 
@@ -238,6 +237,10 @@ module Yoda
238
237
  Model::Types::UnknownType.new
239
238
  end
240
239
 
240
+ def nil_type
241
+ Model::Types::ValueType.new('nil')
242
+ end
243
+
241
244
  # @return [Environment]
242
245
  def env
243
246
  context.env
@@ -1,3 +1,3 @@
1
1
  module Yoda
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -12,15 +12,33 @@
12
12
  "dependencies": {
13
13
  "atom-languageclient": "^0.9.5"
14
14
  },
15
+ "configSchema": {
16
+ "serverPath": {
17
+ "title": "yoda Server Path",
18
+ "description": "Exection File Path of yoda (if empty, find from your PATH)",
19
+ "type": "string",
20
+ "default": ""
21
+ }
22
+ },
15
23
  "consumedServices": {
16
- "linter-indie": {
24
+ "atom-ide-busy-signal": {
17
25
  "versions": {
18
- "2.0.0": "consumeLinterV2"
26
+ "0.1.0": "consumeBusySignal"
19
27
  }
20
28
  },
21
- "atom-ide-busy-signal": {
29
+ "code-actions": {
22
30
  "versions": {
23
- "0.1.0": "consumeBusySignal"
31
+ "0.1.0": "provideCodeActions"
32
+ }
33
+ },
34
+ "code-highlight": {
35
+ "versions": {
36
+ "0.1.0": "provideCodeHighlight"
37
+ }
38
+ },
39
+ "console": {
40
+ "versions": {
41
+ "0.1.0": "consumeConsole"
24
42
  }
25
43
  },
26
44
  "datatip": {
@@ -28,16 +46,19 @@
28
46
  "0.1.0": "consumeDatatip"
29
47
  }
30
48
  },
31
- "signature-help": {
49
+ "linter-indie": {
32
50
  "versions": {
33
- "0.1.0": "consumeSignatureHelp"
51
+ "2.0.0": "consumeLinterV2"
52
+ }
53
+ },
54
+ "outline-view": {
55
+ "versions": {
56
+ "0.1.0": "provideOutlines"
34
57
  }
35
58
  },
36
- "consumedServices": {
37
- "atom-ide-busy-signal": {
38
- "versions": {
39
- "0.1.0": "consumeBusySignal"
40
- }
59
+ "signature-help": {
60
+ "versions": {
61
+ "0.1.0": "consumeSignatureHelp"
41
62
  }
42
63
  }
43
64
  },
@@ -2,5 +2,5 @@ require 'yoda'
2
2
  require 'benchmark'
3
3
 
4
4
  Benchmark.bm do |b|
5
- b.report { Yoda::Runner::Setup.run(File.expand_path('../spec/support/fixtures', __dir__)) }
5
+ b.report { Yoda::Commands::Setup.run(dir: File.expand_path('../spec/support/fixtures', __dir__), force_build: true) }
6
6
  end
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.require_paths = ["lib"]
23
23
 
24
24
  spec.add_dependency 'yard', '~> 0.9.11'
25
+ spec.add_dependency 'thor', '~> 0.20.0'
25
26
  spec.add_dependency 'parslet', '~> 1.8'
26
27
  spec.add_dependency 'parser', '~> 2.0'
27
28
  spec.add_dependency 'language_server-protocol', '~> 3.7.0.0'
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.4.0
4
+ version: 0.5.0
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-06-04 00:00:00.000000000 Z
11
+ date: 2018-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yard
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.9.11
27
+ - !ruby/object:Gem::Dependency
28
+ name: thor
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.20.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.20.0
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: parslet
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -249,12 +263,21 @@ files:
249
263
  - client/vscode/package-lock.json
250
264
  - client/vscode/package.json
251
265
  - client/vscode/src/extension.ts
252
- - client/vscode/src/test/extension.test.ts
266
+ - client/vscode/src/test/completion.test.ts
267
+ - client/vscode/src/test/helper.ts
253
268
  - client/vscode/src/test/index.ts
269
+ - client/vscode/testFixture/completion.rb
254
270
  - client/vscode/tsconfig.json
255
271
  - client/vscode/vsc-extension-quickstart.md
256
272
  - exe/yoda
257
273
  - lib/yoda.rb
274
+ - lib/yoda/commands.rb
275
+ - lib/yoda/commands/base.rb
276
+ - lib/yoda/commands/complete.rb
277
+ - lib/yoda/commands/file_cursor_parsable.rb
278
+ - lib/yoda/commands/infer.rb
279
+ - lib/yoda/commands/setup.rb
280
+ - lib/yoda/errors.rb
258
281
  - lib/yoda/evaluation.rb
259
282
  - lib/yoda/evaluation/code_completion.rb
260
283
  - lib/yoda/evaluation/code_completion/base_provider.rb
@@ -333,25 +356,27 @@ files:
333
356
  - lib/yoda/parsing/source_cutter.rb
334
357
  - lib/yoda/parsing/type_parser.rb
335
358
  - lib/yoda/runner.rb
336
- - lib/yoda/runner/infer.rb
337
- - lib/yoda/runner/setup.rb
338
359
  - lib/yoda/server.rb
339
- - lib/yoda/server/client_info.rb
340
360
  - lib/yoda/server/completion_provider.rb
341
361
  - lib/yoda/server/definition_provider.rb
342
362
  - lib/yoda/server/deserializer.rb
343
363
  - lib/yoda/server/hover_provider.rb
364
+ - lib/yoda/server/initialization_provider.rb
365
+ - lib/yoda/server/session.rb
344
366
  - lib/yoda/server/signature_provider.rb
345
367
  - lib/yoda/store.rb
346
368
  - lib/yoda/store/actions.rb
369
+ - lib/yoda/store/actions/build_core_index.rb
347
370
  - lib/yoda/store/actions/import_core_library.rb
348
- - lib/yoda/store/actions/import_gems.rb
371
+ - lib/yoda/store/actions/import_gem.rb
372
+ - lib/yoda/store/actions/import_std_library.rb
349
373
  - lib/yoda/store/actions/read_file.rb
350
374
  - lib/yoda/store/actions/read_project_files.rb
351
375
  - lib/yoda/store/adapters.rb
352
376
  - lib/yoda/store/adapters/base.rb
353
377
  - lib/yoda/store/adapters/leveldb_adapter.rb
354
378
  - lib/yoda/store/adapters/lmdb_adapter.rb
379
+ - lib/yoda/store/adapters/memory_adapter.rb
355
380
  - lib/yoda/store/objects.rb
356
381
  - lib/yoda/store/objects/addressable.rb
357
382
  - lib/yoda/store/objects/base.rb
@@ -364,9 +389,14 @@ files:
364
389
  - lib/yoda/store/objects/overload.rb
365
390
  - lib/yoda/store/objects/patch.rb
366
391
  - lib/yoda/store/objects/patch_set.rb
392
+ - lib/yoda/store/objects/patchable.rb
393
+ - lib/yoda/store/objects/project_status.rb
394
+ - lib/yoda/store/objects/serializable.rb
367
395
  - lib/yoda/store/objects/tag.rb
368
396
  - lib/yoda/store/objects/value_object.rb
369
397
  - lib/yoda/store/project.rb
398
+ - lib/yoda/store/project/cache.rb
399
+ - lib/yoda/store/project/library_doc_loader.rb
370
400
  - lib/yoda/store/query.rb
371
401
  - lib/yoda/store/query/associators.rb
372
402
  - lib/yoda/store/query/associators/associate_ancestors.rb
@@ -1,22 +0,0 @@
1
- //
2
- // Note: This example test is leveraging the Mocha test framework.
3
- // Please refer to their documentation on https://mochajs.org/ for help.
4
- //
5
-
6
- // The module 'assert' provides assertion methods from node
7
- import * as assert from 'assert';
8
-
9
- // You can import and use all API from the 'vscode' module
10
- // as well as import your extension to test it
11
- import * as vscode from 'vscode';
12
- import * as myExtension from '../extension';
13
-
14
- // Defines a Mocha test suite to group tests of similar kind together
15
- suite("Extension Tests", () => {
16
-
17
- // Defines a Mocha unit test
18
- test("Something 1", () => {
19
- assert.equal(-1, [1, 2, 3].indexOf(5));
20
- assert.equal(-1, [1, 2, 3].indexOf(0));
21
- });
22
- });
@@ -1,26 +0,0 @@
1
- module Yoda
2
- module Runner
3
- class Setup
4
- # @return [String]
5
- attr_reader :dir
6
-
7
- # @param dir [String]
8
- def initialize(dir = nil)
9
- @dir = dir || Dir.pwd
10
- end
11
-
12
- # @param dir [String]
13
- def self.run(dir = nil)
14
- new(dir).run
15
- end
16
-
17
- def run
18
- project.rebuild_cache(progress: true)
19
- end
20
-
21
- def project
22
- @project ||= Store::Project.new(dir)
23
- end
24
- end
25
- end
26
- end
@@ -1,91 +0,0 @@
1
- require 'open3'
2
-
3
- module Yoda
4
- module Store
5
- module Actions
6
- class ImportGems
7
- # @return [Registry]
8
- attr_reader :registry
9
-
10
- # @return [Array<Bundler::LazySpecification>]
11
- attr_reader :gem_specs
12
-
13
- # @param registry [Registry]
14
- # @param gem_specs [Array<Bundler::LazySpecification>]
15
- def initialize(registry, gem_specs)
16
- @registry = registry
17
- @gem_specs = gem_specs
18
- end
19
-
20
- # @return [void]
21
- def run
22
- create_dependency_docs
23
- gem_specs.map do |gem|
24
- if yardoc_file = yardoc_file_for_gem(gem)
25
- if patch = load_yardoc(yardoc_file, gem_path_for(gem))
26
- registry.add_patch(patch)
27
- end
28
- end
29
- end
30
- end
31
-
32
- private
33
-
34
- def create_dependency_docs
35
- gem_specs.each do |gem|
36
- if yardoc_file_for_gem(gem)
37
- STDERR.puts "Gem docs for #{gem.name} #{gem.version} already exist"
38
- next
39
- end
40
- STDERR.puts "Building gem docs for #{gem.name} #{gem.version}"
41
- begin
42
- o, e = Open3.capture2e("yard gems #{gem.name} #{gem.version}")
43
- STDERR.puts o unless o.empty?
44
- if e.success?
45
- STDERR.puts "Done building gem docs for #{gem.name} #{gem.version}"
46
- else
47
- STDERR.puts "Failed to build #{gem.name} #{gem.version}"
48
- end
49
- rescue => ex
50
- STDERR.puts ex
51
- STDERR.puts ex.backtrace
52
- STDERR.puts "Failed to build #{gem.name} #{gem.version}"
53
- end
54
- end
55
- end
56
-
57
- # @param gem [Bundler::LazySpecification]
58
- # @return [String, nil]
59
- def yardoc_file_for_gem(gem)
60
- YARD::Registry.yardoc_file_for_gem(gem.name, gem.version)
61
- rescue Bundler::BundlerError => ex
62
- STDERR.puts ex
63
- STDERR.puts ex.backtrace
64
- nil
65
- end
66
-
67
- # @param yardoc_file [String]
68
- # @param gem_source_path [String]
69
- # @return [Objects::Patch, nil]
70
- def load_yardoc(yardoc_file, gem_source_path)
71
- begin
72
- YardImporter.import(yardoc_file, root_path: gem_source_path)
73
- rescue => ex
74
- STDERR.puts ex
75
- STDERR.puts ex.backtrace
76
- STDERR.puts "Failed to load #{yardoc_file}"
77
- nil
78
- end
79
- end
80
-
81
- # @param gem [Bundler::LazySpecification]
82
- # @return [String, nil]
83
- def gem_path_for(gem)
84
- if spec = Gem.source_index.find_name(gem.name).first
85
- spec.full_gem_path
86
- end
87
- end
88
- end
89
- end
90
- end
91
- end