solargraph 0.8.5 → 0.8.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/solargraph/api_map.rb +11 -7
- data/lib/solargraph/code_map.rb +3 -25
- data/lib/solargraph/server.rb +1 -1
- data/lib/solargraph/suggestion.rb +12 -6
- data/lib/solargraph/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 02c54193138513541a17e784338430260259b223
|
4
|
+
data.tar.gz: f464a3a964e88b6f82d250e065d92e0062c3a135
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b548477ca4dc01db1785654d68d779a1ae3e29fb29c7702efc006ce2abfd8101df8735395328bb11db9a19abfc568d93896fadc392c8eb9af4126450fb7df162
|
7
|
+
data.tar.gz: dd27df9547f7dddfff89b98af23cf61d9dfaeb5937f790885c30607b7ccc7f3d5151132fb1affa8183b4f766d257731129b504a1dbcc43c1791deec07f719a7c
|
data/lib/solargraph/api_map.rb
CHANGED
@@ -405,10 +405,15 @@ module Solargraph
|
|
405
405
|
}
|
406
406
|
return args if list.nil?
|
407
407
|
list.children.each { |c|
|
408
|
+
STDERR.puts "Args child is #{c.type}"
|
408
409
|
if c.type == :arg
|
409
410
|
args.push c.children[0]
|
410
|
-
elsif c.type == :
|
411
|
+
elsif c.type == :optarg
|
412
|
+
args.push "#{c.children[0]} = _"
|
413
|
+
elsif c.type == :kwarg
|
411
414
|
args.push "#{c.children[0]}:"
|
415
|
+
elsif c.type == :kwoptarg
|
416
|
+
args.push "#{c.children[0]}: _"
|
412
417
|
end
|
413
418
|
}
|
414
419
|
args
|
@@ -475,18 +480,17 @@ module Solargraph
|
|
475
480
|
if workspace.nil?
|
476
481
|
STDERR.puts "No workspace specified for yardoc update."
|
477
482
|
else
|
478
|
-
|
479
|
-
|
480
|
-
STDERR.puts "Updating the yardoc..."
|
481
|
-
globs = yard_options[:include] - yard_options[:exclude]
|
483
|
+
Thread.new {
|
484
|
+
Dir.chdir(workspace) do
|
485
|
+
STDERR.puts "Updating the yardoc for #{workspace}..."
|
482
486
|
cmd = "yardoc -e #{Solargraph::YARD_EXTENSION_FILE}"
|
483
487
|
STDERR.puts "Update yardoc with #{cmd}"
|
484
488
|
STDERR.puts `#{cmd}`
|
485
489
|
unless $?.success?
|
486
490
|
STDERR.puts "There was an error processing the workspace yardoc."
|
487
491
|
end
|
488
|
-
|
489
|
-
|
492
|
+
end
|
493
|
+
}
|
490
494
|
end
|
491
495
|
end
|
492
496
|
|
data/lib/solargraph/code_map.rb
CHANGED
@@ -5,19 +5,15 @@ module Solargraph
|
|
5
5
|
attr_accessor :node
|
6
6
|
attr_reader :code
|
7
7
|
attr_reader :parsed
|
8
|
+
attr_reader :filename
|
8
9
|
attr_reader :workspace
|
9
10
|
|
10
11
|
include NodeMethods
|
11
12
|
|
12
13
|
def initialize code: '', filename: nil, workspace: nil, api_map: nil
|
13
|
-
unless workspace.nil?
|
14
|
-
workspace = workspace.gsub(File::ALT_SEPARATOR, File::SEPARATOR) unless File::ALT_SEPARATOR.nil?
|
15
|
-
end
|
16
|
-
if workspace.nil? and !filename.nil?
|
17
|
-
filename = filename.gsub(File::ALT_SEPARATOR, File::SEPARATOR) unless File::ALT_SEPARATOR.nil?
|
18
|
-
workspace = CodeMap.find_workspace(filename)
|
19
|
-
end
|
20
14
|
@workspace = workspace
|
15
|
+
# HACK: Adjust incoming filename's path separator for yardoc file comparisons
|
16
|
+
filename = filename.gsub(File::ALT_SEPARATOR, File::SEPARATOR) unless filename.nil? or File::ALT_SEPARATOR.nil?
|
21
17
|
@filename = filename
|
22
18
|
@api_map = api_map
|
23
19
|
@code = code.gsub(/\r/, '')
|
@@ -68,24 +64,6 @@ module Solargraph
|
|
68
64
|
@api_map ||= ApiMap.new(workspace)
|
69
65
|
end
|
70
66
|
|
71
|
-
def self.find_workspace filename
|
72
|
-
return nil if filename.nil?
|
73
|
-
dirname = filename
|
74
|
-
lastname = nil
|
75
|
-
result = nil
|
76
|
-
until dirname == lastname
|
77
|
-
if File.file?("#{dirname}/Gemfile")
|
78
|
-
result = dirname
|
79
|
-
break
|
80
|
-
end
|
81
|
-
lastname = dirname
|
82
|
-
dirname = File.dirname(dirname)
|
83
|
-
end
|
84
|
-
result ||= File.dirname(filename)
|
85
|
-
result.gsub!(File::ALT_SEPARATOR, File::SEPARATOR) unless File::ALT_SEPARATOR.nil?
|
86
|
-
result
|
87
|
-
end
|
88
|
-
|
89
67
|
# Get the offset of the specified line and column.
|
90
68
|
# The offset (also called the "index") is typically used to identify the
|
91
69
|
# cursor's location in the code when generating suggestions.
|
data/lib/solargraph/server.rb
CHANGED
@@ -20,7 +20,7 @@ module Solargraph
|
|
20
20
|
content_type :json
|
21
21
|
begin
|
22
22
|
sugg = []
|
23
|
-
workspace = params['workspace']
|
23
|
+
workspace = params['workspace']
|
24
24
|
Server.prepare_workspace workspace unless @@api_hash.has_key?(workspace)
|
25
25
|
@@semaphore.synchronize {
|
26
26
|
code_map = CodeMap.new(code: params['text'], filename: params['filename'], api_map: @@api_hash[workspace])
|
@@ -21,7 +21,7 @@ module Solargraph
|
|
21
21
|
@insert = insert || @label
|
22
22
|
@detail = detail
|
23
23
|
@code_object = code_object
|
24
|
-
@documentation =
|
24
|
+
@documentation = documentation
|
25
25
|
@location = location
|
26
26
|
@arguments = arguments
|
27
27
|
end
|
@@ -37,8 +37,14 @@ module Solargraph
|
|
37
37
|
def return_type
|
38
38
|
if code_object.nil?
|
39
39
|
unless documentation.nil?
|
40
|
-
|
41
|
-
|
40
|
+
if documentation.kind_of?(YARD::Docstring)
|
41
|
+
t = documentation.tag(:return)
|
42
|
+
return nil if t.nil?
|
43
|
+
return t.types[0]
|
44
|
+
else
|
45
|
+
match = documentation.match(/@return \[([a-z0-9:_]*)/i)
|
46
|
+
return match[1] unless match.nil?
|
47
|
+
end
|
42
48
|
end
|
43
49
|
else
|
44
50
|
o = code_object.tag(:overload)
|
@@ -55,10 +61,10 @@ module Solargraph
|
|
55
61
|
def documentation
|
56
62
|
if @documentation.nil?
|
57
63
|
unless @code_object.nil?
|
58
|
-
@documentation = @
|
64
|
+
@documentation = @code_object.docstring unless @code_object.docstring.nil?
|
59
65
|
end
|
60
66
|
end
|
61
|
-
@documentation
|
67
|
+
@documentation
|
62
68
|
end
|
63
69
|
|
64
70
|
def to_json args={}
|
@@ -71,7 +77,7 @@ module Solargraph
|
|
71
77
|
location: (@location.nil? ? nil : @location.to_s),
|
72
78
|
arguments: @arguments,
|
73
79
|
return_type: return_type,
|
74
|
-
documentation: documentation
|
80
|
+
documentation: @helper.html_markup_rdoc(documentation.to_s)
|
75
81
|
}
|
76
82
|
obj.to_json(args)
|
77
83
|
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.8.
|
4
|
+
version: 0.8.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Fred Snyder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: parser
|