solargraph 0.12.2 → 0.13.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 +1 -0
- data/lib/solargraph/api_map.rb +179 -431
- data/lib/solargraph/api_map/cache.rb +4 -0
- data/lib/solargraph/api_map/config.rb +1 -1
- data/lib/solargraph/api_map/source.rb +297 -0
- data/lib/solargraph/code_map.rb +81 -134
- data/lib/solargraph/pin.rb +12 -0
- data/lib/solargraph/pin/attribute.rb +16 -0
- data/lib/solargraph/pin/base.rb +47 -0
- data/lib/solargraph/pin/base_variable.rb +33 -0
- data/lib/solargraph/pin/class_variable.rb +6 -0
- data/lib/solargraph/pin/constant.rb +18 -0
- data/lib/solargraph/pin/instance_variable.rb +12 -0
- data/lib/solargraph/pin/method.rb +65 -0
- data/lib/solargraph/pin/symbol.rb +9 -0
- data/lib/solargraph/server.rb +15 -7
- data/lib/solargraph/shell.rb +7 -0
- data/lib/solargraph/suggestion.rb +7 -2
- data/lib/solargraph/version.rb +1 -1
- data/lib/solargraph/yard_map.rb +1 -1
- data/lib/solargraph/yard_methods.rb +28 -1
- metadata +12 -6
- data/lib/solargraph/api_map/attr_pin.rb +0 -37
- data/lib/solargraph/api_map/cvar_pin.rb +0 -27
- data/lib/solargraph/api_map/ivar_pin.rb +0 -29
- data/lib/solargraph/api_map/method_pin.rb +0 -56
@@ -1,27 +0,0 @@
|
|
1
|
-
module Solargraph
|
2
|
-
class ApiMap
|
3
|
-
class CvarPin
|
4
|
-
attr_reader :node
|
5
|
-
attr_reader :namespace
|
6
|
-
attr_reader :docstring
|
7
|
-
|
8
|
-
def initialize api_map, node, namespace, docstring
|
9
|
-
@api_map = api_map
|
10
|
-
@node = node
|
11
|
-
@namespace = namespace
|
12
|
-
@docstring = docstring
|
13
|
-
end
|
14
|
-
|
15
|
-
def suggestion
|
16
|
-
@suggestion ||= generate_suggestion
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
|
21
|
-
def generate_suggestion
|
22
|
-
type = @api_map.infer_assignment_node_type(node, namespace)
|
23
|
-
Suggestion.new(node.children[0], kind: Suggestion::VARIABLE, documentation: docstring, return_type: type)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
module Solargraph
|
2
|
-
class ApiMap
|
3
|
-
class IvarPin
|
4
|
-
attr_reader :node
|
5
|
-
attr_reader :namespace
|
6
|
-
attr_reader :scope
|
7
|
-
attr_reader :docstring
|
8
|
-
|
9
|
-
def initialize api_map, node, namespace, scope, docstring
|
10
|
-
@api_map = api_map
|
11
|
-
@node = node
|
12
|
-
@namespace = namespace
|
13
|
-
@scope = scope
|
14
|
-
@docstring = docstring
|
15
|
-
end
|
16
|
-
|
17
|
-
def suggestion
|
18
|
-
@suggestion ||= generate_suggestion
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def generate_suggestion
|
24
|
-
type = @api_map.infer_assignment_node_type(node, namespace)
|
25
|
-
Suggestion.new(node.children[0], kind: Suggestion::VARIABLE, documentation: docstring, return_type: type)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
module Solargraph
|
2
|
-
class ApiMap
|
3
|
-
class MethodPin
|
4
|
-
attr_reader :node
|
5
|
-
attr_reader :namespace
|
6
|
-
attr_reader :scope
|
7
|
-
attr_reader :visibility
|
8
|
-
attr_reader :docstring
|
9
|
-
|
10
|
-
def initialize node, namespace, scope, visibility, docstring
|
11
|
-
@node = node
|
12
|
-
@namespace = namespace
|
13
|
-
@scope = scope
|
14
|
-
@visibility = visibility
|
15
|
-
@docstring = docstring
|
16
|
-
end
|
17
|
-
|
18
|
-
def suggestion(api_map)
|
19
|
-
@suggestion ||= generate_suggestion(api_map)
|
20
|
-
end
|
21
|
-
|
22
|
-
private
|
23
|
-
|
24
|
-
def generate_suggestion(api_map)
|
25
|
-
i = node.type == :def ? 0 : 1
|
26
|
-
label = "#{node.children[i]}"
|
27
|
-
Suggestion.new(label, insert: node.children[i].to_s.gsub(/=/, ' = '), kind: Suggestion::METHOD, documentation: docstring, detail: namespace, arguments: get_method_args(api_map))
|
28
|
-
end
|
29
|
-
|
30
|
-
# @return [Array<String>]
|
31
|
-
def get_method_args(api_map)
|
32
|
-
list = nil
|
33
|
-
args = []
|
34
|
-
node.children.each { |c|
|
35
|
-
if c.kind_of?(AST::Node) and c.type == :args
|
36
|
-
list = c
|
37
|
-
break
|
38
|
-
end
|
39
|
-
}
|
40
|
-
return args if list.nil?
|
41
|
-
list.children.each { |c|
|
42
|
-
if c.type == :arg
|
43
|
-
args.push c.children[0].to_s
|
44
|
-
elsif c.type == :optarg
|
45
|
-
args.push "#{c.children[0]} = #{api_map.code_for(c.children[1])}"
|
46
|
-
elsif c.type == :kwarg
|
47
|
-
args.push "#{c.children[0]}:"
|
48
|
-
elsif c.type == :kwoptarg
|
49
|
-
args.push "#{c.children[0]}: #{api_map.code_for(c.children[1])}"
|
50
|
-
end
|
51
|
-
}
|
52
|
-
args
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|