solargraph 0.21.1 → 0.22.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/lib/solargraph.rb +0 -1
- data/lib/solargraph/api_map.rb +40 -23
- data/lib/solargraph/api_map/completion.rb +3 -0
- data/lib/solargraph/api_map/probe.rb +16 -19
- data/lib/solargraph/api_map/store.rb +6 -2
- data/lib/solargraph/diagnostics/rubocop.rb +6 -0
- data/lib/solargraph/language_server/host.rb +9 -1
- data/lib/solargraph/language_server/message.rb +3 -0
- data/lib/solargraph/language_server/message/extended.rb +1 -0
- data/lib/solargraph/language_server/message/extended/check_gem_version.rb +1 -1
- data/lib/solargraph/language_server/message/extended/download_core.rb +25 -0
- data/lib/solargraph/language_server/message/initialize.rb +3 -1
- data/lib/solargraph/language_server/message/text_document.rb +13 -11
- data/lib/solargraph/language_server/message/text_document/definition.rb +1 -1
- data/lib/solargraph/language_server/message/text_document/hover.rb +1 -1
- data/lib/solargraph/language_server/message/text_document/references.rb +14 -0
- data/lib/solargraph/language_server/message/text_document/rename.rb +17 -0
- data/lib/solargraph/language_server/uri_helpers.rb +2 -0
- data/lib/solargraph/library.rb +37 -0
- data/lib/solargraph/live_map.rb +8 -2
- data/lib/solargraph/live_map/cache.rb +7 -0
- data/lib/solargraph/pin.rb +1 -0
- data/lib/solargraph/pin/attribute.rb +5 -1
- data/lib/solargraph/pin/namespace.rb +0 -2
- data/lib/solargraph/pin/proxy_method.rb +31 -0
- data/lib/solargraph/plugin/process.rb +1 -1
- data/lib/solargraph/plugin/runtime.rb +0 -1
- data/lib/solargraph/shell.rb +0 -1
- data/lib/solargraph/source.rb +31 -1
- data/lib/solargraph/source/fragment.rb +12 -15
- data/lib/solargraph/source/location.rb +3 -0
- data/lib/solargraph/source/mapper.rb +20 -10
- data/lib/solargraph/source/node_methods.rb +111 -0
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/workspace.rb +7 -1
- data/lib/solargraph/workspace/config.rb +6 -2
- data/lib/solargraph/yard_map.rb +12 -1
- metadata +25 -7
- data/lib/solargraph/node_methods.rb +0 -101
@@ -0,0 +1,111 @@
|
|
1
|
+
module Solargraph
|
2
|
+
class Source
|
3
|
+
module NodeMethods
|
4
|
+
module_function
|
5
|
+
|
6
|
+
# @return [String]
|
7
|
+
def unpack_name(node)
|
8
|
+
pack_name(node).join("::")
|
9
|
+
end
|
10
|
+
|
11
|
+
# @return [Array<String>]
|
12
|
+
def pack_name(node)
|
13
|
+
parts = []
|
14
|
+
if node.kind_of?(AST::Node)
|
15
|
+
node.children.each { |n|
|
16
|
+
if n.kind_of?(AST::Node)
|
17
|
+
if n.type == :cbase
|
18
|
+
parts = pack_name(n)
|
19
|
+
else
|
20
|
+
parts += pack_name(n)
|
21
|
+
end
|
22
|
+
else
|
23
|
+
parts.push n unless n.nil?
|
24
|
+
end
|
25
|
+
}
|
26
|
+
end
|
27
|
+
parts
|
28
|
+
end
|
29
|
+
|
30
|
+
# @return [String]
|
31
|
+
def const_from node
|
32
|
+
if node.kind_of?(AST::Node) and node.type == :const
|
33
|
+
result = ''
|
34
|
+
unless node.children[0].nil?
|
35
|
+
result = const_from(node.children[0])
|
36
|
+
end
|
37
|
+
if result == ''
|
38
|
+
result = node.children[1].to_s
|
39
|
+
else
|
40
|
+
result = result + '::' + node.children[1].to_s
|
41
|
+
end
|
42
|
+
result
|
43
|
+
else
|
44
|
+
nil
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
# @return [String]
|
49
|
+
def infer_literal_node_type node
|
50
|
+
return nil unless node.kind_of?(AST::Node)
|
51
|
+
if node.type == :str or node.type == :dstr
|
52
|
+
return 'String'
|
53
|
+
elsif node.type == :array
|
54
|
+
return 'Array'
|
55
|
+
elsif node.type == :hash
|
56
|
+
return 'Hash'
|
57
|
+
elsif node.type == :int
|
58
|
+
return 'Integer'
|
59
|
+
elsif node.type == :float
|
60
|
+
return 'Float'
|
61
|
+
elsif node.type == :sym
|
62
|
+
return 'Symbol'
|
63
|
+
# @todo Maybe ignore nils
|
64
|
+
# elsif node.type == :nil
|
65
|
+
# return 'NilClass'
|
66
|
+
end
|
67
|
+
nil
|
68
|
+
end
|
69
|
+
|
70
|
+
# Get a call signature from a node.
|
71
|
+
# The result should be a string in the form of a method path, e.g.,
|
72
|
+
# String.new or variable.method.
|
73
|
+
#
|
74
|
+
# @return [String]
|
75
|
+
def resolve_node_signature node
|
76
|
+
result = drill_signature node, ''
|
77
|
+
return nil if result.empty?
|
78
|
+
result
|
79
|
+
end
|
80
|
+
|
81
|
+
def get_node_start_position(node)
|
82
|
+
Position.new(node.loc.line - 1, node.loc.column)
|
83
|
+
end
|
84
|
+
|
85
|
+
def get_node_end_position(node)
|
86
|
+
Position.new(node.loc.last_line - 1, node.loc.last_column)
|
87
|
+
end
|
88
|
+
|
89
|
+
def drill_signature node, signature
|
90
|
+
return signature unless node.kind_of?(AST::Node)
|
91
|
+
if node.type == :const or node.type == :cbase
|
92
|
+
unless node.children[0].nil?
|
93
|
+
signature += drill_signature(node.children[0], signature)
|
94
|
+
end
|
95
|
+
signature += '::' unless signature.empty?
|
96
|
+
signature += node.children[1].to_s
|
97
|
+
elsif node.type == :lvar or node.type == :ivar or node.type == :cvar
|
98
|
+
signature += '.' unless signature.empty?
|
99
|
+
signature += node.children[0].to_s
|
100
|
+
elsif node.type == :send
|
101
|
+
unless node.children[0].nil?
|
102
|
+
signature += drill_signature(node.children[0], signature)
|
103
|
+
end
|
104
|
+
signature += '.' unless signature.empty?
|
105
|
+
signature += node.children[1].to_s
|
106
|
+
end
|
107
|
+
signature
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
data/lib/solargraph/version.rb
CHANGED
data/lib/solargraph/workspace.rb
CHANGED
@@ -132,15 +132,21 @@ module Solargraph
|
|
132
132
|
|
133
133
|
def generate_require_paths
|
134
134
|
return [] if directory.nil?
|
135
|
-
return
|
135
|
+
return configured_require_paths unless gemspec?
|
136
136
|
result = []
|
137
137
|
gemspecs.each do |file|
|
138
138
|
spec = Gem::Specification.load(file)
|
139
139
|
base = File.dirname(file)
|
140
140
|
result.concat spec.require_paths.map{ |path| File.join(base, path) } unless spec.nil?
|
141
141
|
end
|
142
|
+
result.concat config.require_paths
|
142
143
|
result.push File.join(directory, 'lib') if result.empty?
|
143
144
|
result
|
144
145
|
end
|
146
|
+
|
147
|
+
def configured_require_paths
|
148
|
+
return [File.join(directory, 'lib')] if config.require_paths.empty?
|
149
|
+
config.require_paths.map{|p| File.join(directory, p)}
|
150
|
+
end
|
145
151
|
end
|
146
152
|
end
|
@@ -13,7 +13,7 @@ module Solargraph
|
|
13
13
|
def initialize workspace = nil
|
14
14
|
@workspace = workspace
|
15
15
|
include_globs = ['**/*.rb']
|
16
|
-
exclude_globs = ['spec/**/*', 'test/**/*', 'vendor/**/*']
|
16
|
+
exclude_globs = ['spec/**/*', 'test/**/*', 'vendor/**/*', '.bundle/**/*']
|
17
17
|
unless @workspace.nil?
|
18
18
|
sfile = File.join(@workspace, '.solargraph.yml')
|
19
19
|
if File.file?(sfile)
|
@@ -44,7 +44,7 @@ module Solargraph
|
|
44
44
|
end
|
45
45
|
|
46
46
|
# An array of files excluded from the workspace.
|
47
|
-
#
|
47
|
+
#
|
48
48
|
# @return [Array<String>]
|
49
49
|
def excluded
|
50
50
|
return [] if workspace.nil?
|
@@ -67,6 +67,10 @@ module Solargraph
|
|
67
67
|
raw_data['require']
|
68
68
|
end
|
69
69
|
|
70
|
+
def require_paths
|
71
|
+
raw_data['require_paths'] || []
|
72
|
+
end
|
73
|
+
|
70
74
|
def plugins
|
71
75
|
raw_data['plugins']
|
72
76
|
end
|
data/lib/solargraph/yard_map.rb
CHANGED
@@ -152,9 +152,20 @@ module Solargraph
|
|
152
152
|
ns = nil
|
153
153
|
ns = find_first_resolved_object(yard, namespace, scope)
|
154
154
|
unless ns.nil?
|
155
|
+
has_new = false
|
155
156
|
ns.meths(scope: :class, visibility: visibility).each { |m|
|
157
|
+
has_new = true if m.name == 'new'
|
156
158
|
meths.push Pin::YardObject.new(m, object_location(m))
|
157
159
|
}
|
160
|
+
# HACK: Convert #initialize to .new
|
161
|
+
if visibility.include?(:public) and !has_new
|
162
|
+
init = ns.meths(scope: :instance).select{|m| m.to_s.split(/[\.#]/).last == 'initialize'}.first
|
163
|
+
unless init.nil?
|
164
|
+
ip = Solargraph::Pin::YardObject.new(init, object_location(init))
|
165
|
+
np = Solargraph::Pin::Method.new(ip.location, ip.namespace, 'new', ip.docstring, :class, :public, ip.parameters)
|
166
|
+
meths.push np
|
167
|
+
end
|
168
|
+
end
|
158
169
|
# Collect superclass methods
|
159
170
|
if ns.kind_of?(YARD::CodeObjects::ClassObject) and !ns.superclass.nil?
|
160
171
|
meths += get_methods ns.superclass.to_s, '', visibility: [:public, :protected] unless ['Object', 'BasicObject', ''].include?(ns.superclass.to_s)
|
@@ -286,12 +297,12 @@ module Solargraph
|
|
286
297
|
unresolved_requires.clear
|
287
298
|
required.each do |r|
|
288
299
|
next if r.nil?
|
300
|
+
next if !workspace.nil? and workspace.would_require?(r)
|
289
301
|
begin
|
290
302
|
spec = Gem::Specification.find_by_path(r) || Gem::Specification.find_by_name(r.split('/').first)
|
291
303
|
ver = spec.version.to_s
|
292
304
|
ver = ">= 0" if ver.empty?
|
293
305
|
add_gem_dependencies spec
|
294
|
-
next if !workspace.nil? and workspace.would_require?(r)
|
295
306
|
yd = YARD::Registry.yardoc_file_for_gem(spec.name, ver)
|
296
307
|
@gem_paths[spec.name] = spec.full_gem_path
|
297
308
|
unresolved_requires.push r if yd.nil?
|
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.22.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: 2018-05-
|
11
|
+
date: 2018-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|
@@ -102,16 +102,16 @@ dependencies:
|
|
102
102
|
name: kramdown
|
103
103
|
requirement: !ruby/object:Gem::Requirement
|
104
104
|
requirements:
|
105
|
-
- - "
|
105
|
+
- - "~>"
|
106
106
|
- !ruby/object:Gem::Version
|
107
|
-
version: '
|
107
|
+
version: '1.16'
|
108
108
|
type: :runtime
|
109
109
|
prerelease: false
|
110
110
|
version_requirements: !ruby/object:Gem::Requirement
|
111
111
|
requirements:
|
112
|
-
- - "
|
112
|
+
- - "~>"
|
113
113
|
- !ruby/object:Gem::Version
|
114
|
-
version: '
|
114
|
+
version: '1.16'
|
115
115
|
- !ruby/object:Gem::Dependency
|
116
116
|
name: htmlentities
|
117
117
|
requirement: !ruby/object:Gem::Requirement
|
@@ -208,6 +208,20 @@ dependencies:
|
|
208
208
|
- - "~>"
|
209
209
|
- !ruby/object:Gem::Version
|
210
210
|
version: '0.14'
|
211
|
+
- !ruby/object:Gem::Dependency
|
212
|
+
name: pry
|
213
|
+
requirement: !ruby/object:Gem::Requirement
|
214
|
+
requirements:
|
215
|
+
- - "~>"
|
216
|
+
- !ruby/object:Gem::Version
|
217
|
+
version: 0.11.3
|
218
|
+
type: :development
|
219
|
+
prerelease: false
|
220
|
+
version_requirements: !ruby/object:Gem::Requirement
|
221
|
+
requirements:
|
222
|
+
- - "~>"
|
223
|
+
- !ruby/object:Gem::Version
|
224
|
+
version: 0.11.3
|
211
225
|
description: IDE tools for code completion and inline documentation
|
212
226
|
email: admin@castwide.com
|
213
227
|
executables:
|
@@ -249,6 +263,7 @@ files:
|
|
249
263
|
- lib/solargraph/language_server/message/extended/check_gem_version.rb
|
250
264
|
- lib/solargraph/language_server/message/extended/document.rb
|
251
265
|
- lib/solargraph/language_server/message/extended/document_gems.rb
|
266
|
+
- lib/solargraph/language_server/message/extended/download_core.rb
|
252
267
|
- lib/solargraph/language_server/message/extended/search.rb
|
253
268
|
- lib/solargraph/language_server/message/initialize.rb
|
254
269
|
- lib/solargraph/language_server/message/initialized.rb
|
@@ -267,6 +282,8 @@ files:
|
|
267
282
|
- lib/solargraph/language_server/message/text_document/formatting.rb
|
268
283
|
- lib/solargraph/language_server/message/text_document/hover.rb
|
269
284
|
- lib/solargraph/language_server/message/text_document/on_type_formatting.rb
|
285
|
+
- lib/solargraph/language_server/message/text_document/references.rb
|
286
|
+
- lib/solargraph/language_server/message/text_document/rename.rb
|
270
287
|
- lib/solargraph/language_server/message/text_document/signature_help.rb
|
271
288
|
- lib/solargraph/language_server/message/workspace.rb
|
272
289
|
- lib/solargraph/language_server/message/workspace/did_change_configuration.rb
|
@@ -282,7 +299,6 @@ files:
|
|
282
299
|
- lib/solargraph/library.rb
|
283
300
|
- lib/solargraph/live_map.rb
|
284
301
|
- lib/solargraph/live_map/cache.rb
|
285
|
-
- lib/solargraph/node_methods.rb
|
286
302
|
- lib/solargraph/page.rb
|
287
303
|
- lib/solargraph/pin.rb
|
288
304
|
- lib/solargraph/pin/attribute.rb
|
@@ -304,6 +320,7 @@ files:
|
|
304
320
|
- lib/solargraph/pin/method_parameter.rb
|
305
321
|
- lib/solargraph/pin/namespace.rb
|
306
322
|
- lib/solargraph/pin/plugin/method.rb
|
323
|
+
- lib/solargraph/pin/proxy_method.rb
|
307
324
|
- lib/solargraph/pin/reference.rb
|
308
325
|
- lib/solargraph/pin/symbol.rb
|
309
326
|
- lib/solargraph/pin/yard_object.rb
|
@@ -320,6 +337,7 @@ files:
|
|
320
337
|
- lib/solargraph/source/fragment.rb
|
321
338
|
- lib/solargraph/source/location.rb
|
322
339
|
- lib/solargraph/source/mapper.rb
|
340
|
+
- lib/solargraph/source/node_methods.rb
|
323
341
|
- lib/solargraph/source/position.rb
|
324
342
|
- lib/solargraph/source/range.rb
|
325
343
|
- lib/solargraph/source/updater.rb
|
@@ -1,101 +0,0 @@
|
|
1
|
-
module Solargraph
|
2
|
-
module NodeMethods
|
3
|
-
# @return [String]
|
4
|
-
def unpack_name(node)
|
5
|
-
pack_name(node).join("::")
|
6
|
-
end
|
7
|
-
|
8
|
-
# @return [Array<String>]
|
9
|
-
def pack_name(node)
|
10
|
-
parts = []
|
11
|
-
if node.kind_of?(AST::Node)
|
12
|
-
node.children.each { |n|
|
13
|
-
if n.kind_of?(AST::Node)
|
14
|
-
if n.type == :cbase
|
15
|
-
parts = pack_name(n)
|
16
|
-
else
|
17
|
-
parts += pack_name(n)
|
18
|
-
end
|
19
|
-
else
|
20
|
-
parts.push n unless n.nil?
|
21
|
-
end
|
22
|
-
}
|
23
|
-
end
|
24
|
-
parts
|
25
|
-
end
|
26
|
-
|
27
|
-
# @return [String]
|
28
|
-
def const_from node
|
29
|
-
if node.kind_of?(AST::Node) and node.type == :const
|
30
|
-
result = ''
|
31
|
-
unless node.children[0].nil?
|
32
|
-
result = const_from(node.children[0])
|
33
|
-
end
|
34
|
-
if result == ''
|
35
|
-
result = node.children[1].to_s
|
36
|
-
else
|
37
|
-
result = result + '::' + node.children[1].to_s
|
38
|
-
end
|
39
|
-
result
|
40
|
-
else
|
41
|
-
nil
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
# @return [String]
|
46
|
-
def infer_literal_node_type node
|
47
|
-
return nil unless node.kind_of?(AST::Node)
|
48
|
-
if node.type == :str or node.type == :dstr
|
49
|
-
return 'String'
|
50
|
-
elsif node.type == :array
|
51
|
-
return 'Array'
|
52
|
-
elsif node.type == :hash
|
53
|
-
return 'Hash'
|
54
|
-
elsif node.type == :int
|
55
|
-
return 'Integer'
|
56
|
-
elsif node.type == :float
|
57
|
-
return 'Float'
|
58
|
-
elsif node.type == :sym
|
59
|
-
return 'Symbol'
|
60
|
-
# @todo Maybe ignore nils
|
61
|
-
# elsif node.type == :nil
|
62
|
-
# return 'NilClass'
|
63
|
-
end
|
64
|
-
nil
|
65
|
-
end
|
66
|
-
|
67
|
-
# Get a call signature from a node.
|
68
|
-
# The result should be a string in the form of a method path, e.g.,
|
69
|
-
# String.new or variable.method.
|
70
|
-
#
|
71
|
-
# @return [String]
|
72
|
-
def resolve_node_signature node
|
73
|
-
result = drill_signature node, ''
|
74
|
-
return nil if result.empty?
|
75
|
-
result
|
76
|
-
end
|
77
|
-
|
78
|
-
private
|
79
|
-
|
80
|
-
def drill_signature node, signature
|
81
|
-
return signature unless node.kind_of?(AST::Node)
|
82
|
-
if node.type == :const or node.type == :cbase
|
83
|
-
unless node.children[0].nil?
|
84
|
-
signature += drill_signature(node.children[0], signature)
|
85
|
-
end
|
86
|
-
signature += '::' unless signature.empty?
|
87
|
-
signature += node.children[1].to_s
|
88
|
-
elsif node.type == :lvar or node.type == :ivar or node.type == :cvar
|
89
|
-
signature += '.' unless signature.empty?
|
90
|
-
signature += node.children[0].to_s
|
91
|
-
elsif node.type == :send
|
92
|
-
unless node.children[0].nil?
|
93
|
-
signature += drill_signature(node.children[0], signature)
|
94
|
-
end
|
95
|
-
signature += '.' unless signature.empty?
|
96
|
-
signature += node.children[1].to_s
|
97
|
-
end
|
98
|
-
signature
|
99
|
-
end
|
100
|
-
end
|
101
|
-
end
|