solargraph 0.39.0 → 0.40.0
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.
- checksums.yaml +4 -4
- data/.travis.yml +2 -7
- data/CHANGELOG.md +984 -0
- data/Rakefile +12 -1
- data/SPONSORS.md +6 -0
- data/lib/.rubocop.yml +21 -0
- data/lib/solargraph/api_map/cache.rb +4 -0
- data/lib/solargraph/api_map/store.rb +35 -51
- data/lib/solargraph/api_map.rb +94 -87
- data/lib/solargraph/{bundle.rb → bench.rb} +6 -2
- data/lib/solargraph/compat.rb +23 -0
- data/lib/solargraph/complex_type.rb +2 -2
- data/lib/solargraph/convention/base.rb +16 -8
- data/lib/solargraph/convention/gemfile.rb +2 -5
- data/lib/solargraph/convention/gemspec.rb +3 -6
- data/lib/solargraph/convention/rspec.rb +3 -6
- data/lib/solargraph/convention.rb +14 -5
- data/lib/solargraph/diagnostics/rubocop.rb +2 -1
- data/lib/solargraph/diagnostics/rubocop_helpers.rb +4 -1
- data/lib/solargraph/documentor.rb +4 -0
- data/lib/solargraph/environ.rb +11 -6
- data/lib/solargraph/language_server/host.rb +1 -1
- data/lib/solargraph/language_server/message/extended/check_gem_version.rb +6 -1
- data/lib/solargraph/language_server/message/text_document/definition.rb +1 -1
- data/lib/solargraph/language_server/message/text_document/formatting.rb +7 -3
- data/lib/solargraph/language_server/uri_helpers.rb +23 -3
- data/lib/solargraph/library.rb +22 -8
- data/lib/solargraph/parser/legacy/class_methods.rb +4 -0
- data/lib/solargraph/parser/legacy/node_chainer.rb +10 -7
- data/lib/solargraph/parser/legacy/node_methods.rb +16 -3
- data/lib/solargraph/parser/legacy/node_processors/ivasgn_node.rb +1 -1
- data/lib/solargraph/parser/legacy/node_processors/send_node.rb +48 -23
- data/lib/solargraph/parser/node_processor/base.rb +3 -0
- data/lib/solargraph/parser/rubyvm/class_methods.rb +6 -2
- data/lib/solargraph/parser/rubyvm/node_chainer.rb +11 -9
- data/lib/solargraph/parser/rubyvm/node_methods.rb +6 -1
- data/lib/solargraph/parser/rubyvm/node_processors/args_node.rb +35 -11
- data/lib/solargraph/parser/rubyvm/node_processors/ivasgn_node.rb +1 -1
- data/lib/solargraph/parser/rubyvm/node_processors/kw_arg_node.rb +6 -1
- data/lib/solargraph/parser/rubyvm/node_processors/opt_arg_node.rb +6 -1
- data/lib/solargraph/parser/rubyvm/node_processors/send_node.rb +52 -67
- data/lib/solargraph/parser/rubyvm/node_processors.rb +2 -0
- data/lib/solargraph/pin/base.rb +2 -2
- data/lib/solargraph/pin/base_variable.rb +1 -1
- data/lib/solargraph/pin/block.rb +28 -14
- data/lib/solargraph/pin/closure.rb +1 -1
- data/lib/solargraph/pin/common.rb +1 -1
- data/lib/solargraph/pin/constant.rb +1 -1
- data/lib/solargraph/pin/conversions.rb +3 -4
- data/lib/solargraph/pin/documenting.rb +6 -11
- data/lib/solargraph/pin/local_variable.rb +1 -1
- data/lib/solargraph/pin/method.rb +143 -9
- data/lib/solargraph/pin/method_alias.rb +2 -2
- data/lib/solargraph/pin/namespace.rb +1 -1
- data/lib/solargraph/pin/parameter.rb +2 -2
- data/lib/solargraph/pin/proxy_type.rb +1 -1
- data/lib/solargraph/pin.rb +0 -3
- data/lib/solargraph/position.rb +2 -14
- data/lib/solargraph/shell.rb +2 -1
- data/lib/solargraph/source/chain/call.rb +9 -0
- data/lib/solargraph/source/chain/head.rb +14 -8
- data/lib/solargraph/source/chain/z_super.rb +30 -0
- data/lib/solargraph/source/chain.rb +19 -36
- data/lib/solargraph/source/source_chainer.rb +2 -1
- data/lib/solargraph/source.rb +24 -9
- data/lib/solargraph/source_map/clip.rb +78 -44
- data/lib/solargraph/source_map/mapper.rb +41 -21
- data/lib/solargraph/source_map.rb +20 -2
- data/lib/solargraph/type_checker/param_def.rb +1 -1
- data/lib/solargraph/type_checker.rb +61 -42
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/views/_name_type_tag.erb +1 -1
- data/lib/solargraph/workspace.rb +1 -1
- data/lib/solargraph/yard_map/core_fills.rb +185 -0
- data/lib/solargraph/yard_map/helpers.rb +16 -0
- data/lib/solargraph/{pin/yard_pin/constant.rb → yard_map/mapper/to_constant.rb} +6 -6
- data/lib/solargraph/yard_map/mapper/to_method.rb +78 -0
- data/lib/solargraph/{pin/yard_pin/namespace.rb → yard_map/mapper/to_namespace.rb} +6 -6
- data/lib/solargraph/yard_map/mapper.rb +17 -8
- data/lib/solargraph/yard_map/rdoc_to_yard.rb +26 -15
- data/lib/solargraph/yard_map/stdlib_fills.rb +43 -0
- data/lib/solargraph/yard_map/to_method.rb +79 -0
- data/lib/solargraph/yard_map.rb +140 -92
- data/lib/solargraph.rb +5 -4
- data/solargraph.gemspec +5 -5
- data/yardoc/2.2.2.tar.gz +0 -0
- metadata +29 -41
- data/.rubocop.yml +0 -6
- data/lib/solargraph/core_fills.rb +0 -159
- data/lib/solargraph/pin/attribute.rb +0 -49
- data/lib/solargraph/pin/base_method.rb +0 -141
- data/lib/solargraph/pin/yard_pin/method.rb +0 -65
- data/lib/solargraph/pin/yard_pin/yard_mixin.rb +0 -26
- data/lib/solargraph/pin/yard_pin.rb +0 -12
- data/lib/solargraph/stdlib_fills.rb +0 -32
- data/travis-bundler.rb +0 -11
data/lib/solargraph/pin/block.rb
CHANGED
|
@@ -9,22 +9,19 @@ module Solargraph
|
|
|
9
9
|
attr_reader :receiver
|
|
10
10
|
|
|
11
11
|
def initialize receiver: nil, args: [], **splat
|
|
12
|
-
super(splat)
|
|
12
|
+
super(**splat)
|
|
13
13
|
@receiver = receiver
|
|
14
14
|
@parameters = args
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
def rebound?
|
|
23
|
-
@rebound ||= false
|
|
17
|
+
# @param api_map [ApiMap]
|
|
18
|
+
# @return [void]
|
|
19
|
+
def rebind api_map
|
|
20
|
+
@binder ||= binder_or_nil(api_map)
|
|
24
21
|
end
|
|
25
22
|
|
|
26
23
|
def binder
|
|
27
|
-
@binder ||
|
|
24
|
+
@binder || closure.binder
|
|
28
25
|
end
|
|
29
26
|
|
|
30
27
|
# @return [Array<String>]
|
|
@@ -37,11 +34,28 @@ module Solargraph
|
|
|
37
34
|
@parameter_names ||= parameters.map(&:name)
|
|
38
35
|
end
|
|
39
36
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
private
|
|
38
|
+
|
|
39
|
+
# @param api_map [ApiMap]
|
|
40
|
+
# @return [ComplexType, nil]
|
|
41
|
+
def binder_or_nil api_map
|
|
42
|
+
return nil unless receiver
|
|
43
|
+
word = receiver.children.find { |c| c.is_a?(::Symbol) }.to_s
|
|
44
|
+
return nil unless api_map.rebindable_method_names.include?(word)
|
|
45
|
+
chain = Parser.chain(receiver, location.filename)
|
|
46
|
+
locals = api_map.source_map(location.filename).locals_at(location)
|
|
47
|
+
if ['instance_eval', 'instance_exec', 'class_eval', 'class_exec', 'module_eval', 'module_exec'].include?(chain.links.last.word)
|
|
48
|
+
return chain.base.infer(api_map, self, locals)
|
|
49
|
+
else
|
|
50
|
+
receiver_pin = chain.define(api_map, self, locals).first
|
|
51
|
+
if receiver_pin && receiver_pin.docstring
|
|
52
|
+
ys = receiver_pin.docstring.tag(:yieldself)
|
|
53
|
+
if ys && ys.types && !ys.types.empty?
|
|
54
|
+
return ComplexType.try_parse(*ys.types).qualify(api_map, receiver_pin.context.namespace)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
nil
|
|
45
59
|
end
|
|
46
60
|
end
|
|
47
61
|
end
|
|
@@ -54,7 +54,7 @@ module Solargraph
|
|
|
54
54
|
until here.nil?
|
|
55
55
|
if here.is_a?(Pin::Namespace)
|
|
56
56
|
return here.return_type
|
|
57
|
-
elsif here.is_a?(Pin::
|
|
57
|
+
elsif here.is_a?(Pin::Method)
|
|
58
58
|
if here.scope == :instance
|
|
59
59
|
return ComplexType.try_parse(here.context.namespace)
|
|
60
60
|
else
|
|
@@ -23,16 +23,15 @@ module Solargraph
|
|
|
23
23
|
|
|
24
24
|
# @return [Hash]
|
|
25
25
|
def resolve_completion_item
|
|
26
|
-
|
|
26
|
+
@resolve_completion_item ||= begin
|
|
27
27
|
extra = {}
|
|
28
28
|
alldoc = ''
|
|
29
29
|
# alldoc += link_documentation unless link_documentation.nil?
|
|
30
30
|
# alldoc += "\n\n" unless alldoc.empty?
|
|
31
31
|
alldoc += documentation unless documentation.nil?
|
|
32
32
|
extra[:documentation] = alldoc unless alldoc.empty?
|
|
33
|
-
|
|
33
|
+
completion_item.merge(extra)
|
|
34
34
|
end
|
|
35
|
-
@resolve_completion_item
|
|
36
35
|
end
|
|
37
36
|
|
|
38
37
|
# @return [Hash]
|
|
@@ -48,7 +47,7 @@ module Solargraph
|
|
|
48
47
|
# This property is not cached in an instance variable because it can
|
|
49
48
|
# change when pins get proxied.
|
|
50
49
|
detail = String.new
|
|
51
|
-
detail += "(#{parameters.map(&:full).join(', ')}) " unless !is_a?(Pin::
|
|
50
|
+
detail += "(#{parameters.map(&:full).join(', ')}) " unless !is_a?(Pin::Method) || parameters.empty?
|
|
52
51
|
detail += "=#{probed? ? '~' : (proxied? ? '^' : '>')} #{return_type.to_s}" unless return_type.undefined?
|
|
53
52
|
detail.strip!
|
|
54
53
|
return nil if detail.empty?
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require '
|
|
3
|
+
require 'kramdown'
|
|
4
|
+
require 'kramdown-parser-gfm'
|
|
4
5
|
require 'yard'
|
|
5
6
|
require 'reverse_markdown'
|
|
6
7
|
require 'solargraph/converters/dl'
|
|
@@ -8,9 +9,6 @@ require 'solargraph/converters/dt'
|
|
|
8
9
|
require 'solargraph/converters/dd'
|
|
9
10
|
require 'solargraph/converters/misc'
|
|
10
11
|
|
|
11
|
-
# HACK: Setting :html_parser through `Maruku.new` does not work
|
|
12
|
-
MaRuKu::Globals[:html_parser] = 'nokogiri'
|
|
13
|
-
|
|
14
12
|
module Solargraph
|
|
15
13
|
module Pin
|
|
16
14
|
# A module to add the Pin::Base#documentation method.
|
|
@@ -41,11 +39,7 @@ module Solargraph
|
|
|
41
39
|
|
|
42
40
|
def to_s
|
|
43
41
|
return "\n```ruby\n#{@plaintext}#{@plaintext.end_with?("\n") ? '' : "\n"}```\n\n" if code?
|
|
44
|
-
ReverseMarkdown.convert unescape_brackets(
|
|
45
|
-
rescue MaRuKu::Exception
|
|
46
|
-
# Maruku exceptions usually indicate that the documentation is in
|
|
47
|
-
# RDoc syntax.
|
|
48
|
-
ReverseMarkdown.convert YARD::Templates::Helpers::Markup::RDocMarkup.new(@plaintext).to_html
|
|
42
|
+
ReverseMarkdown.convert unescape_brackets(Kramdown::Document.new(escape_brackets(@plaintext), input: 'GFM').to_html)
|
|
49
43
|
end
|
|
50
44
|
|
|
51
45
|
private
|
|
@@ -53,13 +47,14 @@ module Solargraph
|
|
|
53
47
|
# @param text [String]
|
|
54
48
|
# @return [String]
|
|
55
49
|
def escape_brackets text
|
|
56
|
-
text.gsub(/(\[[^\]]*\])([^\(]|\z)/, '
|
|
50
|
+
# text.gsub(/(\[[^\]]*\])([^\(]|\z)/, '!!!^\1^!!!\2')
|
|
51
|
+
text.gsub('[', '!!!!b').gsub(']', 'e!!!!')
|
|
57
52
|
end
|
|
58
53
|
|
|
59
54
|
# @param text [String]
|
|
60
55
|
# @return [String]
|
|
61
56
|
def unescape_brackets text
|
|
62
|
-
text.gsub('
|
|
57
|
+
text.gsub('!!!!b', '[').gsub('e!!!!', ']')
|
|
63
58
|
end
|
|
64
59
|
end
|
|
65
60
|
|
|
@@ -2,18 +2,29 @@
|
|
|
2
2
|
|
|
3
3
|
module Solargraph
|
|
4
4
|
module Pin
|
|
5
|
-
class
|
|
5
|
+
# The base class for method and attribute pins.
|
|
6
|
+
#
|
|
7
|
+
class Method < Closure
|
|
6
8
|
include Solargraph::Parser::NodeMethods
|
|
7
9
|
|
|
8
|
-
# @return [Array<
|
|
10
|
+
# @return [Array<Pin::Parameter>]
|
|
9
11
|
attr_reader :parameters
|
|
10
12
|
|
|
11
|
-
# @
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
# @return [::Symbol] :public, :private, or :protected
|
|
14
|
+
attr_reader :visibility
|
|
15
|
+
|
|
16
|
+
# @return [Parser::AST::Node]
|
|
17
|
+
attr_reader :node
|
|
18
|
+
|
|
19
|
+
# @param visibility [::Symbol] :public, :protected, or :private
|
|
20
|
+
# @param explicit [Boolean]
|
|
21
|
+
def initialize visibility: :public, explicit: true, parameters: [], node: nil, attribute: false, **splat
|
|
22
|
+
super(**splat)
|
|
23
|
+
@visibility = visibility
|
|
24
|
+
@explicit = explicit
|
|
15
25
|
@parameters = parameters
|
|
16
26
|
@node = node
|
|
27
|
+
@attribute = attribute
|
|
17
28
|
end
|
|
18
29
|
|
|
19
30
|
# @return [Array<String>]
|
|
@@ -22,11 +33,70 @@ module Solargraph
|
|
|
22
33
|
end
|
|
23
34
|
|
|
24
35
|
def completion_item_kind
|
|
25
|
-
Solargraph::LanguageServer::CompletionItemKinds::METHOD
|
|
36
|
+
attribute? ? Solargraph::LanguageServer::CompletionItemKinds::PROPERTY : Solargraph::LanguageServer::CompletionItemKinds::METHOD
|
|
26
37
|
end
|
|
27
38
|
|
|
28
39
|
def symbol_kind
|
|
29
|
-
LanguageServer::SymbolKinds::METHOD
|
|
40
|
+
attribute? ? Solargraph::LanguageServer::SymbolKinds::PROPERTY : LanguageServer::SymbolKinds::METHOD
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def return_type
|
|
44
|
+
@return_type ||= generate_complex_type
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def path
|
|
48
|
+
@path ||= "#{namespace}#{(scope == :instance ? '#' : '.')}#{name}"
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def typify api_map
|
|
52
|
+
decl = super
|
|
53
|
+
return decl unless decl.undefined?
|
|
54
|
+
type = see_reference(api_map) || typify_from_super(api_map)
|
|
55
|
+
return type.qualify(api_map, namespace) unless type.nil?
|
|
56
|
+
name.end_with?('?') ? ComplexType::BOOLEAN : ComplexType::UNDEFINED
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def documentation
|
|
60
|
+
if @documentation.nil?
|
|
61
|
+
@documentation ||= super || ''
|
|
62
|
+
param_tags = docstring.tags(:param)
|
|
63
|
+
unless param_tags.nil? or param_tags.empty?
|
|
64
|
+
@documentation += "\n\n" unless @documentation.empty?
|
|
65
|
+
@documentation += "Params:\n"
|
|
66
|
+
lines = []
|
|
67
|
+
param_tags.each do |p|
|
|
68
|
+
l = "* #{p.name}"
|
|
69
|
+
l += " [#{escape_brackets(p.types.join(', '))}]" unless p.types.nil? or p.types.empty?
|
|
70
|
+
l += " #{p.text}"
|
|
71
|
+
lines.push l
|
|
72
|
+
end
|
|
73
|
+
@documentation += lines.join("\n")
|
|
74
|
+
end
|
|
75
|
+
return_tags = docstring.tags(:return)
|
|
76
|
+
unless return_tags.empty?
|
|
77
|
+
@documentation += "\n\n" unless @documentation.empty?
|
|
78
|
+
@documentation += "Returns:\n"
|
|
79
|
+
lines = []
|
|
80
|
+
return_tags.each do |r|
|
|
81
|
+
l = "*"
|
|
82
|
+
l += " [#{escape_brackets(r.types.join(', '))}]" unless r.types.nil? or r.types.empty?
|
|
83
|
+
l += " #{r.text}"
|
|
84
|
+
lines.push l
|
|
85
|
+
end
|
|
86
|
+
@documentation += lines.join("\n")
|
|
87
|
+
end
|
|
88
|
+
@documentation += "\n\n" unless @documentation.empty?
|
|
89
|
+
@documentation += "Visibility: #{visibility}"
|
|
90
|
+
end
|
|
91
|
+
@documentation.to_s
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
def explicit?
|
|
95
|
+
@explicit
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def attribute?
|
|
99
|
+
@attribute
|
|
30
100
|
end
|
|
31
101
|
|
|
32
102
|
def nearly? other
|
|
@@ -37,7 +107,7 @@ module Solargraph
|
|
|
37
107
|
end
|
|
38
108
|
|
|
39
109
|
def probe api_map
|
|
40
|
-
infer_from_return_nodes(api_map)
|
|
110
|
+
attribute? ? infer_from_iv(api_map) : infer_from_return_nodes(api_map)
|
|
41
111
|
end
|
|
42
112
|
|
|
43
113
|
def try_merge! pin
|
|
@@ -70,6 +140,57 @@ module Solargraph
|
|
|
70
140
|
|
|
71
141
|
private
|
|
72
142
|
|
|
143
|
+
# @return [ComplexType]
|
|
144
|
+
def generate_complex_type
|
|
145
|
+
tags = docstring.tags(:return).map(&:types).flatten.reject(&:nil?)
|
|
146
|
+
return ComplexType::UNDEFINED if tags.empty?
|
|
147
|
+
ComplexType.try_parse *tags
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
# @param api_map [ApiMap]
|
|
151
|
+
# @return [ComplexType, nil]
|
|
152
|
+
def see_reference api_map
|
|
153
|
+
docstring.ref_tags.each do |ref|
|
|
154
|
+
next unless ref.tag_name == 'return' && ref.owner
|
|
155
|
+
result = resolve_reference(ref.owner.to_s, api_map)
|
|
156
|
+
return result unless result.nil?
|
|
157
|
+
end
|
|
158
|
+
match = comments.match(/^[ \t]*\(see (.*)\)/m)
|
|
159
|
+
return nil if match.nil?
|
|
160
|
+
resolve_reference match[1], api_map
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
# @param api_map [ApiMap]
|
|
164
|
+
# @return [ComplexType, nil]
|
|
165
|
+
def typify_from_super api_map
|
|
166
|
+
stack = api_map.get_method_stack(namespace, name, scope: scope).reject { |pin| pin.path == path }
|
|
167
|
+
return nil if stack.empty?
|
|
168
|
+
stack.each do |pin|
|
|
169
|
+
return pin.return_type unless pin.return_type.undefined?
|
|
170
|
+
end
|
|
171
|
+
nil
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
# @param ref [String]
|
|
175
|
+
# @param api_map [ApiMap]
|
|
176
|
+
# @return [ComplexType]
|
|
177
|
+
def resolve_reference ref, api_map
|
|
178
|
+
parts = ref.split(/[\.#]/)
|
|
179
|
+
if parts.first.empty? || parts.one?
|
|
180
|
+
path = "#{namespace}#{ref}"
|
|
181
|
+
else
|
|
182
|
+
fqns = api_map.qualify(parts.first, namespace)
|
|
183
|
+
return ComplexType::UNDEFINED if fqns.nil?
|
|
184
|
+
path = fqns + ref[parts.first.length] + parts.last
|
|
185
|
+
end
|
|
186
|
+
pins = api_map.get_path_pins(path)
|
|
187
|
+
pins.each do |pin|
|
|
188
|
+
type = pin.typify(api_map)
|
|
189
|
+
return type unless type.undefined?
|
|
190
|
+
end
|
|
191
|
+
nil
|
|
192
|
+
end
|
|
193
|
+
|
|
73
194
|
# @return [Parser::AST::Node, nil]
|
|
74
195
|
def method_body_node
|
|
75
196
|
return nil if node.nil?
|
|
@@ -106,6 +227,19 @@ module Solargraph
|
|
|
106
227
|
return ComplexType::UNDEFINED if result.empty?
|
|
107
228
|
ComplexType.try_parse(*result.map(&:tag).uniq)
|
|
108
229
|
end
|
|
230
|
+
|
|
231
|
+
def infer_from_iv api_map
|
|
232
|
+
types = []
|
|
233
|
+
varname = "@#{name.gsub(/=$/, '')}"
|
|
234
|
+
pins = api_map.get_instance_variable_pins(binder.namespace, binder.scope).select { |iv| iv.name == varname }
|
|
235
|
+
pins.each do |pin|
|
|
236
|
+
type = pin.typify(api_map)
|
|
237
|
+
type = pin.probe(api_map) if type.undefined?
|
|
238
|
+
types.push type if type.defined?
|
|
239
|
+
end
|
|
240
|
+
return ComplexType::UNDEFINED if types.empty?
|
|
241
|
+
ComplexType.try_parse(*types.map(&:tag).uniq)
|
|
242
|
+
end
|
|
109
243
|
end
|
|
110
244
|
end
|
|
111
245
|
end
|
|
@@ -6,7 +6,7 @@ module Solargraph
|
|
|
6
6
|
# examples that defer mapping are aliases for superclass methods or
|
|
7
7
|
# methods from included modules.
|
|
8
8
|
#
|
|
9
|
-
class MethodAlias <
|
|
9
|
+
class MethodAlias < Method
|
|
10
10
|
# @return [::Symbol]
|
|
11
11
|
attr_reader :scope
|
|
12
12
|
|
|
@@ -14,7 +14,7 @@ module Solargraph
|
|
|
14
14
|
attr_reader :original
|
|
15
15
|
|
|
16
16
|
def initialize scope: :instance, original: nil, **splat
|
|
17
|
-
super(splat)
|
|
17
|
+
super(**splat)
|
|
18
18
|
@scope = scope
|
|
19
19
|
@original = original
|
|
20
20
|
end
|
|
@@ -14,7 +14,7 @@ module Solargraph
|
|
|
14
14
|
# @param gates [Array<String>]
|
|
15
15
|
def initialize type: :class, visibility: :public, gates: [''], **splat
|
|
16
16
|
# super(location, namespace, name, comments)
|
|
17
|
-
super(splat)
|
|
17
|
+
super(**splat)
|
|
18
18
|
@type = type
|
|
19
19
|
@visibility = visibility
|
|
20
20
|
if name.start_with?('::')
|
|
@@ -8,7 +8,7 @@ module Solargraph
|
|
|
8
8
|
attr_reader :asgn_code
|
|
9
9
|
|
|
10
10
|
def initialize decl: :arg, asgn_code: nil, **splat
|
|
11
|
-
super(splat)
|
|
11
|
+
super(**splat)
|
|
12
12
|
@asgn_code = asgn_code
|
|
13
13
|
@decl = decl
|
|
14
14
|
end
|
|
@@ -41,7 +41,7 @@ module Solargraph
|
|
|
41
41
|
"*#{name}"
|
|
42
42
|
when :kwrestarg
|
|
43
43
|
"**#{name}"
|
|
44
|
-
when :block
|
|
44
|
+
when :block, :blockarg
|
|
45
45
|
"&#{name}"
|
|
46
46
|
else
|
|
47
47
|
name
|
data/lib/solargraph/pin.rb
CHANGED
|
@@ -9,10 +9,8 @@ module Solargraph
|
|
|
9
9
|
autoload :Common, 'solargraph/pin/common'
|
|
10
10
|
autoload :Conversions, 'solargraph/pin/conversions'
|
|
11
11
|
autoload :Base, 'solargraph/pin/base'
|
|
12
|
-
autoload :BaseMethod, 'solargraph/pin/base_method'
|
|
13
12
|
autoload :Method, 'solargraph/pin/method'
|
|
14
13
|
autoload :MethodAlias, 'solargraph/pin/method_alias'
|
|
15
|
-
autoload :Attribute, 'solargraph/pin/attribute'
|
|
16
14
|
autoload :BaseVariable, 'solargraph/pin/base_variable'
|
|
17
15
|
autoload :InstanceVariable, 'solargraph/pin/instance_variable'
|
|
18
16
|
autoload :ClassVariable, 'solargraph/pin/class_variable'
|
|
@@ -30,7 +28,6 @@ module Solargraph
|
|
|
30
28
|
autoload :Localized, 'solargraph/pin/localized'
|
|
31
29
|
autoload :ProxyType, 'solargraph/pin/proxy_type'
|
|
32
30
|
autoload :DuckMethod, 'solargraph/pin/duck_method'
|
|
33
|
-
autoload :YardPin, 'solargraph/pin/yard_pin'
|
|
34
31
|
autoload :Singleton, 'solargraph/pin/singleton'
|
|
35
32
|
autoload :KeywordParam, 'solargraph/pin/keyword_param'
|
|
36
33
|
|
data/lib/solargraph/position.rb
CHANGED
|
@@ -40,20 +40,8 @@ module Solargraph
|
|
|
40
40
|
# @param position [Position]
|
|
41
41
|
# @return [Integer]
|
|
42
42
|
def self.to_offset text, position
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
line = position.line
|
|
46
|
-
column = position.character
|
|
47
|
-
text.lines.each do |l|
|
|
48
|
-
line_length = l.length
|
|
49
|
-
if feed == line
|
|
50
|
-
result += column
|
|
51
|
-
break
|
|
52
|
-
end
|
|
53
|
-
result += line_length
|
|
54
|
-
feed += 1
|
|
55
|
-
end
|
|
56
|
-
result
|
|
43
|
+
return 0 if text.empty?
|
|
44
|
+
text.lines[0...position.line].sum(&:length) + position.character
|
|
57
45
|
end
|
|
58
46
|
|
|
59
47
|
# Get a numeric offset for the specified text and a position identified
|
data/lib/solargraph/shell.rb
CHANGED
|
@@ -153,6 +153,7 @@ module Solargraph
|
|
|
153
153
|
probcount += problems.length
|
|
154
154
|
end
|
|
155
155
|
puts "#{probcount} problem#{probcount != 1 ? 's' : ''} found#{files.length != 1 ? " in #{filecount} of #{files.length} files" : ''}."
|
|
156
|
+
exit 1 if probcount > 0
|
|
156
157
|
end
|
|
157
158
|
|
|
158
159
|
desc 'scan', 'Test the workspace for problems'
|
|
@@ -175,7 +176,7 @@ module Solargraph
|
|
|
175
176
|
puts pin_description(pin) if options[:verbose]
|
|
176
177
|
pin.typify api_map
|
|
177
178
|
pin.probe api_map
|
|
178
|
-
rescue
|
|
179
|
+
rescue StandardError => e
|
|
179
180
|
STDERR.puts "Error testing #{pin_description(pin)} #{pin.location ? "at #{pin.location.filename}:#{pin.location.range.start.line + 1}" : ''}"
|
|
180
181
|
STDERR.puts "[#{e.class}]: #{e.message}"
|
|
181
182
|
STDERR.puts e.backtrace.join("\n")
|
|
@@ -28,6 +28,7 @@ module Solargraph
|
|
|
28
28
|
# @param name_pin [Pin::Base]
|
|
29
29
|
# @param locals [Array<Pin::Base>]
|
|
30
30
|
def resolve api_map, name_pin, locals
|
|
31
|
+
return super_pins(api_map, name_pin) if word == 'super'
|
|
31
32
|
found = if head?
|
|
32
33
|
locals.select { |p| p.name == word }
|
|
33
34
|
else
|
|
@@ -188,6 +189,14 @@ module Solargraph
|
|
|
188
189
|
return false if argcount < parcount && !(argcount == parcount - 1 && parameters.last.first.start_with?('*'))
|
|
189
190
|
true
|
|
190
191
|
end
|
|
192
|
+
|
|
193
|
+
# @param api_map [ApiMap]
|
|
194
|
+
# @param name_pin [Pin::Base]
|
|
195
|
+
# @return [Array<Pin::Base>]
|
|
196
|
+
def super_pins api_map, name_pin
|
|
197
|
+
pins = api_map.get_method_stack(name_pin.namespace, name_pin.name, scope: name_pin.scope)
|
|
198
|
+
pins.reject{|p| p.path == name_pin.path}
|
|
199
|
+
end
|
|
191
200
|
end
|
|
192
201
|
end
|
|
193
202
|
end
|
|
@@ -10,19 +10,25 @@ module Solargraph
|
|
|
10
10
|
class Head < Link
|
|
11
11
|
def resolve api_map, name_pin, locals
|
|
12
12
|
return [Pin::ProxyType.anonymous(name_pin.binder)] if word == 'self'
|
|
13
|
-
return super_pins(api_map, name_pin) if word == 'super'
|
|
13
|
+
# return super_pins(api_map, name_pin) if word == 'super'
|
|
14
14
|
[]
|
|
15
15
|
end
|
|
16
16
|
|
|
17
|
+
# @todo This is temporary. Chain heads need to handle arguments to
|
|
18
|
+
# `super`.
|
|
19
|
+
# def arguments
|
|
20
|
+
# []
|
|
21
|
+
# end
|
|
22
|
+
|
|
17
23
|
private
|
|
18
24
|
|
|
19
|
-
# @param api_map [ApiMap]
|
|
20
|
-
# @param name_pin [Pin::Base]
|
|
21
|
-
# @return [Array<Pin::Base>]
|
|
22
|
-
def super_pins api_map, name_pin
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
end
|
|
25
|
+
# # @param api_map [ApiMap]
|
|
26
|
+
# # @param name_pin [Pin::Base]
|
|
27
|
+
# # @return [Array<Pin::Base>]
|
|
28
|
+
# def super_pins api_map, name_pin
|
|
29
|
+
# pins = api_map.get_method_stack(name_pin.namespace, name_pin.name, scope: name_pin.scope)
|
|
30
|
+
# pins.reject{|p| p.path == name_pin.path}
|
|
31
|
+
# end
|
|
26
32
|
end
|
|
27
33
|
end
|
|
28
34
|
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Solargraph
|
|
4
|
+
class Source
|
|
5
|
+
class Chain
|
|
6
|
+
class ZSuper < Call
|
|
7
|
+
# @return [String]
|
|
8
|
+
attr_reader :word
|
|
9
|
+
|
|
10
|
+
# @return [Array<Chain>]
|
|
11
|
+
attr_reader :arguments
|
|
12
|
+
|
|
13
|
+
# @param word [String]
|
|
14
|
+
# @param arguments [Array<Chain>]
|
|
15
|
+
# @param with_block [Boolean] True if the chain is inside a block
|
|
16
|
+
# @param head [Boolean] True if the call is the start of its chain
|
|
17
|
+
def initialize word, with_block = false
|
|
18
|
+
super(word, [], with_block)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# @param api_map [ApiMap]
|
|
22
|
+
# @param name_pin [Pin::Base]
|
|
23
|
+
# @param locals [Array<Pin::Base>]
|
|
24
|
+
def resolve api_map, name_pin, locals
|
|
25
|
+
return super_pins(api_map, name_pin)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|