solargraph 0.39.15 → 0.40.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +4 -8
  3. data/CHANGELOG.md +992 -0
  4. data/Rakefile +12 -1
  5. data/SPONSORS.md +1 -0
  6. data/lib/.rubocop.yml +2 -2
  7. data/lib/solargraph.rb +2 -4
  8. data/lib/solargraph/api_map.rb +75 -74
  9. data/lib/solargraph/api_map/cache.rb +2 -2
  10. data/lib/solargraph/api_map/store.rb +4 -8
  11. data/lib/solargraph/{bundle.rb → bench.rb} +6 -2
  12. data/lib/solargraph/compat.rb +14 -0
  13. data/lib/solargraph/complex_type.rb +2 -2
  14. data/lib/solargraph/convention.rb +13 -4
  15. data/lib/solargraph/convention/base.rb +16 -8
  16. data/lib/solargraph/convention/gemfile.rb +2 -5
  17. data/lib/solargraph/convention/gemspec.rb +3 -6
  18. data/lib/solargraph/convention/rspec.rb +3 -6
  19. data/lib/solargraph/environ.rb +11 -6
  20. data/lib/solargraph/language_server/message/extended/check_gem_version.rb +6 -1
  21. data/lib/solargraph/language_server/message/text_document/definition.rb +1 -1
  22. data/lib/solargraph/language_server/message/text_document/formatting.rb +17 -19
  23. data/lib/solargraph/library.rb +6 -8
  24. data/lib/solargraph/parser/legacy/node_methods.rb +9 -0
  25. data/lib/solargraph/parser/legacy/node_processors/ivasgn_node.rb +1 -1
  26. data/lib/solargraph/parser/legacy/node_processors/send_node.rb +36 -23
  27. data/lib/solargraph/parser/node_processor/base.rb +3 -0
  28. data/lib/solargraph/parser/rubyvm/node_methods.rb +18 -1
  29. data/lib/solargraph/parser/rubyvm/node_processors/args_node.rb +1 -1
  30. data/lib/solargraph/parser/rubyvm/node_processors/ivasgn_node.rb +1 -1
  31. data/lib/solargraph/parser/rubyvm/node_processors/send_node.rb +40 -29
  32. data/lib/solargraph/pin.rb +0 -3
  33. data/lib/solargraph/pin/common.rb +1 -1
  34. data/lib/solargraph/pin/conversions.rb +3 -4
  35. data/lib/solargraph/pin/documenting.rb +3 -9
  36. data/lib/solargraph/pin/method.rb +141 -7
  37. data/lib/solargraph/pin/method_alias.rb +1 -1
  38. data/lib/solargraph/position.rb +2 -14
  39. data/lib/solargraph/source.rb +10 -6
  40. data/lib/solargraph/source/chain.rb +18 -5
  41. data/lib/solargraph/source_map.rb +4 -1
  42. data/lib/solargraph/source_map/clip.rb +3 -2
  43. data/lib/solargraph/source_map/mapper.rb +10 -6
  44. data/lib/solargraph/type_checker.rb +27 -24
  45. data/lib/solargraph/type_checker/param_def.rb +1 -1
  46. data/lib/solargraph/version.rb +1 -1
  47. data/lib/solargraph/yard_map.rb +40 -47
  48. data/lib/solargraph/yard_map/core_fills.rb +185 -0
  49. data/lib/solargraph/yard_map/helpers.rb +16 -0
  50. data/lib/solargraph/yard_map/mapper.rb +14 -8
  51. data/lib/solargraph/{pin/yard_pin/constant.rb → yard_map/mapper/to_constant.rb} +6 -6
  52. data/lib/solargraph/yard_map/mapper/to_method.rb +78 -0
  53. data/lib/solargraph/{pin/yard_pin/namespace.rb → yard_map/mapper/to_namespace.rb} +6 -6
  54. data/lib/solargraph/yard_map/rdoc_to_yard.rb +1 -1
  55. data/lib/solargraph/yard_map/stdlib_fills.rb +43 -0
  56. data/lib/solargraph/yard_map/to_method.rb +79 -0
  57. data/solargraph.gemspec +5 -5
  58. metadata +22 -36
  59. data/lib/solargraph/core_fills.rb +0 -160
  60. data/lib/solargraph/pin/attribute.rb +0 -49
  61. data/lib/solargraph/pin/base_method.rb +0 -141
  62. data/lib/solargraph/pin/yard_pin.rb +0 -12
  63. data/lib/solargraph/pin/yard_pin/method.rb +0 -80
  64. data/lib/solargraph/pin/yard_pin/yard_mixin.rb +0 -20
  65. data/lib/solargraph/stdlib_fills.rb +0 -40
  66. data/travis-bundler.rb +0 -11
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Solargraph
4
- module Pin
5
- module YardPin
6
- autoload :YardMixin, 'solargraph/pin/yard_pin/yard_mixin'
7
- autoload :Constant, 'solargraph/pin/yard_pin/constant'
8
- autoload :Method, 'solargraph/pin/yard_pin/method'
9
- autoload :Namespace, 'solargraph/pin/yard_pin/namespace'
10
- end
11
- end
12
- end
@@ -1,80 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Solargraph
4
- module Pin
5
- module YardPin
6
- class Method < Pin::Method
7
- include YardMixin
8
-
9
- # @param code_object [YARD::CodeObjects::Base]
10
- # @param name [String, nil]
11
- # @param scope [Symbol, nil]
12
- # @param visibility [Symbol, nil]
13
- # @param closure [Solargraph::Pin::Closure, nil]
14
- # @param spec [Gem::Specification]
15
- def initialize code_object, name = nil, scope = nil, visibility = nil, closure = nil, spec = nil
16
- closure ||= Solargraph::Pin::Namespace.new(
17
- name: code_object.namespace.to_s,
18
- gates: [code_object.namespace.to_s]
19
- )
20
- super(
21
- location: object_location(code_object, spec),
22
- closure: closure,
23
- name: name || code_object.name.to_s,
24
- comments: code_object.docstring ? code_object.docstring.all.to_s : '',
25
- scope: scope || code_object.scope,
26
- visibility: visibility || code_object.visibility,
27
- parameters: get_parameters(code_object),
28
- explicit: code_object.is_explicit?
29
- )
30
- end
31
-
32
- private
33
-
34
- # @param code_object [YARD::CodeObjects::Base]
35
- # @return [Array<Solargraph::Pin::Parameter>]
36
- def get_parameters code_object
37
- return [] unless code_object.is_a?(YARD::CodeObjects::MethodObject)
38
- # HACK: Skip `nil` and `self` parameters that are sometimes emitted
39
- # for methods defined in C
40
- # See https://github.com/castwide/solargraph/issues/345
41
- code_object.parameters.select { |a| a[0] && a[0] != 'self' }.map do |a|
42
- Solargraph::Pin::Parameter.new(
43
- location: location,
44
- closure: self,
45
- comments: comments,
46
- name: arg_name(a),
47
- presence: nil,
48
- decl: arg_type(a),
49
- asgn_code: a[1]
50
- )
51
- end
52
- end
53
-
54
- # @param a [Array]
55
- # @return [String]
56
- def arg_name a
57
- a[0].match(/[A-Za-z0-9_]*/)[0]
58
- end
59
-
60
- # @param a [Array]
61
- # @return [Symbol]
62
- def arg_type a
63
- if a[0].start_with?('**')
64
- :kwrestarg
65
- elsif a[0].start_with?('*')
66
- :restarg
67
- elsif a[0].start_with?('&')
68
- :blockarg
69
- elsif a[1]
70
- :optarg
71
- elsif a[0].end_with?(':')
72
- a[1] ? :kwarg : :kwoptarg
73
- else
74
- :arg
75
- end
76
- end
77
- end
78
- end
79
- end
80
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Solargraph
4
- module Pin
5
- module YardPin
6
- module YardMixin
7
- private
8
-
9
- # @param code_object [YARD::CodeObjects::Base]
10
- # @param spec [Gem::Specification]
11
- # @return [Solargraph::Location, nil]
12
- def object_location code_object, spec
13
- return nil if spec.nil? || code_object.nil? || code_object.file.nil? || code_object.line.nil?
14
- file = File.join(spec.full_gem_path, code_object.file)
15
- Solargraph::Location.new(file, Solargraph::Range.from_to(code_object.line - 1, 0, code_object.line - 1, 0))
16
- end
17
- end
18
- end
19
- end
20
- end
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Solargraph
4
- # Overrides for the Ruby stdlib.
5
- #
6
- # The YardMap uses this module to add type information to stdlib methods.
7
- #
8
- module StdlibFills
9
- Override = Pin::Reference::Override
10
-
11
- LIBS = {
12
- 'benchmark' => [
13
- Override.method_return('Benchmark.measure', 'Benchmark::Tms')
14
- ],
15
-
16
- 'pathname' => [
17
- Override.method_return('Pathname#join', 'Pathname'),
18
- Override.method_return('Pathname#basename', 'Pathname'),
19
- Override.method_return('Pathname#dirname', 'Pathname'),
20
- Override.method_return('Pathname#cleanpath', 'Pathname'),
21
- Override.method_return('Pathname#children', 'Array<Pathname>'),
22
- Override.method_return('Pathname#entries', 'Array<Pathname>')
23
- ],
24
-
25
- 'set' => [
26
- Override.method_return('Enumerable#to_set', 'Set'),
27
- Override.method_return('Set#add', 'self'),
28
- Override.method_return('Set#add?', 'self, nil'),
29
- Override.method_return('Set#classify', 'Hash'),
30
- Override.from_comment('Set#each', '@yieldparam_single_parameter')
31
- ]
32
- }
33
-
34
- # @param path [String]
35
- # @return [Array<Pin::Reference::Override>]
36
- def self.get path
37
- LIBS[path] || []
38
- end
39
- end
40
- end
@@ -1,11 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- # Travis uses this script to select which version of bundler to install for
4
- # each job.
5
-
6
- if RUBY_VERSION =~ /^2\.(1|2)\./
7
- `gem install bundler -v '< 2'`
8
- else
9
- `gem update --system`
10
- `gem install bundler`
11
- end