@codua/codeoutline-win32-x64 0.2.1 → 0.2.6
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.
- package/README.md +1 -0
- package/bin/xnet.exe +0 -0
- package/build-info.json +1 -1
- package/package.json +1 -1
- package/scripts/codeoutline/callers.lua +116 -0
- package/scripts/codeoutline/command.lua +7 -3
- package/scripts/codeoutline/common.lua +29 -3
- package/scripts/codeoutline/completion.lua +162 -62
- package/scripts/codeoutline/cpp_bindings.lua +116 -0
- package/scripts/codeoutline/cpp_types.lua +209 -0
- package/scripts/codeoutline/csharp_bindings.lua +498 -0
- package/scripts/codeoutline/dispatch_aliases.lua +474 -0
- package/scripts/codeoutline/documents.lua +11 -1
- package/scripts/codeoutline/explore.lua +73 -12
- package/scripts/codeoutline/foreign.lua +125 -0
- package/scripts/codeoutline/foreign_lua.lua +273 -0
- package/scripts/codeoutline/graph.lua +80 -22
- package/scripts/codeoutline/index.lua +15 -6
- package/scripts/codeoutline/index_worker.lua +15 -7
- package/scripts/codeoutline/indirect.lua +148 -50
- package/scripts/codeoutline/js_evidence.lua +30 -2
- package/scripts/codeoutline/js_resolution.lua +34 -0
- package/scripts/codeoutline/lang/csharp.lua +15 -3
- package/scripts/codeoutline/lang/lua.lua +17 -2
- package/scripts/codeoutline/lsp.lua +58 -34
- package/scripts/codeoutline/lua_bindings.lua +242 -34
- package/scripts/codeoutline/lua_literal.lua +38 -0
- package/scripts/codeoutline/main.lua +24 -3
- package/scripts/codeoutline/mcp.lua +13 -4
- package/scripts/codeoutline/navigation.lua +337 -96
- package/scripts/codeoutline/ordinary_bindings.lua +220 -0
- package/scripts/codeoutline/parse.lua +2 -0
- package/scripts/codeoutline/python_bindings.lua +112 -0
- package/scripts/codeoutline/query_report.lua +126 -0
- package/scripts/codeoutline/rules.lua +127 -0
- package/scripts/codeoutline/service.lua +11 -3
- package/scripts/codeoutline/static_dispatch.lua +534 -0
- package/scripts/codeoutline/update_sequence.lua +1 -1
- package/scripts/codeoutline/version.lua +1 -1
package/README.md
CHANGED
|
@@ -56,6 +56,7 @@ Three tools are provided:
|
|
|
56
56
|
| Tool | Purpose |
|
|
57
57
|
| --- | --- |
|
|
58
58
|
| `codeoutline_explore` | Query source, call paths, and callers/callees by symbol or file name (`query`; optional `projectPath`, `budget`) |
|
|
59
|
+
| `codeoutline_callers` | [Find recursive callers and affected files](docs/CALLERS.md) for an exact symbol/qualified name (`query`; optional `projectPath`, `depth` default 3, `max_nodes` default 200, `budget`) |
|
|
59
60
|
| `codeoutline_status` | Refresh and report index, cache, scanner, and parser statistics |
|
|
60
61
|
| `codeoutline_rebuild` | Rebuild fully, bypassing the cache |
|
|
61
62
|
|
package/bin/xnet.exe
CHANGED
|
Binary file
|
package/build-info.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"
|
|
1
|
+
{"version":"0.2.6","runtimeCommit":"d33491598d199b1a2f5fd3d9840c5b17d49b1e13","runtimeBuild":"b9b847244c68283df56e7858fe3daaafd35b756f0ff67cfa379f998133ddf29d","lua":"LuaJIT 2.1.1774896198","sourceCommit":"e738eb2dff955027fda8ecbe0b397d32d6911e03","sourceDirty":false,"releaseReady":true,"note":"Release build from a clean checkout","sha256":{"scripts/codeoutline/query_report.lua":"5e6052483514c1d3497fe90c2eb70235caed334b4a89411453a2a812f50c6246","scripts/codeoutline/command.lua":"e4bd7698e03dbca3728084454a2e9a4b1a9902e76c3d69b85107ffac80981716","scripts/codeoutline/rules.lua":"b01402863062435a6d31a4a5a90208319876fdb444a76c75fd0c45ea8ee6fee5","scripts/codeoutline/common.lua":"dc76e72f4c8de20f120962bb19bffaa0beafbeddad217fc95b028e4e7d94374a","scripts/codeoutline/service.lua":"91ac502048f8e5be4521284ca77f45af1a8f6421aff59c41361c88015a531b03","licenses/lua-cmsgpack.txt":"8edfdc5282278a1268d8a6ee52f9245f1a5fe3d1c8065be00330196b1de49873","scripts/codeoutline/completion.lua":"aa59fed11e6bcecb4e80a5df42911e05541c4b65bb9aefdd0e7f70b0e8fcfd22","scripts/codeoutline/static_dispatch.lua":"19a4f20ecc85e0e6d49d571fe4f5cc339b6ee6a9968d52d072c62ff4121bcaba","scripts/codeoutline/js_resolution.lua":"b921411cceae30190a0d637605d8f54105a9da907c57c9c361513720feba6dcc","scripts/codeoutline/control.lua":"b67a2e382e021f0793ef313aa4e71faab76f6cb77ca127f499d01ae96f36a8db","keys/update-public.pem":"7ff853339e19631b20ed3fa2cf221daa31c581e2e84d161b344b8f06de6562a8","keys/update-ca.crt":"d9b5ec3d4628de9c5559871f39841a5f84d47c53ded4d58d6e3bba2b4c669a02","lib/xhttp_codec.lua":"a5b0f127105ba6dbd4a518a214ca55e22c7510e6b2fc8c25c325898d8346ef8c","scripts/codeoutline/updater.lua":"267c4b6e9704fce710f44d1bfceac69c1857e34e064d8444d7890f0e10d921c7","licenses/libdeflate.txt":"41b60f2caab6bffdd5ba360687bd23ca653c0a1235c00380ecffc939b4cd8d75","scripts/codeoutline/cpp_types.lua":"b0904638c40bf621f965f9839d4c103dec96cadc98ec7c1b0fa689e379f41804","scripts/codeoutline/update_sequence.lua":"640a1b156e8ce2e54d9e63fd95d179eb07f551e6eeb752d5d36114a7b5867196","scripts/codeoutline/lang/c.lua":"9cd8abbdfda6cae5d6c04a9ae68bbd9f7589b217e88b7682917106e80df9b0c5","scripts/codeoutline/csharp_bindings.lua":"3a237f9a04c4cc2277ebfcbe902bdefecff125ef4a7c8d2d55e8284e916db0ab","scripts/codeoutline/update_worker.lua":"7e2ec28e4b911d7b90fd97d0a4c0e2f5b295d1a9200c5c7250e47a99139ca550","scripts/codeoutline/lang/cpp.lua":"47e3dc18cbc8b9a93567897e9ff69a026434a1971fe1dcc3e07d3af03c54a4f2","scripts/codeoutline/daemon.lua":"06863991135cc9a85f07bca8310296f0df9e415b3e2de97ae006393e777b009b","scripts/codeoutline/version.lua":"098b03a424dd1b59a945f4042470355ca854e3063108e89debca0070dc9145b0","scripts/codeoutline/lang/csharp.lua":"eac54f1664946e2d8278de8530878c14c91b432b62f9d0044e991164df3d0666","scripts/codeoutline/dispatch_aliases.lua":"40c85d2c76efd797cb9cf7355cd18bbac270aaa0fe724c3760695fe97187f83d","scripts/codeoutline/xscan.lua":"bd95a1b0b7022d029a41aab615897502478b5834612505e8d299343cb5ca8ef9","scripts/codeoutline/lang/go.lua":"3a62d4dc451b0d2f7f2aefd5e77d11449a5d725f59379728eba8dda0aacc13f3","scripts/codeoutline/documents.lua":"7e59a60085c68d756f57424925732e205e2559efbf1213716afa620acf0c6c43","scripts/codeoutline/indirect.lua":"ead34f11f48fdb11478f613dd69c83c00fdb4c2840e635da2d5315125395baf9","scripts/codeoutline/lang/java.lua":"0ea34298770cb3431f4bc3521c4d2ecf363d55e768d6cd30b3f11ad05d7e8f0d","scripts/codeoutline/explore.lua":"f9294a11c3155daa41f7a994886e4004fed940468c95d03c1b33859530186236","bin/xnet.exe":"1fa95f25f32f44e49250cda6642a8e6a975e42b3ee8922cbc591ec75ed530848","scripts/xupgate/client.lua":"967c29c1eeebd8596458025ab3237816a91591cca64236ea0e7ba1762814e6ba","scripts/codeoutline/lang/js.lua":"62570ddc38c974991763e11770059880b87ec87f14578891df9d935af6cb4786","scripts/codeoutline/foreign.lua":"a3eab94b652b94dfe2a11c2c33f0744201decdbb84fcbb6d2ef244f2826e9b6e","scripts/codeoutline/lang/kotlin.lua":"cefaad1c412cb42ea6b2027ad9f81ad38d8d821f05c1cfde7f89c600d745a708","scripts/codeoutline/foreign_lua.lua":"03640aa84ba2ba628a5b0d8a7f66285fe308107fdd196862164d29d7e4129660","scripts/codeoutline/mcp.lua":"d68f3648a31befeabb846faae3e13efe4f8c7406f6d9b14a1fab6c77014c6b50","scripts/xupgate/http_client.lua":"a189506c3d0fcc454f5e001fdeecdd6349a1019ea0970d11ce2fbfdf035166d6","scripts/codeoutline/graph.lua":"76350b773fc8366102acf471d8ef70bfebc5898eaeba6ded018041c4ecabd69e","DISTRIBUTION.md":"da4a1048fc9b44670fd6fcef97e7d92ac3f50d3523da1773930c49f7e2c38dc3","scripts/xupgate/http_codec.lua":"a5b0f127105ba6dbd4a518a214ca55e22c7510e6b2fc8c25c325898d8346ef8c","scripts/codeoutline/lang/python.lua":"1ae8f1658e25220ec4d952c17ed817bfc92d0c45d4585d3dd4716d5585b60cc6","scripts/codeoutline/http.lua":"3d957628ecc9592d57cc68a61e5d4229a71da501eb8fb3aa0bbb5e1cd772adf0","scripts/xupgate/proxy.lua":"5bf532e7005f44555d6a5277336e5ad395af060585c13a1cdc2441de50e0dcff","scripts/codeoutline/ordinary_bindings.lua":"63bb8d660a74d67c370641793ab983e9b203c344253535ee32b5530d2365a700","scripts/codeoutline/lang/rust.lua":"294cee85786caaa5f29dedd5058877c7a4786349431faf33b36357ef69406a9e","scripts/codeoutline/index.lua":"f258c8085c5a93ac57c9ae9d21ee92c2be4850e21672b8af650dfee8ecbbc48e","scripts/xupgate/signature.lua":"f07de8a4093d08cc69d3c1d8296d23318c5d81344ece788d4453a9b3b700f000","scripts/codeoutline/parse.lua":"52eadb0b4b5bb5db2f6064170414377c5a23e2b24b3409ae00b9969273076435","scripts/codeoutline/lsp.lua":"5403311a9fd5cdc85bcbe158c35d5f1515d279f8374fc41d1f0c694a629ba824","codeoutline":"3d3970e488e077e8acd67d174b506a361d43578b3360c7b29f2ec3f0103ba899","scripts/codeoutline/parse_pool.lua":"acaafe74a568ec450e428f4a1a2ff704834588bba0f8b808e4c7a1d552861941","scripts/codeoutline/lua_bindings.lua":"e8c8a44dffd7e263dcfb321682c382d3d9d691495dbcb143a049532859d4ed53","codeoutline.cmd":"607b60c6d107becdb6793df8f41aaf2cff944baf69f5ece59dba990d0f24c13b","THIRD_PARTY.md":"a0d596a8600c5244b27c1426a81b4ec7046d213d733ec6b4287a4b1e8db501b5","README.zh-CN.md":"fea0ffb9835e1b78925b1aa0a6a3019591e376d23e94da5b4f58773601e2d7da","README.md":"b58cd12615dd7b796c3a3e8ce86ec0adb36a92f7d32025eed1fb78a843616fcf","scripts/codeoutline/parse_worker.lua":"c5f1745d15332c5040b1e97f6da08f2f456d9afe7c2491275cc97d7113b75e45","scripts/codeoutline/lua_literal.lua":"5fdd90a872988622337410c7e516d41b789ce4326c4aa6dddcd61998fe5aef90","licenses/mbedtls.txt":"9b405ef4c89342f5eae1dd828882f931747f71001cfba7d114801039b52ad09b","licenses/luajit.txt":"1b10a02c9474cb908da2d87bc908edd8798f9ad28d9a8c53fbd05c13227f7394","LICENSE":"1b63179362acd482b4a9a07ca526b3fce6d9103dcded361de2159ade174568b6","licenses/xnet2lua.txt":"1aa8af3df70f60f1ebf2d23e14c27af1606057ad9c32a9a0d15fd76cff257532","scripts/codeoutline/path.lua":"407bd960c1ad04e5006b321ce33263393bb40eee5dee5c123be9b36d3ad10937","scripts/codeoutline/main.lua":"0e1731a4e931ed8cc3ec42c537bb61c22094c3462fe7c20ed49ed7831ce71bd4","scripts/codeoutline/callers.lua":"d5b11e92bd32a823f1d198a6e7b4dca73e15daa4713762cf29d1062f26ec20d6","scripts/codeoutline/lang/lua.lua":"f50a169549475d5d71f8af920feeb82797e8f24ccfe0c3f416abc5a32e942713","scripts/codeoutline/js_evidence.lua":"494f6f90c3da2eee0e8f6b21f8ce364802ed1ee710e74c443f1cfbbd575859f6","scripts/codeoutline/navigation.lua":"69001bab3763fb974a66cdeab5fe88c8b52f7e9229f8243ad6a30a26932c3418","scripts/codeoutline/python_bindings.lua":"e33a0ff223cf3b3292cbe9ed728aa32f6c5cab47d1843d6797ae670b74a3c580","scripts/codeoutline/index_worker.lua":"ad6b300fcca6f2eadb0373179d1c5c3321319a3ab0cae3d9a8996ce760e55671","scripts/codeoutline/cpp_bindings.lua":"b302b0a0e99846853ec75532a5a10e5da2f6738f512ca7b6f57fa98aaed17018","scripts/xupgate/common.lua":"86267648c0dbbd3a05f90de4d6e1dbee53ba57bf4801783c2ae636224b1f228c","scripts/codeoutline/cli.lua":"f7ac4addd32ced58069954cb81edd4836c6043bb5d143683b80bd7b11554c733","scripts/codeoutline/text.lua":"75f9af87ff5ce62def74f69d8972a6b11ff660723fc5cf515369ee3012ff0675"},"target":"win32-x64","updateSequence":15}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"
|
|
1
|
+
{"name":"@codua/codeoutline-win32-x64","version":"0.2.6","files":["bin/","lib/","keys/","scripts/","licenses/","LICENSE","codeoutline","codeoutline.cmd","build-info.json","*.md"],"os":["win32"],"publishConfig":{"access":"public"},"description":"CodeOutline native runtime and Lua implementation for win32-x64","repository":{"url":"git+https://github.com/1dao/codeoutline.git","type":"git"},"cpu":["x64","arm64"],"license":"BSD-2-Clause"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
-- Reverse BFS over query-owned relationships. No persistent impact graph.
|
|
2
|
+
local graph = require('codeoutline.graph')
|
|
3
|
+
local control = require('codeoutline.control')
|
|
4
|
+
local text = require('codeoutline.text')
|
|
5
|
+
local M = {}
|
|
6
|
+
|
|
7
|
+
function M.validate(query, opts)
|
|
8
|
+
require('codeoutline.explore').validate(query, opts)
|
|
9
|
+
opts = opts or {}
|
|
10
|
+
for _, item in ipairs({ { 'depth', 3, 8 }, { 'max_nodes', 200, 2000 } }) do
|
|
11
|
+
local value = opts[item[1]]
|
|
12
|
+
if value == nil then value = item[2] end
|
|
13
|
+
assert(type(value) == 'number' and value % 1 == 0 and value >= 1 and value <= item[3],
|
|
14
|
+
item[1] .. ' must be an integer between 1 and ' .. item[3])
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
function M.run(symbols, idx, query, opts)
|
|
19
|
+
M.validate(query, opts)
|
|
20
|
+
opts = opts or {}
|
|
21
|
+
local depth, cap = opts.depth or 3, opts.max_nodes or 200
|
|
22
|
+
local budget = require('codeoutline.explore').validate(query, opts)
|
|
23
|
+
local Q = graph.query(symbols, opts)
|
|
24
|
+
local result = { targets = {}, callers = {}, files = {}, depth = depth,
|
|
25
|
+
node_limit_reached = false, depth_limit_reached = false }
|
|
26
|
+
local function describe(id)
|
|
27
|
+
return { id = id, name = Q.nodes[id].qualified, file = Q.files[Q.node_file[id]].path, line = Q.nodes[id].line }
|
|
28
|
+
end
|
|
29
|
+
local candidates = symbols.by_qualified[query] or symbols.by_name[query] or {}
|
|
30
|
+
local ordered = {}
|
|
31
|
+
for _, id in ipairs(candidates) do ordered[#ordered + 1] = id end
|
|
32
|
+
table.sort(ordered, function(a, b) return graph.before(Q, a, b) end)
|
|
33
|
+
local frontier, seen, next_hop = {}, {}, {}
|
|
34
|
+
for _, id in ipairs(ordered) do
|
|
35
|
+
if #frontier >= cap then result.node_limit_reached = true; break end
|
|
36
|
+
frontier[#frontier + 1] = id; seen[id] = true
|
|
37
|
+
result.targets[#result.targets + 1] = describe(id)
|
|
38
|
+
end
|
|
39
|
+
local files = {}
|
|
40
|
+
for level = 1, depth do
|
|
41
|
+
if #frontier == 0 then break end
|
|
42
|
+
control.check()
|
|
43
|
+
Q:load_incoming(frontier) -- one project reference scan per layer
|
|
44
|
+
local pending, links = {}, {}
|
|
45
|
+
for _, dst in ipairs(frontier) do
|
|
46
|
+
local edges = Q.inn[dst] or {}
|
|
47
|
+
for i = 1, #edges, graph.EDGE do
|
|
48
|
+
if i % 384 == 1 then control.check() end
|
|
49
|
+
local src = edges[i]
|
|
50
|
+
if not seen[src] and not links[src] then
|
|
51
|
+
links[src] = { target = dst, line = edges[i + 1], kind = edges[i + 2] }
|
|
52
|
+
pending[#pending + 1] = src
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
table.sort(pending, function(a, b) return graph.before(Q, a, b) end)
|
|
57
|
+
frontier = {}
|
|
58
|
+
for _, src in ipairs(pending) do
|
|
59
|
+
if #result.callers >= cap then result.node_limit_reached = true; break end
|
|
60
|
+
seen[src], next_hop[src] = true, links[src]
|
|
61
|
+
frontier[#frontier + 1] = src
|
|
62
|
+
local entry = describe(src)
|
|
63
|
+
entry.depth, entry.path = level, {}
|
|
64
|
+
local current = src
|
|
65
|
+
while next_hop[current] do
|
|
66
|
+
local hop = describe(current)
|
|
67
|
+
local edge = next_hop[current]
|
|
68
|
+
hop.call_line, hop.kind = edge.line, edge.kind
|
|
69
|
+
entry.path[#entry.path + 1] = hop
|
|
70
|
+
current = edge.target
|
|
71
|
+
end
|
|
72
|
+
entry.path[#entry.path + 1] = describe(current)
|
|
73
|
+
result.callers[#result.callers + 1] = entry
|
|
74
|
+
files[entry.file] = true
|
|
75
|
+
end
|
|
76
|
+
if level == depth and #frontier > 0 then result.depth_limit_reached = true end
|
|
77
|
+
if result.node_limit_reached then break end
|
|
78
|
+
end
|
|
79
|
+
for file in pairs(files) do result.files[#result.files + 1] = file end
|
|
80
|
+
table.sort(result.files)
|
|
81
|
+
-- Source validation may repair encodings and invalidate IDs: retry the query.
|
|
82
|
+
local paths = {}
|
|
83
|
+
for _, target in ipairs(result.targets) do paths[target.file] = true end
|
|
84
|
+
for _, file in ipairs(result.files) do paths[file] = true end
|
|
85
|
+
local changed = false
|
|
86
|
+
for path in pairs(paths) do
|
|
87
|
+
local source, repaired = idx:query_source(path)
|
|
88
|
+
assert(source, 'cannot read source: ' .. path)
|
|
89
|
+
changed = changed or repaired
|
|
90
|
+
end
|
|
91
|
+
if changed then return nil, { encoding_retry = true } end
|
|
92
|
+
local lines = { string.format('Matched %d target(s); %d potential callers in %d files, searched up to %d levels.',
|
|
93
|
+
#result.targets, #result.callers, #result.files, depth),
|
|
94
|
+
'Static potential impact; each caller has one shortest path. This is not proof of runtime execution or complete impact coverage.' }
|
|
95
|
+
if #result.targets == 0 then lines[#lines + 1] = 'No exact symbol matched; use a symbol name or qualified name.' end
|
|
96
|
+
if #result.targets > 1 then lines[#lines + 1] = 'Multiple definitions matched; results cover the listed targets.' end
|
|
97
|
+
if result.node_limit_reached then lines[#lines + 1] = 'Node limit reached; targets or callers were omitted.' end
|
|
98
|
+
if result.depth_limit_reached then lines[#lines + 1] = 'Depth limit reached; callers beyond this depth were not checked.' end
|
|
99
|
+
for _, target in ipairs(result.targets) do
|
|
100
|
+
lines[#lines + 1] = string.format('Target: %s (%s:%d)', target.name, target.file, target.line)
|
|
101
|
+
end
|
|
102
|
+
for _, entry in ipairs(result.callers) do
|
|
103
|
+
local path = {}
|
|
104
|
+
for _, hop in ipairs(entry.path) do
|
|
105
|
+
path[#path + 1] = string.format('%s (%s:%d)%s', hop.name, hop.file, hop.call_line or hop.line,
|
|
106
|
+
hop.kind and ' [' .. hop.kind .. ']' or '')
|
|
107
|
+
end
|
|
108
|
+
lines[#lines + 1] = string.format('Depth %d: %s', entry.depth, table.concat(path, ' -> '))
|
|
109
|
+
end
|
|
110
|
+
if #result.files > 0 then lines[#lines + 1] = 'Affected caller files:\n' .. table.concat(result.files, '\n') end
|
|
111
|
+
local output, cut = text.limit(table.concat(lines, '\n'), budget, result.node_limit_reached)
|
|
112
|
+
result.truncated, result.query_stats = cut, Q.stats
|
|
113
|
+
return output, result
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
return M
|
|
@@ -19,6 +19,7 @@ Usage:
|
|
|
19
19
|
codeoutline lsp --stdio [--project PATH]
|
|
20
20
|
codeoutline serve --http [--host HOST] [--port PORT] [--project PATH] [--allow-root PATH ...]
|
|
21
21
|
codeoutline explore --project PATH --query QUERY [--budget BYTES]
|
|
22
|
+
codeoutline callers --project PATH --query SYMBOL [--depth 3] [--max-nodes 200] [--budget BYTES]
|
|
22
23
|
codeoutline status [--project PATH]
|
|
23
24
|
codeoutline rebuild [--project PATH]
|
|
24
25
|
codeoutline doctor [--project PATH]
|
|
@@ -60,6 +61,7 @@ local function parse(args)
|
|
|
60
61
|
['allow-root'] = true, ['allow-host'] = true, ['allow-origin'] = true },
|
|
61
62
|
daemon = { port = true }, install = { port = true, npm = true }, uninstall = { port = true },
|
|
62
63
|
explore = { project = true, query = true, budget = true },
|
|
64
|
+
callers = { project = true, query = true, budget = true, depth = true, ['max-nodes'] = true },
|
|
63
65
|
update = { check = true, channel = true },
|
|
64
66
|
status = { project = true }, rebuild = { project = true }, doctor = { project = true },
|
|
65
67
|
}
|
|
@@ -237,11 +239,13 @@ local function run()
|
|
|
237
239
|
local root = options.project or '.'
|
|
238
240
|
if command == 'doctor' then return doctor(root) end
|
|
239
241
|
local svc = require('codeoutline.service')
|
|
240
|
-
if command == 'explore' then
|
|
241
|
-
assert(options.query, '
|
|
242
|
+
if command == 'explore' or command == 'callers' then
|
|
243
|
+
assert(options.query, command .. ' requires --query')
|
|
242
244
|
local budget
|
|
243
245
|
if options.budget then budget = assert(tonumber(options.budget), '--budget must be a number') end
|
|
244
|
-
local
|
|
246
|
+
local depth = options.depth and assert(tonumber(options.depth), '--depth must be a number')
|
|
247
|
+
local max_nodes = options['max-nodes'] and assert(tonumber(options['max-nodes']), '--max-nodes must be a number')
|
|
248
|
+
local text = svc[command](root, options.query, { budget = budget, depth = depth, max_nodes = max_nodes })
|
|
245
249
|
io.write(text, '\n')
|
|
246
250
|
else
|
|
247
251
|
io.write(xutils.json_pack(svc[command](root)), '\n')
|
|
@@ -24,7 +24,10 @@ local text = require('codeoutline.text')
|
|
|
24
24
|
|
|
25
25
|
function M.new(path, language, opts)
|
|
26
26
|
return { path = path, language = language, nodes = {}, refs = {}, imports = {},
|
|
27
|
-
ranges = not opts or opts.ranges ~= false, collect_dispatch = opts and opts.dispatch
|
|
27
|
+
ranges = not opts or opts.ranges ~= false, collect_dispatch = opts and opts.dispatch,
|
|
28
|
+
dispatch_only = opts and opts.dispatch_only, collect_static_dispatch = opts and opts.static_dispatch,
|
|
29
|
+
ordinary_bindings = opts and opts.ordinary_bindings,
|
|
30
|
+
collect_foreign = opts and opts.foreign, omit_signatures = opts and opts.omit_signatures }
|
|
28
31
|
end
|
|
29
32
|
|
|
30
33
|
-- Collapse a token span into a one-line signature.
|
|
@@ -131,18 +134,39 @@ end
|
|
|
131
134
|
|
|
132
135
|
-- Drop parser-internal fields so the result is plain data.
|
|
133
136
|
function M.finish(r, T)
|
|
137
|
+
if T and r.collect_foreign and (r.language == 'c' or r.language == 'cpp') then
|
|
138
|
+
require('codeoutline.foreign').collect(r, T)
|
|
139
|
+
end
|
|
140
|
+
r.collect_foreign = nil
|
|
134
141
|
M.assign_refs(r)
|
|
142
|
+
if T then require('codeoutline.static_dispatch').collect(r, T) end
|
|
143
|
+
r.collect_static_dispatch = nil
|
|
144
|
+
-- Query-only parse: preserve normal declaration/call attribution, but do
|
|
145
|
+
-- not build binding evidence or compact records that will be discarded.
|
|
146
|
+
if r.dispatch_only then
|
|
147
|
+
require('codeoutline.indirect').collect(r, T)
|
|
148
|
+
r.dispatch_only, r.collect_dispatch = nil, nil
|
|
149
|
+
return r
|
|
150
|
+
end
|
|
135
151
|
if T then require('codeoutline.js_evidence').collect(r, T) end
|
|
152
|
+
if T and r.ordinary_bindings then
|
|
153
|
+
require('codeoutline.python_bindings').collect(r, T)
|
|
154
|
+
require('codeoutline.cpp_bindings').collect(r, T)
|
|
155
|
+
if r.language == 'csharp' then require('codeoutline.csharp_bindings').collect(r, T) end
|
|
156
|
+
end
|
|
136
157
|
if T then require('codeoutline.indirect').collect(r, T) end
|
|
137
158
|
r.collect_dispatch = nil
|
|
138
159
|
local name, from, kind, line, recv = {}, {}, {}, {}, {}
|
|
139
160
|
local js_receiver = r.js_imports and {}
|
|
140
161
|
local lua_binding = r.lua_imports and {}
|
|
162
|
+
local binding = (r.python_imports or r.has_bindings) and {}
|
|
163
|
+
r.has_bindings = nil
|
|
141
164
|
local start, stop = r.ranges and T and {}, r.ranges and T and {}
|
|
142
165
|
for i, ref in ipairs(r.refs) do
|
|
143
166
|
name[i], from[i], kind[i], line[i], recv[i] = ref.name, ref.from, ref.kind, ref.line, ref.recv or false
|
|
144
167
|
if js_receiver then js_receiver[i] = ref.js_receiver or '' end
|
|
145
168
|
if lua_binding then lua_binding[i] = ref.lua_binding or '' end
|
|
169
|
+
if binding then binding[i] = ref.binding or '' end
|
|
146
170
|
if start then
|
|
147
171
|
local named = T:text(ref.tok) == ref.name
|
|
148
172
|
start[i], stop[i] = named and T.s[ref.tok] - 1 or false, named and T.e[ref.tok] or false
|
|
@@ -151,20 +175,22 @@ function M.finish(r, T)
|
|
|
151
175
|
r.refs = { name = name, from = from, kind = kind, line = line, recv = recv, start = start or nil, stop = stop or nil }
|
|
152
176
|
r.refs.js_receiver = js_receiver
|
|
153
177
|
r.refs.lua_binding = lua_binding
|
|
178
|
+
r.refs.binding = binding
|
|
154
179
|
for i, n in ipairs(r.nodes) do
|
|
155
180
|
n.ti, n.tj = nil, nil
|
|
156
181
|
if not r.ranges then
|
|
157
182
|
-- Rebuild: deleting keys does not shrink Lua table allocations.
|
|
158
183
|
local compact = {}
|
|
159
184
|
for key, value in pairs(n) do
|
|
160
|
-
if key ~= 'start_byte' and key ~= 'end_byte' and key ~= 'name_start' and key ~= 'name_end'
|
|
185
|
+
if key ~= 'start_byte' and key ~= 'end_byte' and key ~= 'name_start' and key ~= 'name_end'
|
|
186
|
+
and not (r.omit_signatures and key == 'sig') then
|
|
161
187
|
compact[key] = value
|
|
162
188
|
end
|
|
163
189
|
end
|
|
164
190
|
r.nodes[i] = compact
|
|
165
191
|
end
|
|
166
192
|
end
|
|
167
|
-
r.ranges = nil
|
|
193
|
+
r.ranges, r.omit_signatures = nil, nil
|
|
168
194
|
r.prefix, r.skip_calls = nil, nil
|
|
169
195
|
return r
|
|
170
196
|
end
|