solargraph 0.33.1 → 0.33.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.
- checksums.yaml +4 -4
- data/lib/solargraph/language_server/host.rb +2 -1
- data/lib/solargraph/language_server/host/dispatch.rb +3 -1
- data/lib/solargraph/language_server/host/sources.rb +5 -0
- data/lib/solargraph/language_server/message/completion_item/resolve.rb +15 -2
- data/lib/solargraph/language_server/message/text_document/hover.rb +1 -1
- data/lib/solargraph/library.rb +9 -35
- data/lib/solargraph/pin/conversions.rb +2 -2
- data/lib/solargraph/pin/parameter.rb +5 -0
- data/lib/solargraph/pin/proxy_type.rb +0 -8
- data/lib/solargraph/source.rb +1 -1
- data/lib/solargraph/source/chain.rb +9 -3
- data/lib/solargraph/source/chain/head.rb +1 -1
- data/lib/solargraph/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32fec2551136daaa8c608f7fe94fec4ef24e08ba03723b2ece3e4c8b66342c5b
|
4
|
+
data.tar.gz: edaa58070c532e97dd1b0ac2e43b7917e08ceb972d19c43f26eba7b9fc62cf5a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 46b6981ae2a47c4676a78fdb50ac01f46d70cc37b3f762b9c35936dd13b2cd529fca0ed6d9057bd3106164145967560f50d1836848c395d4d90b953facb48f27
|
7
|
+
data.tar.gz: c6f70f39fded5af0e588f6792c9dba1872c421fc62993e16e1f734fe828d36e5f287309368fb09b1a7130d9bd7f0aa87a9ac7e9bef8e0de9309247985bc67c9f
|
@@ -159,8 +159,9 @@ module Solargraph
|
|
159
159
|
# @param uri [String]
|
160
160
|
# @return [void]
|
161
161
|
def open_from_disk uri
|
162
|
+
sources.open_from_disk(uri)
|
162
163
|
library = library_for(uri)
|
163
|
-
library.open_from_disk uri_to_file(uri)
|
164
|
+
# library.open_from_disk uri_to_file(uri)
|
164
165
|
diagnoser.schedule uri
|
165
166
|
end
|
166
167
|
|
@@ -36,9 +36,11 @@ module Solargraph
|
|
36
36
|
# @param uri [String]
|
37
37
|
# @return [Library]
|
38
38
|
def library_for uri
|
39
|
-
explicit_library_for(uri) ||
|
39
|
+
result = explicit_library_for(uri) ||
|
40
40
|
implicit_library_for(uri) ||
|
41
41
|
generic_library_for(uri)
|
42
|
+
result.attach sources.find(uri) if sources.include?(uri)
|
43
|
+
result
|
42
44
|
end
|
43
45
|
|
44
46
|
# Find an explicit library match for the given URI. An explicit match
|
@@ -59,6 +59,11 @@ module Solargraph
|
|
59
59
|
open_source_hash[uri] = source
|
60
60
|
end
|
61
61
|
|
62
|
+
def open_from_disk uri
|
63
|
+
source = Solargraph::Source.load(UriHelpers.uri_to_file(uri))
|
64
|
+
open_source_hash[uri] = source
|
65
|
+
end
|
66
|
+
|
62
67
|
# Update an existing source.
|
63
68
|
#
|
64
69
|
# @raise [FileNotFoundError] if the URI does not match an open source.
|
@@ -18,10 +18,10 @@ module Solargraph
|
|
18
18
|
return params if pins.empty?
|
19
19
|
docs = pins
|
20
20
|
.reject { |pin| pin.documentation.empty? && pin.return_type.undefined? }
|
21
|
-
|
21
|
+
# docs = filt.map { |pin| pin.resolve_completion_item[:documentation] }
|
22
22
|
result = params
|
23
23
|
.merge(pins.first.resolve_completion_item)
|
24
|
-
.merge(documentation: markup_content(docs
|
24
|
+
.merge(documentation: markup_content(join_docs(docs)))
|
25
25
|
result[:detail] = pins.first.detail
|
26
26
|
result
|
27
27
|
end
|
@@ -35,6 +35,19 @@ module Solargraph
|
|
35
35
|
value: text
|
36
36
|
}
|
37
37
|
end
|
38
|
+
|
39
|
+
def join_docs pins
|
40
|
+
result = []
|
41
|
+
last_link = nil
|
42
|
+
pins.each_with_index do |pin|
|
43
|
+
if pin.link_documentation && pin.link_documentation != last_link
|
44
|
+
result.push pin.link_documentation
|
45
|
+
end
|
46
|
+
result.push pin.documentation
|
47
|
+
last_link = pin.link_documentation
|
48
|
+
end
|
49
|
+
result.join("\n\n")
|
50
|
+
end
|
38
51
|
end
|
39
52
|
end
|
40
53
|
end
|
@@ -15,7 +15,7 @@ module Solargraph
|
|
15
15
|
suggestions.each do |pin|
|
16
16
|
parts = []
|
17
17
|
this_link = pin.link_documentation
|
18
|
-
if !this_link.nil?
|
18
|
+
if !this_link.nil? && this_link != last_link
|
19
19
|
parts.push this_link
|
20
20
|
end
|
21
21
|
parts.push HTMLEntities.new.encode(pin.detail) unless pin.kind == Solargraph::Pin::NAMESPACE or pin.detail.nil?
|
data/lib/solargraph/library.rb
CHANGED
@@ -10,6 +10,9 @@ module Solargraph
|
|
10
10
|
# @return [String, nil]
|
11
11
|
attr_reader :name
|
12
12
|
|
13
|
+
# @return [Source, nil]
|
14
|
+
attr_reader :current
|
15
|
+
|
13
16
|
# @param workspace [Solargraph::Workspace]
|
14
17
|
# @param name [String, nil]
|
15
18
|
def initialize workspace = Solargraph::Workspace.new, name = nil
|
@@ -33,15 +36,6 @@ module Solargraph
|
|
33
36
|
@synchronized
|
34
37
|
end
|
35
38
|
|
36
|
-
# Open a file from disk and try to merge it into the workspace.
|
37
|
-
#
|
38
|
-
# @param filename [String]
|
39
|
-
# @return [Boolean] True if the file was merged into the source.
|
40
|
-
def open_from_disk filename
|
41
|
-
source = Solargraph::Source.load(filename)
|
42
|
-
merge source
|
43
|
-
end
|
44
|
-
|
45
39
|
# Attach a source to the library.
|
46
40
|
#
|
47
41
|
# The attached source does not need to be a part of the workspace. The
|
@@ -54,6 +48,7 @@ module Solargraph
|
|
54
48
|
mutex.synchronize do
|
55
49
|
@synchronized = (@current == source) if synchronized?
|
56
50
|
@current = source
|
51
|
+
catalog
|
57
52
|
end
|
58
53
|
end
|
59
54
|
|
@@ -159,7 +154,7 @@ module Solargraph
|
|
159
154
|
# @todo Take a Location instead of filename/line/column
|
160
155
|
def completions_at filename, line, column
|
161
156
|
position = Position.new(line, column)
|
162
|
-
cursor = Source::Cursor.new(
|
157
|
+
cursor = Source::Cursor.new(read(filename), position)
|
163
158
|
api_map.clip(cursor).complete
|
164
159
|
end
|
165
160
|
|
@@ -173,7 +168,7 @@ module Solargraph
|
|
173
168
|
# @todo Take filename/position instead of filename/line/column
|
174
169
|
def definitions_at filename, line, column
|
175
170
|
position = Position.new(line, column)
|
176
|
-
cursor = Source::Cursor.new(
|
171
|
+
cursor = Source::Cursor.new(read(filename), position)
|
177
172
|
api_map.clip(cursor).define.map { |pin| pin.realize(api_map) }
|
178
173
|
end
|
179
174
|
|
@@ -187,7 +182,7 @@ module Solargraph
|
|
187
182
|
# @todo Take filename/position instead of filename/line/column
|
188
183
|
def signatures_at filename, line, column
|
189
184
|
position = Position.new(line, column)
|
190
|
-
cursor = Source::Cursor.new(
|
185
|
+
cursor = Source::Cursor.new(read(filename), position)
|
191
186
|
api_map.clip(cursor).signify
|
192
187
|
end
|
193
188
|
|
@@ -198,7 +193,7 @@ module Solargraph
|
|
198
193
|
# @return [Array<Solargraph::Range>]
|
199
194
|
# @todo Take a Location instead of filename/line/column
|
200
195
|
def references_from filename, line, column, strip: false
|
201
|
-
checkout filename
|
196
|
+
# checkout filename
|
202
197
|
cursor = api_map.cursor_at(filename, Position.new(line, column))
|
203
198
|
clip = api_map.clip(cursor)
|
204
199
|
pins = clip.define
|
@@ -247,27 +242,6 @@ module Solargraph
|
|
247
242
|
api_map.get_path_suggestions(path)
|
248
243
|
end
|
249
244
|
|
250
|
-
# Check a file out of the library. If the file is not part of the
|
251
|
-
# workspace, the ApiMap will virtualize it for mapping purposes. If
|
252
|
-
# filename is nil, any source currently checked out of the library
|
253
|
-
# will be removed from the ApiMap. Only one file can be checked out
|
254
|
-
# (virtualized) at a time.
|
255
|
-
#
|
256
|
-
# @raise [FileNotFoundError] if the file does not exist.
|
257
|
-
#
|
258
|
-
# @param filename [String]
|
259
|
-
# @return [Source]
|
260
|
-
def checkout filename
|
261
|
-
checked = read(filename)
|
262
|
-
@synchronized = (checked == @current) if synchronized?
|
263
|
-
@current = checked
|
264
|
-
# Cataloging is necessary to avoid FileNotFoundErrors when the file is
|
265
|
-
# not in the workspace. Otherwise it should be safe to defer
|
266
|
-
# synchronization.
|
267
|
-
catalog unless workspace.has_file?(filename)
|
268
|
-
@current
|
269
|
-
end
|
270
|
-
|
271
245
|
# @param query [String]
|
272
246
|
# @return [Array<YARD::CodeObject::Base>]
|
273
247
|
def document query
|
@@ -300,7 +274,7 @@ module Solargraph
|
|
300
274
|
# @param filename [String]
|
301
275
|
# @return [Array<Solargraph::Pin::Base>]
|
302
276
|
def document_symbols filename
|
303
|
-
checkout filename
|
277
|
+
# checkout filename
|
304
278
|
api_map.document_symbols(filename)
|
305
279
|
end
|
306
280
|
|
@@ -22,8 +22,8 @@ module Solargraph
|
|
22
22
|
if @resolve_completion_item.nil?
|
23
23
|
extra = {}
|
24
24
|
alldoc = ''
|
25
|
-
alldoc += link_documentation unless link_documentation.nil?
|
26
|
-
alldoc += "\n\n" unless alldoc.empty?
|
25
|
+
# alldoc += link_documentation unless link_documentation.nil?
|
26
|
+
# alldoc += "\n\n" unless alldoc.empty?
|
27
27
|
alldoc += documentation unless documentation.nil?
|
28
28
|
extra[:documentation] = alldoc unless alldoc.empty?
|
29
29
|
@resolve_completion_item = completion_item.merge(extra)
|
data/lib/solargraph/source.rb
CHANGED
@@ -443,7 +443,7 @@ module Solargraph
|
|
443
443
|
# @return [Array<AST::Node>]
|
444
444
|
def inner_node_references name, top
|
445
445
|
result = []
|
446
|
-
if top.is_a?(AST::Node)
|
446
|
+
if top.is_a?(AST::Node) && top.to_s.include?(":#{name}")
|
447
447
|
result.push top if top.children.any? { |c| c.to_s == name }
|
448
448
|
top.children.each { |c| result.concat inner_node_references(name, c) }
|
449
449
|
end
|
@@ -18,6 +18,7 @@ module Solargraph
|
|
18
18
|
autoload :Head, 'solargraph/source/chain/head'
|
19
19
|
autoload :Or, 'solargraph/source/chain/or'
|
20
20
|
|
21
|
+
@@inference_stack = []
|
21
22
|
@@inference_depth = 0
|
22
23
|
|
23
24
|
UNDEFINED_CALL = Chain::Call.new('<undefined>')
|
@@ -94,19 +95,24 @@ module Solargraph
|
|
94
95
|
# @return [ComplexType]
|
95
96
|
def infer_first_defined pins, context, api_map
|
96
97
|
type = ComplexType::UNDEFINED
|
97
|
-
return type if @@inference_depth >= 3
|
98
|
-
@@inference_depth += 1
|
99
98
|
pins.each do |pin|
|
100
99
|
type = pin.typify(api_map)
|
101
100
|
break if type.defined?
|
102
101
|
end
|
103
102
|
if type.undefined?
|
103
|
+
# Limit method inference recursion
|
104
|
+
return type if @@inference_depth >= 2 && pins.first.is_a?(Pin::BaseMethod)
|
105
|
+
@@inference_depth += 1
|
104
106
|
pins.each do |pin|
|
107
|
+
# Avoid infinite recursion
|
108
|
+
next if @@inference_stack.include?(pin)
|
109
|
+
@@inference_stack.push pin
|
105
110
|
type = pin.probe(api_map)
|
111
|
+
@@inference_stack.pop
|
106
112
|
break if type.defined?
|
107
113
|
end
|
114
|
+
@@inference_depth -= 1
|
108
115
|
end
|
109
|
-
@@inference_depth -= 1
|
110
116
|
return type if context.nil? || context.return_type.undefined?
|
111
117
|
type.self_to(context.return_type.namespace)
|
112
118
|
end
|
@@ -7,7 +7,7 @@ module Solargraph
|
|
7
7
|
# @note Chain::Head is only intended to handle `self` and `super`.
|
8
8
|
class Head < Link
|
9
9
|
def resolve api_map, name_pin, locals
|
10
|
-
return [name_pin] if word == 'self'
|
10
|
+
return [Pin::ProxyType.anonymous(name_pin.binder)] if word == 'self'
|
11
11
|
return super_pins(api_map, name_pin) if word == 'super'
|
12
12
|
[]
|
13
13
|
end
|
data/lib/solargraph/version.rb
CHANGED
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.33.
|
4
|
+
version: 0.33.2
|
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-06-
|
11
|
+
date: 2019-06-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: backport
|