solargraph 0.32.5 → 0.33.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/.gitignore +1 -0
- data/README.md +2 -11
- data/lib/solargraph.rb +1 -2
- data/lib/solargraph/api_map.rb +93 -63
- data/lib/solargraph/api_map/cache.rb +16 -1
- data/lib/solargraph/api_map/source_to_yard.rb +16 -7
- data/lib/solargraph/api_map/store.rb +55 -12
- data/lib/solargraph/complex_type.rb +58 -14
- data/lib/solargraph/complex_type/type_methods.rb +2 -2
- data/lib/solargraph/complex_type/unique_type.rb +33 -4
- data/lib/solargraph/core_fills.rb +40 -12
- data/lib/solargraph/diagnostics.rb +4 -3
- data/lib/solargraph/diagnostics/base.rb +6 -0
- data/lib/solargraph/diagnostics/require_not_found.rb +17 -10
- data/lib/solargraph/diagnostics/rubocop_helpers.rb +2 -0
- data/lib/solargraph/diagnostics/type_check.rb +51 -0
- data/lib/solargraph/diagnostics/update_errors.rb +1 -0
- data/lib/solargraph/language_server/host.rb +55 -25
- data/lib/solargraph/language_server/host/diagnoser.rb +1 -2
- data/lib/solargraph/language_server/host/dispatch.rb +4 -8
- data/lib/solargraph/language_server/host/sources.rb +1 -1
- data/lib/solargraph/language_server/message.rb +1 -0
- data/lib/solargraph/language_server/message/completion_item/resolve.rb +4 -2
- data/lib/solargraph/language_server/message/initialize.rb +9 -0
- data/lib/solargraph/language_server/message/initialized.rb +1 -0
- data/lib/solargraph/language_server/message/text_document.rb +1 -0
- data/lib/solargraph/language_server/message/text_document/code_action.rb +15 -0
- data/lib/solargraph/language_server/message/text_document/completion.rb +1 -1
- data/lib/solargraph/language_server/message/text_document/definition.rb +25 -5
- data/lib/solargraph/language_server/message/text_document/hover.rb +1 -1
- data/lib/solargraph/language_server/message/text_document/signature_help.rb +4 -0
- data/lib/solargraph/language_server/message/workspace/did_change_watched_files.rb +8 -4
- data/lib/solargraph/language_server/transport/adapter.rb +12 -15
- data/lib/solargraph/library.rb +23 -6
- data/lib/solargraph/location.rb +4 -0
- data/lib/solargraph/pin.rb +7 -3
- data/lib/solargraph/pin/attribute.rb +14 -13
- data/lib/solargraph/pin/base.rb +56 -43
- data/lib/solargraph/pin/base_method.rb +41 -18
- data/lib/solargraph/pin/base_variable.rb +17 -15
- data/lib/solargraph/pin/block.rb +22 -4
- data/lib/solargraph/pin/closure.rb +28 -0
- data/lib/solargraph/pin/common.rb +59 -0
- data/lib/solargraph/pin/constant.rb +4 -4
- data/lib/solargraph/pin/conversions.rb +8 -8
- data/lib/solargraph/pin/duck_method.rb +3 -3
- data/lib/solargraph/pin/instance_variable.rb +30 -0
- data/lib/solargraph/pin/keyword.rb +1 -1
- data/lib/solargraph/pin/local_variable.rb +3 -3
- data/lib/solargraph/pin/localized.rb +9 -5
- data/lib/solargraph/pin/method.rb +26 -40
- data/lib/solargraph/pin/method_alias.rb +9 -6
- data/lib/solargraph/pin/namespace.rb +33 -10
- data/lib/solargraph/pin/parameter.rb +150 -0
- data/lib/solargraph/pin/proxy_type.rb +8 -8
- data/lib/solargraph/pin/reference.rb +1 -12
- data/lib/solargraph/pin/reference/override.rb +18 -0
- data/lib/solargraph/pin/reference/require.rb +2 -1
- data/lib/solargraph/pin/singleton.rb +9 -0
- data/lib/solargraph/pin/symbol.rb +9 -4
- data/lib/solargraph/pin/yard_pin/constant.rb +12 -3
- data/lib/solargraph/pin/yard_pin/method.rb +18 -6
- data/lib/solargraph/pin/yard_pin/namespace.rb +13 -1
- data/lib/solargraph/position.rb +1 -1
- data/lib/solargraph/range.rb +4 -0
- data/lib/solargraph/shell.rb +83 -4
- data/lib/solargraph/source.rb +32 -12
- data/lib/solargraph/source/chain.rb +48 -28
- data/lib/solargraph/source/chain/call.rb +37 -38
- data/lib/solargraph/source/chain/constant.rb +1 -1
- data/lib/solargraph/source/chain/head.rb +2 -8
- data/lib/solargraph/source/chain/instance_variable.rb +1 -1
- data/lib/solargraph/source/chain/link.rb +2 -0
- data/lib/solargraph/source/cursor.rb +59 -24
- data/lib/solargraph/source/node_chainer.rb +0 -2
- data/lib/solargraph/source/node_methods.rb +12 -6
- data/lib/solargraph/source/source_chainer.rb +38 -44
- data/lib/solargraph/source_map.rb +11 -18
- data/lib/solargraph/source_map/clip.rb +13 -15
- data/lib/solargraph/source_map/mapper.rb +37 -26
- data/lib/solargraph/source_map/node_processor.rb +13 -8
- data/lib/solargraph/source_map/node_processor/alias_node.rb +8 -8
- data/lib/solargraph/source_map/node_processor/args_node.rb +10 -16
- data/lib/solargraph/source_map/node_processor/base.rb +47 -4
- data/lib/solargraph/source_map/node_processor/block_node.rb +9 -4
- data/lib/solargraph/source_map/node_processor/casgn_node.rb +7 -2
- data/lib/solargraph/source_map/node_processor/cvasgn_node.rb +8 -3
- data/lib/solargraph/source_map/node_processor/def_node.rb +45 -38
- data/lib/solargraph/source_map/node_processor/defs_node.rb +16 -6
- data/lib/solargraph/source_map/node_processor/gvasgn_node.rb +8 -1
- data/lib/solargraph/source_map/node_processor/ivasgn_node.rb +20 -6
- data/lib/solargraph/source_map/node_processor/lvasgn_node.rb +10 -4
- data/lib/solargraph/source_map/node_processor/namespace_node.rb +18 -12
- data/lib/solargraph/source_map/node_processor/orasgn_node.rb +1 -1
- data/lib/solargraph/source_map/node_processor/resbody_node.rb +30 -0
- data/lib/solargraph/source_map/node_processor/sclass_node.rb +7 -1
- data/lib/solargraph/source_map/node_processor/send_node.rb +102 -52
- data/lib/solargraph/source_map/node_processor/sym_node.rb +4 -1
- data/lib/solargraph/source_map/region.rb +9 -8
- data/lib/solargraph/type_checker.rb +282 -0
- data/lib/solargraph/type_checker/param_def.rb +47 -0
- data/lib/solargraph/type_checker/problem.rb +25 -0
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/views/environment.erb +1 -1
- data/lib/solargraph/workspace.rb +2 -2
- data/lib/solargraph/workspace/config.rb +0 -8
- data/lib/solargraph/yard_map.rb +25 -69
- data/lib/solargraph/yard_map/core_docs.rb +8 -3
- data/lib/solargraph/yard_map/core_gen.rb +1 -3
- data/lib/solargraph/yard_map/mapper.rb +85 -0
- data/lib/yard-solargraph.rb +2 -0
- metadata +14 -14
- data/lib/solargraph/diagnostics/type_not_defined.rb +0 -108
- data/lib/solargraph/live_map.rb +0 -126
- data/lib/solargraph/live_map/cache.rb +0 -38
- data/lib/solargraph/pin/block_parameter.rb +0 -103
- data/lib/solargraph/pin/method_parameter.rb +0 -40
- data/lib/solargraph/pin/plugin/method.rb +0 -25
- data/lib/solargraph/plugin.rb +0 -8
- data/lib/solargraph/plugin/base.rb +0 -41
- data/lib/solargraph/plugin/canceler.rb +0 -11
- data/lib/solargraph/plugin/process.rb +0 -172
- data/lib/solargraph/plugin/runtime.rb +0 -134
- data/lib/yard-coregen.rb +0 -16
data/lib/solargraph/yard_map.rb
CHANGED
@@ -8,6 +8,7 @@ module Solargraph
|
|
8
8
|
autoload :Cache, 'solargraph/yard_map/cache'
|
9
9
|
autoload :CoreDocs, 'solargraph/yard_map/core_docs'
|
10
10
|
autoload :CoreGen, 'solargraph/yard_map/core_gen'
|
11
|
+
autoload :Mapper, 'solargraph/yard_map/mapper'
|
11
12
|
|
12
13
|
CoreDocs.require_minimum
|
13
14
|
@@stdlib_yardoc = CoreDocs.yardoc_stdlib_file
|
@@ -88,12 +89,8 @@ module Solargraph
|
|
88
89
|
# @return [Array<Solargraph::Pin::Base>]
|
89
90
|
def core_pins
|
90
91
|
@@core_pins ||= begin
|
91
|
-
result = []
|
92
92
|
load_yardoc CoreDocs.yardoc_file
|
93
|
-
YARD::Registry.
|
94
|
-
result.concat generate_pins(o)
|
95
|
-
end
|
96
|
-
result
|
93
|
+
Mapper.new(YARD::Registry.all).map
|
97
94
|
end
|
98
95
|
end
|
99
96
|
|
@@ -103,6 +100,23 @@ module Solargraph
|
|
103
100
|
pins.select{ |p| p.path == path }.first
|
104
101
|
end
|
105
102
|
|
103
|
+
# Get the location of a file referenced by a require path.
|
104
|
+
#
|
105
|
+
# @param path [String]
|
106
|
+
# @return [Location]
|
107
|
+
def require_reference path
|
108
|
+
# @type [Gem::Specification]
|
109
|
+
spec = Gem::Specification.find_by_path(path) || Gem::Specification.find_by_name(path.split('/').first)
|
110
|
+
spec.full_require_paths.each do |rp|
|
111
|
+
file = File.join(rp, "#{path}.rb")
|
112
|
+
next unless File.file?(file)
|
113
|
+
return Solargraph::Location.new(file, Solargraph::Range.from_to(0, 0, 0, 0))
|
114
|
+
end
|
115
|
+
nil
|
116
|
+
rescue Gem::LoadError
|
117
|
+
nil
|
118
|
+
end
|
119
|
+
|
106
120
|
private
|
107
121
|
|
108
122
|
# @return [YardMap::Cache]
|
@@ -111,54 +125,16 @@ module Solargraph
|
|
111
125
|
end
|
112
126
|
|
113
127
|
# @param ns [YARD::CodeObjects::Namespace]
|
114
|
-
# @return [Array<
|
128
|
+
# @return [Array<YARD::CodeObjects::Base>]
|
115
129
|
def recurse_namespace_object ns
|
116
130
|
result = []
|
117
131
|
ns.children.each do |c|
|
118
|
-
result.
|
132
|
+
result.push c
|
119
133
|
result.concat recurse_namespace_object(c) if c.respond_to?(:children)
|
120
134
|
end
|
121
135
|
result
|
122
136
|
end
|
123
137
|
|
124
|
-
# @param code_object [YARD::CodeObjects::Base]
|
125
|
-
# @return [Solargraph::Pin::Base]
|
126
|
-
def generate_pins code_object, spec = nil
|
127
|
-
result = []
|
128
|
-
location = object_location(code_object, spec)
|
129
|
-
if code_object.is_a?(YARD::CodeObjects::NamespaceObject)
|
130
|
-
result.push Solargraph::Pin::YardPin::Namespace.new(code_object, location)
|
131
|
-
if code_object.is_a?(YARD::CodeObjects::ClassObject) and !code_object.superclass.nil?
|
132
|
-
# @todo This method of superclass detection is a bit of a hack. If
|
133
|
-
# the superclass is a Proxy, it is assumed to be undefined in its
|
134
|
-
# yardoc and converted to a fully qualified namespace.
|
135
|
-
if code_object.superclass.is_a?(YARD::CodeObjects::Proxy)
|
136
|
-
superclass = "::#{code_object.superclass}"
|
137
|
-
else
|
138
|
-
superclass = code_object.superclass.to_s
|
139
|
-
end
|
140
|
-
result.push Solargraph::Pin::Reference::Superclass.new(location, code_object.path, superclass)
|
141
|
-
end
|
142
|
-
code_object.class_mixins.each do |m|
|
143
|
-
result.push Solargraph::Pin::Reference::Extend.new(location, code_object.path, m.path)
|
144
|
-
end
|
145
|
-
code_object.instance_mixins.each do |m|
|
146
|
-
result.push Solargraph::Pin::Reference::Include.new(location, code_object.path, m.path)
|
147
|
-
end
|
148
|
-
elsif code_object.is_a?(YARD::CodeObjects::MethodObject)
|
149
|
-
if code_object.name == :initialize && code_object.scope == :instance
|
150
|
-
# @todo Check the visibility of <Class>.new
|
151
|
-
result.push Solargraph::Pin::YardPin::Method.new(code_object, location, 'new', :class, :public)
|
152
|
-
result.push Solargraph::Pin::YardPin::Method.new(code_object, location, 'initialize', :instance, :private)
|
153
|
-
else
|
154
|
-
result.push Solargraph::Pin::YardPin::Method.new(code_object, location)
|
155
|
-
end
|
156
|
-
elsif code_object.is_a?(YARD::CodeObjects::ConstantObject)
|
157
|
-
result.push Solargraph::Pin::YardPin::Constant.new(code_object, location)
|
158
|
-
end
|
159
|
-
result
|
160
|
-
end
|
161
|
-
|
162
138
|
# @return [void]
|
163
139
|
def process_requires
|
164
140
|
pins.clear
|
@@ -222,8 +198,9 @@ module Solargraph
|
|
222
198
|
objects.each do |ns|
|
223
199
|
next if done.include?(ns.path)
|
224
200
|
done.push ns.path
|
225
|
-
|
226
|
-
|
201
|
+
all = [ns]
|
202
|
+
all.concat recurse_namespace_object(ns)
|
203
|
+
result.concat Mapper.new(all).map
|
227
204
|
end
|
228
205
|
result.delete_if(&:nil?)
|
229
206
|
cache.set_path_pins(r, result) unless result.empty?
|
@@ -270,29 +247,8 @@ module Solargraph
|
|
270
247
|
Solargraph::Logging.logger.warn "Yardoc at #{y} is too large to process (#{size} bytes)"
|
271
248
|
return []
|
272
249
|
end
|
273
|
-
result = []
|
274
250
|
load_yardoc y
|
275
|
-
YARD::Registry.
|
276
|
-
result.concat generate_pins(o, spec)
|
277
|
-
end
|
278
|
-
result
|
279
|
-
end
|
280
|
-
|
281
|
-
# @param obj [YARD::CodeObjects::Base]
|
282
|
-
# @return [Solargraph::Location]
|
283
|
-
def object_location obj, spec = nil
|
284
|
-
@object_file_cache ||= {}
|
285
|
-
return nil if spec.nil? || obj.file.nil? || obj.line.nil?
|
286
|
-
file = nil
|
287
|
-
if @object_file_cache.key?(obj.file)
|
288
|
-
file = @object_file_cache[obj.file]
|
289
|
-
else
|
290
|
-
tmp = File.join(spec.full_gem_path, obj.file)
|
291
|
-
file = tmp if File.exist?(tmp)
|
292
|
-
@object_file_cache[obj.file] = file
|
293
|
-
end
|
294
|
-
return nil if file.nil?
|
295
|
-
Solargraph::Location.new(file, Solargraph::Range.from_to(obj.line - 1, 0, obj.line - 1, 0))
|
251
|
+
Mapper.new(YARD::Registry.all, spec).map
|
296
252
|
end
|
297
253
|
end
|
298
254
|
end
|
@@ -122,10 +122,15 @@ module Solargraph
|
|
122
122
|
def download version
|
123
123
|
FileUtils.mkdir_p cache_dir
|
124
124
|
uri = URI.parse("#{SOURCE}/#{version}.tar.gz")
|
125
|
+
# @type [Net::HTTPResponse]
|
125
126
|
response = Net::HTTP.get_response(uri)
|
126
|
-
|
127
|
-
|
128
|
-
|
127
|
+
if response.code == '404'
|
128
|
+
raise ArgumentError, "Version #{version} is not available from #{SOURCE}"
|
129
|
+
else
|
130
|
+
zipfile = File.join(cache_dir, "#{version}.tar.gz")
|
131
|
+
File.binwrite zipfile, response.body
|
132
|
+
install_archive zipfile
|
133
|
+
end
|
129
134
|
end
|
130
135
|
|
131
136
|
# Reset the core documentation cache to the minimum requirement.
|
@@ -19,12 +19,10 @@ module Solargraph
|
|
19
19
|
path_name = Pathname.new(Dir.pwd).join(dest_dir).to_s
|
20
20
|
FileUtils.mkdir_p path_name
|
21
21
|
Dir.chdir(ruby_dir) do
|
22
|
-
`yardoc
|
22
|
+
`yardoc -b "#{File.join(path_name, 'yardoc')}" -n *.c`
|
23
23
|
raise 'An error occurred generating the core yardoc.' unless $?.success?
|
24
|
-
# YARD::CLI::Yardoc.run('--plugin', 'coregen', '-b', "#{File.join(path_name, 'yardoc')}", '-n', File.join(ruby_dir, '*.c'))
|
25
24
|
`yardoc -b "#{File.join(path_name, 'yardoc-stdlib')}" -n lib ext`
|
26
25
|
raise 'An error occurred generating the stdlib yardoc.' unless $?.success?
|
27
|
-
# YARD::CLI::Yardoc.run('-b', "#{File.join(path_name, 'yardoc-stdlib')}", '-n', File.join(ruby_dir, 'lib', '**', '*.rb'), File.join(ruby_dir, 'ext', '**', '*.c'), File.join(ruby_dir, 'ext', '**', '*.rb'))
|
28
26
|
end
|
29
27
|
end
|
30
28
|
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module Solargraph
|
2
|
+
class YardMap
|
3
|
+
class Mapper
|
4
|
+
# @param code_objects [Array<YARD::CodeObject::Base>]
|
5
|
+
# @param spec [Gem::Specification]
|
6
|
+
def initialize code_objects, spec = nil
|
7
|
+
@code_objects = code_objects
|
8
|
+
@spec = spec
|
9
|
+
@pins = []
|
10
|
+
@namespace_pins = {}
|
11
|
+
end
|
12
|
+
|
13
|
+
# @return [Array<Pin::Base>]
|
14
|
+
def map
|
15
|
+
@code_objects.each do |co|
|
16
|
+
@pins.concat generate_pins co
|
17
|
+
end
|
18
|
+
@pins
|
19
|
+
end
|
20
|
+
|
21
|
+
# @param code_object [YARD::CodeObjects::Base]
|
22
|
+
# @return [Array<Pin::Base>]
|
23
|
+
def generate_pins code_object
|
24
|
+
result = []
|
25
|
+
location = object_location(code_object, @spec)
|
26
|
+
if code_object.is_a?(YARD::CodeObjects::NamespaceObject)
|
27
|
+
nspin = Solargraph::Pin::YardPin::Namespace.new(code_object, location)
|
28
|
+
@namespace_pins[code_object.path] = nspin
|
29
|
+
result.push nspin
|
30
|
+
if code_object.is_a?(YARD::CodeObjects::ClassObject) and !code_object.superclass.nil?
|
31
|
+
# This method of superclass detection is a bit of a hack. If
|
32
|
+
# the superclass is a Proxy, it is assumed to be undefined in its
|
33
|
+
# yardoc and converted to a fully qualified namespace.
|
34
|
+
if code_object.superclass.is_a?(YARD::CodeObjects::Proxy)
|
35
|
+
superclass = "::#{code_object.superclass}"
|
36
|
+
else
|
37
|
+
superclass = code_object.superclass.to_s
|
38
|
+
end
|
39
|
+
result.push Solargraph::Pin::Reference::Superclass.new(location: location, name: superclass, closure: nspin)
|
40
|
+
end
|
41
|
+
code_object.class_mixins.each do |m|
|
42
|
+
result.push Solargraph::Pin::Reference::Extend.new(location: location, closure: nspin, name: m.path)
|
43
|
+
end
|
44
|
+
code_object.instance_mixins.each do |m|
|
45
|
+
result.push Solargraph::Pin::Reference::Include.new(
|
46
|
+
location: location,
|
47
|
+
closure: nspin, # @todo Fix this
|
48
|
+
name: m.path
|
49
|
+
)
|
50
|
+
end
|
51
|
+
elsif code_object.is_a?(YARD::CodeObjects::MethodObject)
|
52
|
+
closure = @namespace_pins[code_object.namespace.to_s]
|
53
|
+
if code_object.name == :initialize && code_object.scope == :instance
|
54
|
+
# @todo Check the visibility of <Class>.new
|
55
|
+
result.push Solargraph::Pin::YardPin::Method.new(code_object, location, 'new', :class, :public, closure)
|
56
|
+
result.push Solargraph::Pin::YardPin::Method.new(code_object, location, 'initialize', :instance, :private, closure)
|
57
|
+
else
|
58
|
+
result.push Solargraph::Pin::YardPin::Method.new(code_object, location, nil, nil, nil, closure)
|
59
|
+
end
|
60
|
+
elsif code_object.is_a?(YARD::CodeObjects::ConstantObject)
|
61
|
+
closure = @namespace_pins[code_object.namespace]
|
62
|
+
result.push Solargraph::Pin::YardPin::Constant.new(code_object, location, closure)
|
63
|
+
end
|
64
|
+
result
|
65
|
+
end
|
66
|
+
|
67
|
+
# @param obj [YARD::CodeObjects::Base]
|
68
|
+
# @return [Solargraph::Location, nil]
|
69
|
+
def object_location obj, spec = nil
|
70
|
+
@object_file_cache ||= {}
|
71
|
+
return nil if spec.nil? || obj.file.nil? || obj.line.nil?
|
72
|
+
file = nil
|
73
|
+
if @object_file_cache.key?(obj.file)
|
74
|
+
file = @object_file_cache[obj.file]
|
75
|
+
else
|
76
|
+
tmp = File.join(spec.full_gem_path, obj.file)
|
77
|
+
file = tmp if File.exist?(tmp)
|
78
|
+
@object_file_cache[obj.file] = file
|
79
|
+
end
|
80
|
+
return nil if file.nil?
|
81
|
+
Solargraph::Location.new(file, Solargraph::Range.from_to(obj.line - 1, 0, obj.line - 1, 0))
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
data/lib/yard-solargraph.rb
CHANGED
@@ -16,3 +16,5 @@ YARD::Tags::Library.define_tag("Yieldself", :yieldself, :with_types)
|
|
16
16
|
YARD::Tags::Library.define_tag("Yieldpublic", :yieldpublic, :with_types)
|
17
17
|
# Define a @!domain directive for documenting DSLs
|
18
18
|
YARD::Tags::Library.define_directive("domain", :with_types, Solargraph::DomainDirective)
|
19
|
+
# Define an @!override directive for overriding method tags
|
20
|
+
YARD::Tags::Library.define_directive("override", :with_name, Solargraph::DomainDirective)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solargraph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.33.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fred Snyder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backport
|
@@ -269,7 +269,7 @@ files:
|
|
269
269
|
- lib/solargraph/diagnostics/rubocop.rb
|
270
270
|
- lib/solargraph/diagnostics/rubocop_helpers.rb
|
271
271
|
- lib/solargraph/diagnostics/severities.rb
|
272
|
-
- lib/solargraph/diagnostics/
|
272
|
+
- lib/solargraph/diagnostics/type_check.rb
|
273
273
|
- lib/solargraph/diagnostics/update_errors.rb
|
274
274
|
- lib/solargraph/language_server.rb
|
275
275
|
- lib/solargraph/language_server/completion_item_kinds.rb
|
@@ -301,6 +301,7 @@ files:
|
|
301
301
|
- lib/solargraph/language_server/message/shutdown.rb
|
302
302
|
- lib/solargraph/language_server/message/text_document.rb
|
303
303
|
- lib/solargraph/language_server/message/text_document/base.rb
|
304
|
+
- lib/solargraph/language_server/message/text_document/code_action.rb
|
304
305
|
- lib/solargraph/language_server/message/text_document/completion.rb
|
305
306
|
- lib/solargraph/language_server/message/text_document/definition.rb
|
306
307
|
- lib/solargraph/language_server/message/text_document/did_change.rb
|
@@ -329,8 +330,6 @@ files:
|
|
329
330
|
- lib/solargraph/language_server/transport/data_reader.rb
|
330
331
|
- lib/solargraph/language_server/uri_helpers.rb
|
331
332
|
- lib/solargraph/library.rb
|
332
|
-
- lib/solargraph/live_map.rb
|
333
|
-
- lib/solargraph/live_map/cache.rb
|
334
333
|
- lib/solargraph/location.rb
|
335
334
|
- lib/solargraph/logging.rb
|
336
335
|
- lib/solargraph/page.rb
|
@@ -340,8 +339,9 @@ files:
|
|
340
339
|
- lib/solargraph/pin/base_method.rb
|
341
340
|
- lib/solargraph/pin/base_variable.rb
|
342
341
|
- lib/solargraph/pin/block.rb
|
343
|
-
- lib/solargraph/pin/block_parameter.rb
|
344
342
|
- lib/solargraph/pin/class_variable.rb
|
343
|
+
- lib/solargraph/pin/closure.rb
|
344
|
+
- lib/solargraph/pin/common.rb
|
345
345
|
- lib/solargraph/pin/constant.rb
|
346
346
|
- lib/solargraph/pin/conversions.rb
|
347
347
|
- lib/solargraph/pin/documenting.rb
|
@@ -353,26 +353,22 @@ files:
|
|
353
353
|
- lib/solargraph/pin/localized.rb
|
354
354
|
- lib/solargraph/pin/method.rb
|
355
355
|
- lib/solargraph/pin/method_alias.rb
|
356
|
-
- lib/solargraph/pin/method_parameter.rb
|
357
356
|
- lib/solargraph/pin/namespace.rb
|
358
|
-
- lib/solargraph/pin/
|
357
|
+
- lib/solargraph/pin/parameter.rb
|
359
358
|
- lib/solargraph/pin/proxy_type.rb
|
360
359
|
- lib/solargraph/pin/reference.rb
|
361
360
|
- lib/solargraph/pin/reference/extend.rb
|
362
361
|
- lib/solargraph/pin/reference/include.rb
|
362
|
+
- lib/solargraph/pin/reference/override.rb
|
363
363
|
- lib/solargraph/pin/reference/require.rb
|
364
364
|
- lib/solargraph/pin/reference/superclass.rb
|
365
|
+
- lib/solargraph/pin/singleton.rb
|
365
366
|
- lib/solargraph/pin/symbol.rb
|
366
367
|
- lib/solargraph/pin/yard_pin.rb
|
367
368
|
- lib/solargraph/pin/yard_pin/constant.rb
|
368
369
|
- lib/solargraph/pin/yard_pin/method.rb
|
369
370
|
- lib/solargraph/pin/yard_pin/namespace.rb
|
370
371
|
- lib/solargraph/pin/yard_pin/yard_mixin.rb
|
371
|
-
- lib/solargraph/plugin.rb
|
372
|
-
- lib/solargraph/plugin/base.rb
|
373
|
-
- lib/solargraph/plugin/canceler.rb
|
374
|
-
- lib/solargraph/plugin/process.rb
|
375
|
-
- lib/solargraph/plugin/runtime.rb
|
376
372
|
- lib/solargraph/position.rb
|
377
373
|
- lib/solargraph/range.rb
|
378
374
|
- lib/solargraph/server_methods.rb
|
@@ -415,10 +411,14 @@ files:
|
|
415
411
|
- lib/solargraph/source_map/node_processor/lvasgn_node.rb
|
416
412
|
- lib/solargraph/source_map/node_processor/namespace_node.rb
|
417
413
|
- lib/solargraph/source_map/node_processor/orasgn_node.rb
|
414
|
+
- lib/solargraph/source_map/node_processor/resbody_node.rb
|
418
415
|
- lib/solargraph/source_map/node_processor/sclass_node.rb
|
419
416
|
- lib/solargraph/source_map/node_processor/send_node.rb
|
420
417
|
- lib/solargraph/source_map/node_processor/sym_node.rb
|
421
418
|
- lib/solargraph/source_map/region.rb
|
419
|
+
- lib/solargraph/type_checker.rb
|
420
|
+
- lib/solargraph/type_checker/param_def.rb
|
421
|
+
- lib/solargraph/type_checker/problem.rb
|
422
422
|
- lib/solargraph/version.rb
|
423
423
|
- lib/solargraph/views/_method.erb
|
424
424
|
- lib/solargraph/views/_name_type_tag.erb
|
@@ -433,7 +433,7 @@ files:
|
|
433
433
|
- lib/solargraph/yard_map/cache.rb
|
434
434
|
- lib/solargraph/yard_map/core_docs.rb
|
435
435
|
- lib/solargraph/yard_map/core_gen.rb
|
436
|
-
- lib/
|
436
|
+
- lib/solargraph/yard_map/mapper.rb
|
437
437
|
- lib/yard-solargraph.rb
|
438
438
|
- solargraph.gemspec
|
439
439
|
- travis-bundler.rb
|
@@ -1,108 +0,0 @@
|
|
1
|
-
module Solargraph
|
2
|
-
module Diagnostics
|
3
|
-
# TypeNotDefined reports methods with undefined return types, untagged
|
4
|
-
# parameters, and invalid param tags.
|
5
|
-
#
|
6
|
-
class TypeNotDefined < Base
|
7
|
-
def diagnose source, api_map
|
8
|
-
result = []
|
9
|
-
api_map.document_symbols(source.filename).each do |pin|
|
10
|
-
next unless pin.kind == Pin::METHOD or pin.kind == Pin::ATTRIBUTE
|
11
|
-
result.concat check_return_type(pin, api_map, source)
|
12
|
-
result.concat check_param_types(pin, api_map, source)
|
13
|
-
result.concat check_param_tags(pin, api_map, source)
|
14
|
-
end
|
15
|
-
result
|
16
|
-
end
|
17
|
-
|
18
|
-
private
|
19
|
-
|
20
|
-
def check_return_type pin, api_map, source
|
21
|
-
return [] if (pin.name == 'initialize' && pin.scope == :instance) || (pin.name == 'new' && pin.scope == :class)
|
22
|
-
result = []
|
23
|
-
unless defined_return_type?(pin, api_map)
|
24
|
-
result.push(
|
25
|
-
range: extract_first_line(pin, source),
|
26
|
-
severity: Diagnostics::Severities::WARNING,
|
27
|
-
source: 'Solargraph',
|
28
|
-
message: "Method `#{pin.name}` has undefined return type."
|
29
|
-
)
|
30
|
-
end
|
31
|
-
result
|
32
|
-
end
|
33
|
-
|
34
|
-
def check_param_types pin, api_map, source
|
35
|
-
return [] if pin.name == 'new' and pin.scope == :class
|
36
|
-
result = []
|
37
|
-
pin.parameter_names.each do |par|
|
38
|
-
next if defined_param_type?(pin, par, api_map)
|
39
|
-
result.push(
|
40
|
-
range: extract_first_line(pin, source),
|
41
|
-
severity: Diagnostics::Severities::WARNING,
|
42
|
-
source: 'Solargraph',
|
43
|
-
message: "Method `#{pin.name}` has undefined param `#{par}`."
|
44
|
-
)
|
45
|
-
end
|
46
|
-
result
|
47
|
-
end
|
48
|
-
|
49
|
-
def check_param_tags pin, api_map, source
|
50
|
-
result = []
|
51
|
-
pin.docstring.tags(:param).each do |par|
|
52
|
-
next if pin.parameter_names.include?(par.name)
|
53
|
-
result.push(
|
54
|
-
range: extract_first_line(pin, source),
|
55
|
-
severity: Diagnostics::Severities::WARNING,
|
56
|
-
source: 'Solargraph',
|
57
|
-
message: "Method `#{pin.name}` has mistagged param `#{par.name}`."
|
58
|
-
)
|
59
|
-
end
|
60
|
-
result
|
61
|
-
end
|
62
|
-
|
63
|
-
def extract_first_line pin, source
|
64
|
-
{
|
65
|
-
start: {
|
66
|
-
line: pin.location.range.start.line,
|
67
|
-
character: pin.location.range.start.character
|
68
|
-
},
|
69
|
-
end: {
|
70
|
-
line: pin.location.range.start.line,
|
71
|
-
character: last_character(pin.location.range.start, source)
|
72
|
-
}
|
73
|
-
}
|
74
|
-
end
|
75
|
-
|
76
|
-
def defined_return_type? pin, api_map
|
77
|
-
return true unless pin.return_complex_type.undefined?
|
78
|
-
matches = api_map.get_method_stack(pin.namespace, pin.name, scope: pin.scope)
|
79
|
-
matches.shift
|
80
|
-
matches.any?{|m| !m.return_complex_type.undefined?}
|
81
|
-
end
|
82
|
-
|
83
|
-
def defined_param_type? pin, param, api_map
|
84
|
-
return true if param_in_docstring?(param, pin.docstring)
|
85
|
-
matches = api_map.get_method_stack(pin.namespace, pin.name, scope: pin.scope)
|
86
|
-
matches.shift
|
87
|
-
matches.each do |m|
|
88
|
-
next unless pin.parameter_names == m.parameter_names
|
89
|
-
return true if param_in_docstring?(param, m.docstring)
|
90
|
-
end
|
91
|
-
false
|
92
|
-
end
|
93
|
-
|
94
|
-
def param_in_docstring? param, docstring
|
95
|
-
tags = docstring.tags(:param)
|
96
|
-
tags.any?{|t| t.name == param}
|
97
|
-
end
|
98
|
-
|
99
|
-
# @param position [Solargraph::Position]
|
100
|
-
# @param source [Solargraph::Source]
|
101
|
-
# @return [Integer]
|
102
|
-
def last_character position, source
|
103
|
-
cursor = Position.to_offset(source.code, position)
|
104
|
-
source.code.index(/[\r\n]/, cursor) || source.code.length
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|