-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode_callees.lua
More file actions
52 lines (42 loc) · 1.4 KB
/
code_callees.lua
File metadata and controls
52 lines (42 loc) · 1.4 KB
1
2
3
4
5
6
7
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
-- MCP Tool: code_callees
-- What does a function/method call internally? (downward)
-- Entry kind: function.lua
local tools = require("tools")
local fmt = require("fmt")
local function call(arguments)
if not arguments.symbol or arguments.symbol == "" then
return tools.format_error("'symbol' parameter is required")
end
local result, err = tools.request("query:callees", {
symbol = arguments.symbol,
depth = arguments.depth or 2,
project = arguments.project,
})
if err then return tools.format_error(err) end
local lines = {}
table.insert(lines, "# Callees of " .. result.name)
table.insert(lines, "")
local tree_lines = fmt.render_tree(result, {max_depth = arguments.depth or 2})
for _, l in ipairs(tree_lines) do
table.insert(lines, l)
end
-- Count resolved vs unresolved
local resolved, unresolved = 0, 0
local function count(node)
for _, child in ipairs(node.children or {}) do
if child.annotation == "unresolved" then
unresolved = unresolved + 1
else
resolved = resolved + 1
end
count(child)
end
end
count(result)
table.insert(lines, "")
table.insert(lines, string.format(
"Resolved: %d | Unresolved: %d", resolved, unresolved
))
return table.concat(lines, "\n")
end
return { call = call }