solargraph 0.59.0 → 0.59.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/linting.yml +6 -0
  3. data/.github/workflows/plugins.yml +9 -1
  4. data/.github/workflows/typecheck.yml +3 -1
  5. data/CHANGELOG.md +12 -0
  6. data/lib/solargraph/api_map/store.rb +1 -2
  7. data/lib/solargraph/api_map.rb +4 -6
  8. data/lib/solargraph/complex_type/type_methods.rb +1 -0
  9. data/lib/solargraph/complex_type/unique_type.rb +14 -15
  10. data/lib/solargraph/complex_type.rb +2 -1
  11. data/lib/solargraph/convention/active_support_concern.rb +111 -111
  12. data/lib/solargraph/convention/base.rb +50 -50
  13. data/lib/solargraph/diagnostics.rb +55 -55
  14. data/lib/solargraph/environ.rb +52 -52
  15. data/lib/solargraph/gem_pins.rb +0 -11
  16. data/lib/solargraph/language_server/host.rb +6 -7
  17. data/lib/solargraph/language_server/message/extended/environment.rb +25 -25
  18. data/lib/solargraph/language_server/message/initialized.rb +28 -28
  19. data/lib/solargraph/language_server/message/text_document.rb +28 -28
  20. data/lib/solargraph/language_server/progress.rb +143 -143
  21. data/lib/solargraph/language_server/transport/adapter.rb +68 -68
  22. data/lib/solargraph/language_server.rb +20 -20
  23. data/lib/solargraph/parser/parser_gem/node_chainer.rb +1 -0
  24. data/lib/solargraph/parser/parser_gem/node_methods.rb +91 -4
  25. data/lib/solargraph/parser/parser_gem/node_processors/alias_node.rb +24 -24
  26. data/lib/solargraph/parser/parser_gem/node_processors/casgn_node.rb +36 -36
  27. data/lib/solargraph/parser/parser_gem/node_processors/cvasgn_node.rb +24 -24
  28. data/lib/solargraph/parser/parser_gem/node_processors/gvasgn_node.rb +24 -24
  29. data/lib/solargraph/parser/parser_gem/node_processors/namespace_node.rb +40 -40
  30. data/lib/solargraph/parser/parser_gem/node_processors/sym_node.rb +20 -20
  31. data/lib/solargraph/pin/base.rb +3 -3
  32. data/lib/solargraph/pin/method.rb +2 -0
  33. data/lib/solargraph/pin/parameter.rb +3 -1
  34. data/lib/solargraph/pin/reference/require.rb +14 -14
  35. data/lib/solargraph/pin/search.rb +5 -5
  36. data/lib/solargraph/pin/singleton.rb +11 -11
  37. data/lib/solargraph/rbs_map/conversions.rb +15 -8
  38. data/lib/solargraph/shell.rb +1 -1
  39. data/lib/solargraph/source/chain/array.rb +1 -12
  40. data/lib/solargraph/source/chain/block_symbol.rb +13 -13
  41. data/lib/solargraph/source/chain/block_variable.rb +13 -13
  42. data/lib/solargraph/source/chain/head.rb +19 -19
  43. data/lib/solargraph/source/chain/literal.rb +18 -14
  44. data/lib/solargraph/source/cursor.rb +11 -2
  45. data/lib/solargraph/source/source_chainer.rb +4 -4
  46. data/lib/solargraph/source_map/clip.rb +6 -1
  47. data/lib/solargraph/type_checker.rb +4 -4
  48. data/lib/solargraph/version.rb +1 -1
  49. data/lib/solargraph/yard_map/cache.rb +25 -25
  50. data/lib/solargraph/yard_map/mapper/to_constant.rb +28 -28
  51. data/lib/solargraph/yard_map/mapper/to_method.rb +1 -1
  52. data/lib/solargraph.rb +2 -2
  53. metadata +1 -2
  54. data/rbs/fills/tuple/tuple.rbs +0 -177
@@ -115,8 +115,17 @@ module Solargraph
115
115
  def recipient
116
116
  @recipient ||= begin
117
117
  node = recipient_node
