solargraph 0.28.1 → 0.28.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/api_map.rb +3 -3
- data/lib/solargraph/api_map/cache.rb +1 -27
- data/lib/solargraph/api_map/store.rb +1 -1
- data/lib/solargraph/complex_type.rb +4 -2
- data/lib/solargraph/complex_type/type_methods.rb +5 -3
- data/lib/solargraph/complex_type/unique_type.rb +6 -3
- data/lib/solargraph/language_server/host.rb +15 -1
- data/lib/solargraph/language_server/host/diagnoser.rb +5 -19
- data/lib/solargraph/position.rb +6 -5
- data/lib/solargraph/source/source_chainer.rb +1 -1
- data/lib/solargraph/source_map/clip.rb +13 -1
- data/lib/solargraph/source_map/mapper.rb +12 -3
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/yard_map.rb +9 -1
- data/lib/solargraph/yard_map/core_docs.rb +2 -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: 99d55308f8ad7a0f73c4432cf08789471b46a60df7db0cc59a4ca8ef6dd9360f
|
4
|
+
data.tar.gz: 8b81acc2451105bb669fbaa0eb215f27ef6f32306b354683c0c045374317e4f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 482e84a980ef3385ee1f182c17681bdd97912b84055b017dd5821641a82a240945c1e080bbd11dee0a32df520069318aafef85687a24d801089574fb88154f2f
|
7
|
+
data.tar.gz: 14cf67e4029a2f1fcc8fdbccfd521f7db6776d010d2f4681c77db56b5f5da0a4ebdc51499ef60c5ff5fcd6fa031ab054f250491b71a2ac4394feef4b8aeaa9c5
|
data/lib/solargraph/api_map.rb
CHANGED
@@ -334,10 +334,10 @@ module Solargraph
|
|
334
334
|
# @return [Array<Solargraph::Pin::Base>]
|
335
335
|
def get_method_stack fqns, name, scope: :instance
|
336
336
|
# @todo This cache is still causing problems.
|
337
|
-
|
338
|
-
|
337
|
+
cached = cache.get_method_stack(fqns, name, scope)
|
338
|
+
return cached unless cached.nil?
|
339
339
|
result = get_methods(fqns, scope: scope, visibility: [:private, :protected, :public]).select{|p| p.name == name}
|
340
|
-
|
340
|
+
cache.set_method_stack(fqns, name, scope, result)
|
341
341
|
result
|
342
342
|
end
|
343
343
|
|
@@ -2,34 +2,12 @@ module Solargraph
|
|
2
2
|
class ApiMap
|
3
3
|
class Cache
|
4
4
|
def initialize
|
5
|
-
@signature_types = {}
|
6
|
-
@assignment_node_types = {}
|
7
5
|
@methods = {}
|
8
6
|
@method_stacks = {}
|
9
7
|
@constants = {}
|
10
8
|
@qualified_namespaces = {}
|
11
9
|
end
|
12
10
|
|
13
|
-
def get_signature_type signature, namespace, scope
|
14
|
-
@signature_types[[signature, namespace, scope]]
|
15
|
-
end
|
16
|
-
|
17
|
-
def has_signature_type?(signature, namespace, scope)
|
18
|
-
@signature_types.has_key?([signature, namespace, scope])
|
19
|
-
end
|
20
|
-
|
21
|
-
def set_signature_type signature, namespace, scope, value
|
22
|
-
@signature_types[[signature, namespace, scope]] = value
|
23
|
-
end
|
24
|
-
|
25
|
-
def get_assignment_node_type node, namespace
|
26
|
-
@assignment_node_types[[node, namespace]]
|
27
|
-
end
|
28
|
-
|
29
|
-
def set_assignment_node_type node, namespace, value
|
30
|
-
@assignment_node_types[[node, namespace]] = value
|
31
|
-
end
|
32
|
-
|
33
11
|
def get_methods fqns, scope, visibility, deep
|
34
12
|
@methods[[fqns, scope, visibility.sort, deep]]
|
35
13
|
end
|
@@ -64,8 +42,6 @@ module Solargraph
|
|
64
42
|
|
65
43
|
# @return [void]
|
66
44
|
def clear
|
67
|
-
@signature_types.clear
|
68
|
-
@assignment_node_types.clear
|
69
45
|
@methods.clear
|
70
46
|
@method_stacks.clear
|
71
47
|
@constants.clear
|
@@ -74,9 +50,7 @@ module Solargraph
|
|
74
50
|
|
75
51
|
# @return [Boolean]
|
76
52
|
def empty?
|
77
|
-
@
|
78
|
-
@assignment_node_types.empty? &&
|
79
|
-
@methods.empty? &&
|
53
|
+
@methods.empty? &&
|
80
54
|
@method_stacks.empty? &&
|
81
55
|
@constants.empty? &&
|
82
56
|
@qualified_namespaces.empty?
|
@@ -27,7 +27,7 @@ module Solargraph
|
|
27
27
|
# @return [Array<Solargraph::Pin::Base>]
|
28
28
|
def get_methods fqns, scope: :instance, visibility: [:public]
|
29
29
|
namespace_children(fqns).select{ |pin|
|
30
|
-
[Pin::METHOD, Pin::ATTRIBUTE].include?(pin.kind)
|
30
|
+
[Pin::METHOD, Pin::ATTRIBUTE].include?(pin.kind) && pin.scope == scope && visibility.include?(pin.visibility)
|
31
31
|
}
|
32
32
|
end
|
33
33
|
|
@@ -1,4 +1,6 @@
|
|
1
1
|
module Solargraph
|
2
|
+
# A container for type data based on YARD type tags.
|
3
|
+
#
|
2
4
|
class ComplexType < Array
|
3
5
|
# @todo Figure out how to add the basic type methods here without actually
|
4
6
|
# including the module. One possibility:
|
@@ -8,7 +10,7 @@ module Solargraph
|
|
8
10
|
|
9
11
|
autoload :TypeMethods, 'solargraph/complex_type/type_methods'
|
10
12
|
autoload :UniqueType, 'solargraph/complex_type/unique_type'
|
11
|
-
|
13
|
+
|
12
14
|
# @param types [Array<ComplexType>]
|
13
15
|
def initialize types = [ComplexType::UNDEFINED]
|
14
16
|
super()
|
@@ -17,6 +19,7 @@ module Solargraph
|
|
17
19
|
|
18
20
|
# @param api_map [ApiMap]
|
19
21
|
# @param context [String]
|
22
|
+
# @return [ComplexType]
|
20
23
|
def qualify api_map, context = ''
|
21
24
|
types = map do |t|
|
22
25
|
t.qualify api_map, context
|
@@ -95,7 +98,6 @@ module Solargraph
|
|
95
98
|
curly_stack -= 1
|
96
99
|
subtype_string += char
|
97
100
|
raise ComplexTypeError, "Invalid close in type #{type_string}" if curly_stack < 0
|
98
|
-
# types.push ComplexType.parse(subtype_string[1..-2]) if curly_stack == 0
|
99
101
|
next
|
100
102
|
elsif char == '('
|
101
103
|
paren_stack += 1
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module Solargraph
|
2
2
|
class ComplexType
|
3
|
+
# Methods for accessing type data.
|
4
|
+
#
|
3
5
|
module TypeMethods
|
4
6
|
# @return [String]
|
5
7
|
attr_reader :name
|
@@ -69,13 +71,13 @@ module Solargraph
|
|
69
71
|
def namespace
|
70
72
|
@namespace ||= 'Object' if duck_type?
|
71
73
|
@namespace ||= 'NilClass' if nil_type?
|
72
|
-
@namespace ||= (
|
74
|
+
@namespace ||= (name == 'Class' || name == 'Module') && !subtypes.empty? ? subtypes.first.name : name
|
73
75
|
end
|
74
76
|
|
75
77
|
# @return [Symbol] :class or :instance
|
76
78
|
def scope
|
77
|
-
@scope ||= :instance if duck_type?
|
78
|
-
@scope ||= (
|
79
|
+
@scope ||= :instance if duck_type? || nil_type?
|
80
|
+
@scope ||= (name == 'Class' || name == 'Module') && !subtypes.empty? ? :class : :instance
|
79
81
|
end
|
80
82
|
|
81
83
|
def == other
|
@@ -1,11 +1,14 @@
|
|
1
1
|
module Solargraph
|
2
2
|
class ComplexType
|
3
|
+
# An individual type signature. A complex type can consist of multiple
|
4
|
+
# unique types.
|
5
|
+
#
|
3
6
|
class UniqueType
|
4
7
|
include TypeMethods
|
5
8
|
|
6
|
-
# Create a
|
7
|
-
# The substring is the parameter section of a parametrized type, e.g.,
|
8
|
-
# the type `Array<String>`, the name is `Array` and the substring is
|
9
|
+
# Create a UniqueType with the specified name and an optional substring.
|
10
|
+
# The substring is the parameter section of a parametrized type, e.g.,
|
11
|
+
# for the type `Array<String>`, the name is `Array` and the substring is
|
9
12
|
# `<String>`.
|
10
13
|
#
|
11
14
|
# @param name [String] The name of the type
|
@@ -143,8 +143,22 @@ module Solargraph
|
|
143
143
|
library.overwrite filename, version
|
144
144
|
end
|
145
145
|
|
146
|
+
# @param uri [String]
|
146
147
|
def diagnose uri
|
147
|
-
|
148
|
+
begin
|
149
|
+
results = library.diagnose uri_to_file(uri)
|
150
|
+
send_notification "textDocument/publishDiagnostics", {
|
151
|
+
uri: uri,
|
152
|
+
diagnostics: results
|
153
|
+
}
|
154
|
+
rescue DiagnosticsError => e
|
155
|
+
STDERR.puts "Error in diagnostics: #{e.message}"
|
156
|
+
options['diagnostics'] = false
|
157
|
+
send_notification 'window/showMessage', {
|
158
|
+
type: LanguageServer::MessageTypes::ERROR,
|
159
|
+
message: "Error in diagnostics: #{e.message}"
|
160
|
+
}
|
161
|
+
end
|
148
162
|
end
|
149
163
|
|
150
164
|
def change params
|
@@ -45,25 +45,11 @@ module Solargraph
|
|
45
45
|
mutex.synchronize { queue.clear }
|
46
46
|
next
|
47
47
|
end
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
results.concat host.diagnose(current) if host.open?(current)
|
54
|
-
host.send_notification "textDocument/publishDiagnostics", {
|
55
|
-
uri: current,
|
56
|
-
diagnostics: results
|
57
|
-
}
|
58
|
-
sleep 0.5
|
59
|
-
rescue DiagnosticsError => e
|
60
|
-
STDERR.puts "Error in diagnostics: #{e.message}"
|
61
|
-
options['diagnostics'] = false
|
62
|
-
host.send_notification 'window/showMessage', {
|
63
|
-
type: LanguageServer::MessageTypes::ERROR,
|
64
|
-
message: "Error in diagnostics: #{e.message}"
|
65
|
-
}
|
66
|
-
end
|
48
|
+
current = nil
|
49
|
+
mutex.synchronize { current = queue.shift }
|
50
|
+
next if queue.include?(current)
|
51
|
+
host.diagnose current
|
52
|
+
sleep 0.5
|
67
53
|
end
|
68
54
|
end
|
69
55
|
self
|
data/lib/solargraph/position.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
module Solargraph
|
2
|
-
|
2
|
+
# The zero-based line and column numbers of a position in a string.
|
3
|
+
#
|
3
4
|
class Position
|
4
5
|
# @return [Integer]
|
5
6
|
attr_reader :line
|
@@ -7,15 +8,15 @@ module Solargraph
|
|
7
8
|
# @return [Integer]
|
8
9
|
attr_reader :character
|
9
10
|
|
11
|
+
alias column character
|
12
|
+
|
13
|
+
# @param line [Integer]
|
14
|
+
# @param character [Integer]
|
10
15
|
def initialize line, character
|
11
16
|
@line = line
|
12
17
|
@character = character
|
13
18
|
end
|
14
19
|
|
15
|
-
def column
|
16
|
-
character
|
17
|
-
end
|
18
|
-
|
19
20
|
# Get a hash of the position. This representation is suitable for use in
|
20
21
|
# the language server protocol.
|
21
22
|
#
|
@@ -42,7 +42,7 @@ module Solargraph
|
|
42
42
|
node = source.node_at(position.line, position.column)
|
43
43
|
else
|
44
44
|
node = nil
|
45
|
-
node = source.node_at(fixed_position.line, fixed_position.column) unless source.error_ranges.any?{|r| r.include?(fixed_position)}
|
45
|
+
node = source.node_at(fixed_position.line, fixed_position.column) unless source.error_ranges.any?{|r| r.nil? || r.include?(fixed_position)}
|
46
46
|
node = Source.parse(fixed_phrase) if node.nil?
|
47
47
|
end
|
48
48
|
rescue Parser::SyntaxError
|
@@ -24,10 +24,22 @@ module Solargraph
|
|
24
24
|
return package_completions(api_map.get_symbols) if cursor.chain.literal? && cursor.chain.links.last.word == '<Symbol>'
|
25
25
|
return Completion.new([], cursor.range) if cursor.chain.literal? || cursor.comment?
|
26
26
|
result = []
|
27
|
-
type = cursor.chain.base.infer(api_map, context_pin, locals)
|
28
27
|
if cursor.chain.constant? || cursor.start_of_constant?
|
28
|
+
if cursor.chain.undefined?
|
29
|
+
type = cursor.chain.base.infer(api_map, context_pin, locals)
|
30
|
+
else
|
31
|
+
full = cursor.chain.links.first.word
|
32
|
+
if full.include?('::')
|
33
|
+
type = ComplexType.parse(full.split('::')[0..-2].join('::'))
|
34
|
+
elsif cursor.chain.links.length > 1
|
35
|
+
type = ComplexType.parse(full)
|
36
|
+
else
|
37
|
+
type = ComplexType::UNDEFINED
|
38
|
+
end
|
39
|
+
end
|
29
40
|
result.concat api_map.get_constants(type.undefined? ? '' : type.namespace, cursor.start_of_constant? ? '' : context_pin.context.namespace)
|
30
41
|
else
|
42
|
+
type = cursor.chain.base.infer(api_map, context_pin, locals)
|
31
43
|
result.concat api_map.get_complex_type_methods(type, context_pin.context.namespace, cursor.chain.links.length == 1)
|
32
44
|
if cursor.chain.links.length == 1
|
33
45
|
if cursor.word.start_with?('@@')
|
@@ -279,7 +279,7 @@ module Solargraph
|
|
279
279
|
end
|
280
280
|
end
|
281
281
|
end
|
282
|
-
elsif c.type == :send
|
282
|
+
elsif c.type == :send && [:attr_reader, :attr_writer, :attr_accessor].include?(c.children[1])
|
283
283
|
c.children[2..-1].each do |a|
|
284
284
|
if c.children[1] == :attr_reader or c.children[1] == :attr_accessor
|
285
285
|
pins.push Solargraph::Pin::Attribute.new(get_node_location(c), fqn || '', "#{a.children[0]}", comments_for(c), :reader, scope, visibility)
|
@@ -288,10 +288,19 @@ module Solargraph
|
|
288
288
|
pins.push Solargraph::Pin::Attribute.new(get_node_location(c), fqn || '', "#{a.children[0]}=", comments_for(c), :writer, scope, visibility)
|
289
289
|
end
|
290
290
|
end
|
291
|
-
elsif c.type == :
|
291
|
+
elsif c.type == :alias
|
292
|
+
pin = pins.select{|p| p.name == c.children[1].children[0].to_s && p.namespace == fqn && p.scope == scope}.first
|
293
|
+
unless pin.nil?
|
294
|
+
if pin.is_a?(Solargraph::Pin::Method)
|
295
|
+
pins.push Solargraph::Pin::Method.new(get_node_location(c), pin.namespace, c.children[0].children[0].to_s, comments_for(c) || pin.comments, pin.scope, pin.visibility, pin.parameters)
|
296
|
+
elsif pin.is_a?(Solargraph::Pin::Attribute)
|
297
|
+
pins.push Solargraph::Pin::Attribute.new(get_node_location(c), pin.namespace, c.children[0].children[0].to_s, comments_for(c) || pin.comments, pin.access, pin.scope, pin.visibility)
|
298
|
+
end
|
299
|
+
end
|
300
|
+
elsif c.type == :sclass && c.children[0].type == :self
|
292
301
|
process c, tree, :public, :class, fqn || '', stack
|
293
302
|
next
|
294
|
-
elsif c.type == :send
|
303
|
+
elsif c.type == :send && c.children[1] == :require
|
295
304
|
if c.children[2].kind_of?(AST::Node) and c.children[2].type == :str
|
296
305
|
# @requires.push Solargraph::Pin::Reference.new(get_node_location(c), fqn, c.children[2].children[0].to_s)
|
297
306
|
pins.push Pin::Reference::Require.new(get_node_location(c), c.children[2].children[0].to_s)
|
data/lib/solargraph/version.rb
CHANGED
data/lib/solargraph/yard_map.rb
CHANGED
@@ -122,7 +122,15 @@ module Solargraph
|
|
122
122
|
if code_object.is_a?(YARD::CodeObjects::NamespaceObject)
|
123
123
|
result.push Solargraph::Pin::YardPin::Namespace.new(code_object, location)
|
124
124
|
if code_object.is_a?(YARD::CodeObjects::ClassObject) and !code_object.superclass.nil?
|
125
|
-
|
125
|
+
# @todo This method of superclass detection is a bit of a hack. If
|
126
|
+
# the superclass is a Proxy, it is assumed to be undefined in its
|
127
|
+
# yardoc and converted to a fully qualified namespace.
|
128
|
+
if code_object.superclass.is_a?(YARD::CodeObjects::Proxy)
|
129
|
+
superclass = "::#{code_object.superclass}"
|
130
|
+
else
|
131
|
+
superclass = code_object.superclass.to_s
|
132
|
+
end
|
133
|
+
result.push Solargraph::Pin::Reference::Superclass.new(location, code_object.path, superclass)
|
126
134
|
end
|
127
135
|
code_object.class_mixins.each do |m|
|
128
136
|
result.push Solargraph::Pin::Reference::Extend.new(location, code_object.path, m.path)
|
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.28.
|
4
|
+
version: 0.28.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: 2018-
|
11
|
+
date: 2018-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|