8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/solargraph/arc/rails_api.rb', line 8
def global yard_map
return [] if yard_map.required.empty?
ann = File.read(File.dirname(__FILE__) + "/annotations.rb")
source = Solargraph::Source.load_string(ann, "annotations.rb")
map = Solargraph::SourceMap.map(source)
Solargraph.logger.debug("[Arc][Rails] found #{map.pins.size} pins in annotations")
overrides = YAML.load_file(File.dirname(__FILE__) + "/types.yml").map do |meth, data|
if data["return"]
Util.method_return(meth, data["return"])
elsif data["yieldself"]
Solargraph::Pin::Reference::Override.(
meth,
"@yieldself [#{data['yieldself'].join(',')}]"
)
elsif data["yieldparam"]
Solargraph::Pin::Reference::Override.(
meth,
"@yieldparam [#{data['yieldparam'].join(',')}]"
)
end
end
ns = Solargraph::Pin::Namespace.new(
name: "ActionController::Base",
gates: ["ActionController::Base"]
)
definitions = [
Util.build_public_method(
ns,
"response",
types: ["ActionDispatch::Response"],
location: Util.dummy_location("whatever.rb")
),
Util.build_public_method(
ns,
"request",
types: ["ActionDispatch::Request"],
location: Util.dummy_location("whatever.rb")
),
Util.build_public_method(
ns,
"session",
types: ["ActionDispatch::Request::Session"],
location: Util.dummy_location("whatever.rb")
),
Util.build_public_method(
ns,
"flash",
types: ["ActionDispatch::Flash::FlashHash"],
location: Util.dummy_location("whatever.rb")
)
]
map.pins + definitions + overrides
end
|