118
- # @sg-ignore Need to add nil check here
119
- node ? Cursor.new(source, Range.from_node(node).ending) : nil
118
+ if node.nil?
119
+ nil
120
+ else
121
+ rng = Range.from_node(node)
122
+ if rng
123
+ Cursor.new(source, rng.ending)
124
+ else
125
+ pos = Position.new(position.line, [position.column - 1, 0].max)
126
+ Cursor.new(source, pos)
127
+ end
128
+ end
120
129
  end
121
130
  end
122
131
  alias receiver recipient
@@ -32,10 +32,10 @@ module Solargraph
32
32
  # @return [Source::Chain]
33
33
  def chain
34
34
  # Special handling for files that end with an integer and a period
35
- if phrase =~ /^[0-9]+\.$/
36
- return Chain.new([Chain::Literal.new('Integer', Integer(phrase[0..-2])),
37
- Chain::UNDEFINED_CALL])
38
- end
35
+ # if phrase =~ /^[0-9]+\.$/
36
+ # return Chain.new([Chain::Literal.new('Integer', Integer(phrase[0..-2])),
37
+ # Chain::UNDEFINED_CALL])
38
+ # end
39
39
  if phrase.start_with?(':') && !phrase.start_with?('::')
40
40
  return Chain.new([Chain::Literal.new('Symbol',
41
41
  # @sg-ignore Need to add nil check here
@@ -54,8 +54,13 @@ module Solargraph
54
54
  # @return [Array<Pin::Method>]
55
55
  def signify
56
56
  return [] unless cursor.argument?
57
+ return [] if cursor.recipient_node.nil?
57
58
  chain = Parser.chain(cursor.recipient_node, cursor.filename)
58
- chain.define(api_map, context_pin, locals).select { |pin| pin.is_a?(Pin::Method) }
59
+ name_pin = context_pin
60
+ if name_pin.nil?
61
+ name_pin = Pin::ProxyType.anonymous(ComplexType.try_parse('::Object'))
62
+ end
63
+ chain.define(api_map, name_pin, locals).select { |pin| pin.is_a?(Pin::Method) }
59
64
  end
60
65
 
61
66
  # @return [ComplexType]
@@ -283,7 +283,7 @@ module Solargraph
283
283
 
284
284
  # @return [Array<Pin::BaseVariable>]
285
285
  def all_variables
286
- source_map.pins_by_class(Pin::BaseVariable) + source_map.locals.select { |pin| pin.is_a?(Pin::LocalVariable) }
286
+ source_map.pins_by_class(Pin::BaseVariable) + source_map.locals.grep(Pin::LocalVariable)
287
287
  end
288
288
 
289
289
  # @return [Array<Problem>]
@@ -773,9 +773,9 @@ module Solargraph
773
773
  return [] if parameters.any?(&:rest?)
774
774
  opt = optional_param_count(parameters)
775
775
  return [] if unchecked.length <= req + opt
776
- if req + add_params + 1 == unchecked.length && any_splatted_call?(unchecked.map(&:node)) && (parameters.map(&:decl) & %i[
777
- kwarg kwoptarg kwrestarg
778
- ]).any?
776
+ if req + add_params + 1 == unchecked.length && any_splatted_call?(unchecked.map(&:node)) && parameters.map(&:decl).intersect?(%i[
777
+ kwarg kwoptarg kwrestarg
778
+ ])
779
779
  return []
780
780
  end
781
781
  return [] if arguments.length - req == parameters.select { |p| %i[optarg kwoptarg].include?(p.decl) }.length
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Solargraph
4
- VERSION = ENV.fetch('SOLARGRAPH_FORCE_VERSION', '0.59.0')
4
+ VERSION = ENV.fetch('SOLARGRAPH_FORCE_VERSION', '0.59.2')
5
5
  end
@@ -1,25 +1,25 @@
1
- # frozen_string_literal: true
2
-
3
- module Solargraph
4
- class YardMap
5
- class Cache
6
- def initialize
7
- # @type [Hash{String => Array<Solargraph::Pin::Base>}]
8
- @path_pins = {}
9
- end
10
-
11
- # @param path [String]
12
- # @param pins [Array<Solargraph::Pin::Base>]
13
- # @return [Array<Solargraph::Pin::Base>]
14
- def set_path_pins path, pins
15
- @path_pins[path] = pins
16
- end
17
-
18
- # @param path [String]
19
- # @return [Array<Solargraph::Pin::Base>]
20
- def get_path_pins path
21
- @path_pins[path]
22
- end
23
- end
24
- end
25
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Solargraph
4
+ class YardMap
5
+ class Cache
6
+ def initialize
7
+ # @type [Hash{String => Array<Solargraph::Pin::Base>}]
8
+ @path_pins = {}
9
+ end
10
+
11
+ # @param path [String]
12
+ # @param pins [Array<Solargraph::Pin::Base>]
13
+ # @return [Array<Solargraph::Pin::Base>]
14
+ def set_path_pins path, pins
15
+ @path_pins[path] = pins
16
+ end
17
+
18
+ # @param path [String]
19
+ # @return [Array<Solargraph::Pin::Base>]
20
+ def get_path_pins path
21
+ @path_pins[path]
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,28 +1,28 @@
1
- # frozen_string_literal: true
2
-
3
- module Solargraph
4
- class YardMap
5
- class Mapper
6
- module ToConstant
7
- extend YardMap::Helpers
8
-
9
- # @param code_object [YARD::CodeObjects::Base]
10
- # @param closure [Pin::Closure, nil]
11
- # @param spec [Gem::Specification, nil]
12
- # @return [Pin::Constant]
13
- def self.make code_object, closure = nil, spec = nil
14
- closure ||= create_closure_namespace_for(code_object, spec)
15
-
16
- Pin::Constant.new(
17
- location: object_location(code_object, spec),
18
- closure: closure,
19
- name: code_object.name.to_s,
20
- comments: code_object.docstring ? code_object.docstring.all.to_s : '',
21
- visibility: code_object.visibility,
22
- source: :yardoc
23
- )
24
- end
25
- end
26
- end
27
- end
28
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Solargraph
4
+ class YardMap
5
+ class Mapper
6
+ module ToConstant
7
+ extend YardMap::Helpers
8
+
9
+ # @param code_object [YARD::CodeObjects::Base]
10
+ # @param closure [Pin::Closure, nil]
11
+ # @param spec [Gem::Specification, nil]
12
+ # @return [Pin::Constant]
13
+ def self.make code_object, closure = nil, spec = nil
14
+ closure ||= create_closure_namespace_for(code_object, spec)
15
+
16
+ Pin::Constant.new(
17
+ location: object_location(code_object, spec),
18
+ closure: closure,
19
+ name: code_object.name.to_s,
20
+ comments: code_object.docstring ? code_object.docstring.all.to_s : '',
21
+ visibility: code_object.visibility,
22
+ source: :yardoc
23
+ )
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -32,7 +32,7 @@ module Solargraph
32
32
  # @sg-ignore Need to add nil check here
33
33
  final_visibility ||= VISIBILITY_OVERRIDE[[closure.path, final_scope]]
34
34
  # @sg-ignore Need to add nil check here
35
- if closure.path == 'Kernel' && Kernel.private_instance_methods(false).include?(name.to_sym)
35
+ if closure.path == 'Kernel' && Kernel.private_method_defined?(name.to_sym, false)
36
36
  final_visibility ||= :private
37
37
  end
38
38
  final_visibility ||= visibility
data/lib/solargraph.rb CHANGED
@@ -113,13 +113,13 @@ module Solargraph
113
113
  # @yieldreturn [generic<T>]
114
114
  # @sg-ignore dynamic call, but both functions behave the same
115
115
  # @return [generic<T>]
116
- def self.with_clean_env &block
116
+ def self.with_clean_env(&)
117
117
  meth = if Bundler.respond_to?(:with_original_env)
118
118
  :with_original_env
119
119
  else
120
120
  :with_clean_env
121
121
  end
122
- Bundler.send meth, &block
122
+ Bundler.send(meth, &)
123
123
  end
124
124
  end
125
125
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solargraph
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.59.0
4
+ version: 0.59.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fred Snyder
@@ -804,7 +804,6 @@ files:
804
804
  - rbs/fills/rubygems/0/errors.rbs
805
805
  - rbs/fills/rubygems/0/spec_fetcher.rbs
806
806
  - rbs/fills/rubygems/0/specification.rbs
807
- - rbs/fills/tuple/tuple.rbs
808
807
  - rbs/shims/ast/0/node.rbs
809
808
  - rbs/shims/ast/2.4/.rbs_meta.yaml
810
809
  - rbs/shims/ast/2.4/ast.rbs
@@ -1,177 +0,0 @@
1
- # <-- liberally borrowed from
2
- # https://github.com/ruby/rbs/blob/master/core/array.rbs, which
3
- # was generated from
4
- # https://github.com/ruby/ruby/blob/master/array.c
5
- # -->
6
- module Solargraph
7
- module Fills
8
- class Tuple[unchecked out A,
9
- unchecked out B = A,
10
- unchecked out C = A | B,
11
- unchecked out D = A | B | C,
12
- unchecked out E = A | B | C | D,
13
- unchecked out F = A | B | C | D | E,
14
- unchecked out G = A | B | C | D | E | F,
15
- unchecked out H = A | B | C | D | E | F | G,
16
- unchecked out I = A | B | C | D | E | F | G | H,
17
- unchecked out J = A | B | C | D | E | F | G | H | I] < Array[A | B | C | D | E | F | G | H | I | J]
18
- # <!--
19
- # rdoc-file=array.c
20
- # - self[index] -> object or nil
21
- # -->
22
- # Returns elements from `self`; does not modify `self`.
23
- #
24
- # In brief:
25
- #
26
- # a = [:foo, 'bar', 2]
27
- #
28
- # # Single argument index: returns one element.
29
- # a[0] # => :foo # Zero-based index.
30
- #
31
- # When a single integer argument `index` is given, returns the element at offset
32
- # `index`:
33
- #
34
- # a = [:foo, 'bar', 2]
35
- # a[0] # => :foo
36
- # a[2] # => 2
37
- # a # => [:foo, "bar", 2]
38
- def []: (0 index) -> A
39
- | (1 index) -> B
40
- | (2 index) -> C
41
- | (3 index) -> D
42
- | (4 index) -> E
43
- | (5 index) -> F
44
- | (6 index) -> G
45
- | (7 index) -> H
46
- | (8 index) -> I
47
- | (9 index) -> J
48
- | (int index) -> nil
49
-
50
- # <!--
51
- # rdoc-file=array.c
52
- # - at(index) -> object or nil
53
- # -->
54
- # Returns the element of `self` specified by the given `index` or `nil` if there
55
- # is no such element; `index` must be an [integer-convertible
56
- # object](rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects).
57
- #
58
- # For non-negative `index`, returns the element of `self` at offset `index`:
59
- #
60
- # a = [:foo, 'bar', 2]
61
- # a.at(0) # => :foo
62
- # a.at(2) # => 2
63
- # a.at(2.0) # => 2
64
- #
65
- # Related: Array#[]; see also [Methods for
66
- # Fetching](rdoc-ref:Array@Methods+for+Fetching).
67
- #
68
- def at: (0 index) -> A
69
- | (1 index) -> B
70
- | (2 index) -> C
71
- | (3 index) -> D
72
- | (4 index) -> E
73
- | (5 index) -> F
74
- | (6 index) -> G
75
- | (7 index) -> H
76
- | (8 index) -> I
77
- | (9 index) -> J
78
- | (int index) -> nil
79
-
80
- # <!--
81
- # rdoc-file=array.c
82
- # - fetch(index) -> element
83
- # - fetch(index, default_value) -> element or default_value
84
- # - fetch(index) {|index| ... } -> element or block_return_value
85
- # -->
86
- # Returns the element of `self` at offset `index` if `index` is in range;
87
- # `index` must be an [integer-convertible
88
- # object](rdoc-ref:implicit_conversion.rdoc@Integer-Convertible+Objects).
89
- #
90
- # With the single argument `index` and no block, returns the element at offset
91
- # `index`:
92
- #
93
- # a = [:foo, 'bar', 2]
94
- # a.fetch(1) # => "bar"
95
- # a.fetch(1.1) # => "bar"
96
- #
97
- # With arguments `index` and `default_value` (which may be any object) and no
98
- # block, returns `default_value` if `index` is out-of-range:
99
- #
100
- # a = [:foo, 'bar', 2]
101
- # a.fetch(1, nil) # => "bar"
102
- # a.fetch(3, :foo) # => :foo
103
- #
104
- # With argument `index` and a block, returns the element at offset `index` if
105
- # index is in range (and the block is not called); otherwise calls the block
106
- # with index and returns its return value:
107
- #
108
- # a = [:foo, 'bar', 2]
109
- # a.fetch(1) {|index| raise 'Cannot happen' } # => "bar"
110
- # a.fetch(50) {|index| "Value for #{index}" } # => "Value for 50"
111
- #
112
- # Related: see [Methods for Fetching](rdoc-ref:Array@Methods+for+Fetching).
113
- #
114
- def fetch: (0 index) -> A
115
- | (1 index) -> B
116
- | (2 index) -> C
117
- | (3 index) -> D
118
- | (4 index) -> E
119
- | (5 index) -> F
120
- | (6 index) -> G
121
- | (7 index) -> H
122
- | (8 index) -> I
123
- | (9 index) -> J
124
- | (int index) -> void
125
- | [T] (0 index, T default) -> (A | T)
126
- | [T] (1 index, T default) -> (B | T)
127
- | [T] (2 index, T default) -> (C | T)
128
- | [T] (3 index, T default) -> (D | T)
129
- | [T] (4 index, T default) -> (E | T)
130
- | [T] (5 index, T default) -> (F | T)
131
- | [T] (6 index, T default) -> (G | T)
132
- | [T] (7 index, T default) -> (H | T)
133
- | [T] (8 index, T default) -> (I | T)
134
- | [T] (9 index, T default) -> (J | T)
135
- | [T] (int index, T default) -> (A | B | C | D | E | F | G | H | I | J | T)
136
- | [T] (0 index) { (int index) -> T } -> (A | T)
137
- | [T] (1 index) { (int index) -> T } -> (B | T)
138
- | [T] (2 index) { (int index) -> T } -> (C | T)
139
- | [T] (3 index) { (int index) -> T } -> (D | T)
140
- | [T] (4 index) { (int index) -> T } -> (E | T)
141
- | [T] (5 index) { (int index) -> T } -> (F | T)
142
- | [T] (6 index) { (int index) -> T } -> (G | T)
143
- | [T] (7 index) { (int index) -> T } -> (H | T)
144
- | [T] (8 index) { (int index) -> T } -> (I | T)
145
- | [T] (9 index) { (int index) -> T } -> (J | T)
146
- | [T] (int index) { (int index) -> T } -> (A | B | C | D | E | F | G | H | I | J | T)
147
-
148
- # <!--
149
- # rdoc-file=array.rb
150
- # - first -> object or nil
151
- # - first(count) -> new_array
152
- # -->
153
- # Returns elements from `self`, or `nil`; does not modify `self`.
154
- #
155
- # With no argument given, returns the first element (if available):
156
- #
157
- # a = [:foo, 'bar', 2]
158
- # a.first # => :foo
159
- # a # => [:foo, "bar", 2]
160
- #
161
- # If `self` is empty, returns `nil`.
162
- #
163
- # [].first # => nil
164
- #
165
- # With a non-negative integer argument `count` given, returns the first `count`
166
- # elements (as available) in a new array:
167
- #
168
- # a.first(0) # => []
169
- # a.first(2) # => [:foo, "bar"]
170
- # a.first(50) # => [:foo, "bar", 2]
171
- #
172
- # Related: see [Methods for Querying](rdoc-ref:Array@Methods+for+Querying).
173
- #
174
- def first: %a{implicitly-returns-nil} () -> A
175
- end
176
- end
177
- end