@codua/codeoutline-win32-x64 0.3.3 → 0.3.7
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 +13 -1
- package/README.zh-CN.md +11 -1
- package/bin/xnet.exe +0 -0
- package/build-info.json +1 -1
- package/editors/codeoutline.vsix +0 -0
- package/editors/zed/extension.wasm +0 -0
- package/package.json +1 -1
- package/scripts/codeoutline/{automatic_events.lua → analysis/automatic_events.lua} +4 -4
- package/scripts/codeoutline/{cpp_bindings.lua → analysis/cpp/cpp_bindings.lua} +7 -7
- package/scripts/codeoutline/{cpp_implementations.lua → analysis/cpp/cpp_implementations.lua} +3 -3
- package/scripts/codeoutline/{cpp_includes.lua → analysis/cpp/cpp_includes.lua} +3 -3
- package/scripts/codeoutline/{cpp_macros.lua → analysis/cpp/cpp_macros.lua} +3 -3
- package/scripts/codeoutline/{cpp_receivers.lua → analysis/cpp/cpp_receivers.lua} +7 -7
- package/scripts/codeoutline/{cpp_types.lua → analysis/cpp/cpp_types.lua} +5 -5
- package/scripts/codeoutline/{csharp_bindings.lua → analysis/csharp/csharp_bindings.lua} +78 -41
- package/scripts/codeoutline/{dispatch_aliases.lua → analysis/dispatch_aliases.lua} +3 -3
- package/scripts/codeoutline/{foreign.lua → analysis/foreign.lua} +2 -2
- package/scripts/codeoutline/{function_values.lua → analysis/function_values.lua} +2 -2
- package/scripts/codeoutline/analysis/go/go_frameworks.lua +327 -0
- package/scripts/codeoutline/{go_methods.lua → analysis/go/go_methods.lua} +2 -2
- package/scripts/codeoutline/{go_modules.lua → analysis/go/go_modules.lua} +2 -2
- package/scripts/codeoutline/{graph.lua → analysis/graph.lua} +53 -47
- package/scripts/codeoutline/{implementations.lua → analysis/implementations.lua} +18 -9
- package/scripts/codeoutline/{indirect.lua → analysis/indirect.lua} +71 -13
- package/scripts/codeoutline/{js_evidence.lua → analysis/js/js_evidence.lua} +4 -3
- package/scripts/codeoutline/{js_resolution.lua → analysis/js/js_resolution.lua} +2 -2
- package/scripts/codeoutline/{js_workspace.lua → analysis/js/js_workspace.lua} +2 -2
- package/scripts/codeoutline/{ts_implementations.lua → analysis/js/ts_implementations.lua} +3 -3
- package/scripts/codeoutline/{foreign_lua.lua → analysis/lua/foreign_lua.lua} +3 -3
- package/scripts/codeoutline/{lua_bindings.lua → analysis/lua/lua_bindings.lua} +136 -12
- package/scripts/codeoutline/{lua_callback_loops.lua → analysis/lua/lua_callback_loops.lua} +1 -1
- package/scripts/codeoutline/{ordinary_bindings.lua → analysis/ordinary_bindings.lua} +45 -21
- package/scripts/codeoutline/{python_bindings.lua → analysis/python/python_bindings.lua} +2 -2
- package/scripts/codeoutline/analysis/receivers.lua +559 -0
- package/scripts/codeoutline/{rust_packages.lua → analysis/rust/rust_packages.lua} +2 -2
- package/scripts/codeoutline/analysis/rust/rust_resolution.lua +609 -0
- package/scripts/codeoutline/{shared_events.lua → analysis/shared_events.lua} +3 -3
- package/scripts/codeoutline/{static_dispatch.lua → analysis/static_dispatch.lua} +5 -5
- package/scripts/codeoutline/{type_uses.lua → analysis/type_uses.lua} +1 -1
- package/scripts/codeoutline/cli.lua +1 -1
- package/scripts/codeoutline/command.lua +10 -8
- package/scripts/codeoutline/{cpp_fragments.lua → indexing/cpp_fragments.lua} +4 -4
- package/scripts/codeoutline/{index.lua → indexing/index.lua} +12 -12
- package/scripts/codeoutline/{parse_pool.lua → indexing/parse_pool.lua} +1 -1
- package/scripts/codeoutline/{agent_config.lua → install/agent_config.lua} +21 -1
- package/scripts/codeoutline/{agent_install.lua → install/agent_install.lua} +2 -2
- package/scripts/codeoutline/{editor_install.lua → install/editor_install.lua} +34 -6
- package/scripts/codeoutline/lang/c.lua +2 -2
- package/scripts/codeoutline/lang/cpp.lua +2 -2
- package/scripts/codeoutline/lang/csharp.lua +2 -2
- package/scripts/codeoutline/lang/go.lua +2 -2
- package/scripts/codeoutline/lang/java.lua +2 -2
- package/scripts/codeoutline/lang/js.lua +2 -2
- package/scripts/codeoutline/lang/kotlin.lua +4 -2
- package/scripts/codeoutline/lang/lua.lua +3 -3
- package/scripts/codeoutline/lang/python.lua +2 -2
- package/scripts/codeoutline/lang/rust.lua +3 -3
- package/scripts/codeoutline/main.lua +9 -9
- package/scripts/codeoutline/{common.lua → parsing/common.lua} +22 -17
- package/scripts/codeoutline/{language_detect.lua → parsing/language_detect.lua} +1 -1
- package/scripts/codeoutline/{parse.lua → parsing/parse.lua} +4 -4
- package/scripts/codeoutline/{http.lua → protocol/http.lua} +1 -1
- package/scripts/codeoutline/{lsp.lua → protocol/lsp.lua} +4 -4
- package/scripts/codeoutline/{mcp.lua → protocol/mcp.lua} +9 -9
- package/scripts/codeoutline/{affected.lua → query/affected.lua} +6 -6
- package/scripts/codeoutline/{callers.lua → query/callers.lua} +9 -9
- package/scripts/codeoutline/{completion.lua → query/completion.lua} +37 -49
- package/scripts/codeoutline/{definition_candidates.lua → query/definition_candidates.lua} +19 -13
- package/scripts/codeoutline/{documents.lua → query/documents.lua} +4 -4
- package/scripts/codeoutline/{explore.lua → query/explore.lua} +85 -25
- package/scripts/codeoutline/{external_headers.lua → query/external_headers.lua} +6 -6
- package/scripts/codeoutline/{navigation.lua → query/navigation.lua} +172 -57
- package/scripts/codeoutline/{on_demand.lua → query/on_demand.lua} +6 -6
- package/scripts/codeoutline/{query_report.lua → query/query_report.lua} +9 -5
- package/scripts/codeoutline/{search_ranking.lua → query/search_ranking.lua} +10 -7
- package/scripts/codeoutline/{type_hierarchy.lua → query/type_hierarchy.lua} +11 -11
- package/scripts/codeoutline/{type_references.lua → query/type_references.lua} +17 -17
- package/scripts/codeoutline/{index_worker.lua → runtime/index_worker.lua} +10 -10
- package/scripts/codeoutline/{parse_worker.lua → runtime/parse_worker.lua} +2 -2
- package/scripts/codeoutline/{update_worker.lua → runtime/update_worker.lua} +1 -1
- package/scripts/codeoutline/service.lua +11 -11
- package/scripts/codeoutline/update_sequence.lua +1 -1
- package/scripts/codeoutline/version.lua +1 -1
- package/scripts/codeoutline/rust_resolution.lua +0 -301
- /package/scripts/codeoutline/{lua_literal.lua → analysis/lua/lua_literal.lua} +0 -0
- /package/scripts/codeoutline/{resolution.lua → analysis/resolution.lua} +0 -0
- /package/scripts/codeoutline/{cargo_toml.lua → analysis/rust/cargo_toml.lua} +0 -0
- /package/scripts/codeoutline/{type_bases.lua → analysis/type_bases.lua} +0 -0
- /package/scripts/codeoutline/{cache_repairs.lua → indexing/cache_repairs.lua} +0 -0
- /package/scripts/codeoutline/{daemon.lua → install/daemon.lua} +0 -0
- /package/scripts/codeoutline/{install_prompt.lua → install/install_prompt.lua} +0 -0
- /package/scripts/codeoutline/{xscan.lua → parsing/xscan.lua} +0 -0
- /package/scripts/codeoutline/{lsp_trace.lua → protocol/lsp_trace.lua} +0 -0
- /package/scripts/codeoutline/{coverage.lua → query/coverage.lua} +0 -0
- /package/scripts/codeoutline/{query_filters.lua → query/query_filters.lua} +0 -0
- /package/scripts/codeoutline/{idle_gc.lua → runtime/idle_gc.lua} +0 -0
- /package/scripts/codeoutline/{control.lua → shared/control.lua} +0 -0
- /package/scripts/codeoutline/{path.lua → shared/path.lua} +0 -0
- /package/scripts/codeoutline/{rules.lua → shared/rules.lua} +0 -0
- /package/scripts/codeoutline/{text.lua → shared/text.lua} +0 -0
|
@@ -29,7 +29,7 @@ function M.collect(r, T)
|
|
|
29
29
|
local names, roots, seen = {}, {}, {}
|
|
30
30
|
for _, n in ipairs(r.nodes) do if callable[n.kind] then names[n.name] = true end end
|
|
31
31
|
if r.language ~= 'java' then
|
|
32
|
-
for _, imp in ipairs(require('codeoutline.dispatch_aliases').imports(r, T)) do
|
|
32
|
+
for _, imp in ipairs(require('codeoutline.analysis.dispatch_aliases').imports(r, T)) do
|
|
33
33
|
names[imp.name], roots[imp.name] = true, true
|
|
34
34
|
end
|
|
35
35
|
end
|
|
@@ -49,7 +49,7 @@ function M.collect(r, T)
|
|
|
49
49
|
if not changed then break end
|
|
50
50
|
end
|
|
51
51
|
for i = 1, T.n do
|
|
52
|
-
if i % 4096 == 0 then require('codeoutline.control').check() end
|
|
52
|
+
if i % 4096 == 0 then require('codeoutline.shared.control').check() end
|
|
53
53
|
if T.k[i] == 'id' and not seen[i] then
|
|
54
54
|
local prev, next = T:text(i - 1), T:text(i + 1)
|
|
55
55
|
local explicit = prev == '::' and r.language == 'java'
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
-- Query-only Go framework relationships. Registrations and generated bridges
|
|
2
|
+
-- are possibilities, never ordinary calls or persistent semantic records.
|
|
3
|
+
local M = { MAX_FILES = 64, MAX_BYTES = 8388608, MAX_SITES = 256, MAX_LINKS = 512,
|
|
4
|
+
MAX_CANDIDATES = 512, MAX_SCANNED_FILES = 4096, MAX_TIME_MS = 1500 }
|
|
5
|
+
local control = require('codeoutline.shared.control')
|
|
6
|
+
local verbs = { GET = true, POST = true, PUT = true, PATCH = true, DELETE = true,
|
|
7
|
+
OPTIONS = true, HEAD = true, Get = true, Post = true, Put = true, Patch = true, Delete = true }
|
|
8
|
+
local function framework(path)
|
|
9
|
+
if path == 'net/http' then return 'http' end
|
|
10
|
+
if path == 'github.com/gin-gonic/gin' then return 'gin' end
|
|
11
|
+
if path:match('^github%.com/labstack/echo') then return 'echo' end
|
|
12
|
+
if path:match('^github%.com/gofiber/fiber') then return 'fiber' end
|
|
13
|
+
if path:match('^github%.com/go%-chi/chi') then return 'chi' end
|
|
14
|
+
end
|
|
15
|
+
local function literal(T, i)
|
|
16
|
+
if T.k[i] ~= 'str' then return nil end
|
|
17
|
+
local raw = T:text(i)
|
|
18
|
+
if raw:sub(1, 1) == '`' then return raw:sub(2, -2) end
|
|
19
|
+
if raw:sub(1, 1) ~= '"' or raw:find('\\', 1, true) then return nil end
|
|
20
|
+
return raw:sub(2, -2)
|
|
21
|
+
end
|
|
22
|
+
local function parts(T, a, b)
|
|
23
|
+
local out, start, i = {}, a, a
|
|
24
|
+
while i <= b + 1 do
|
|
25
|
+
if i == b + 1 or T:text(i) == ',' then
|
|
26
|
+
if start < i then out[#out + 1] = { start, i - 1 } end
|
|
27
|
+
start = i + 1
|
|
28
|
+
elseif T.m[i] and T.m[i] > i then i = T.m[i] end
|
|
29
|
+
i = i + 1
|
|
30
|
+
end
|
|
31
|
+
return out
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
function M.collect(r, T)
|
|
35
|
+
if r.language ~= 'go' then return end
|
|
36
|
+
local D = { sites = {}, dispatchers = {}, assertions = {}, weight = 0, source_bytes = #T.src }
|
|
37
|
+
r.go_frameworks = D
|
|
38
|
+
local aliases = {}
|
|
39
|
+
for _, imp in ipairs(r.imports) do
|
|
40
|
+
local fw = framework(imp.path)
|
|
41
|
+
if fw then aliases[imp.alias or (fw == 'http' and 'http' or fw)] = fw end
|
|
42
|
+
end
|
|
43
|
+
local scopes, stack = {}, {}
|
|
44
|
+
for i = 1, T.n do
|
|
45
|
+
if i % 1024 == 0 then control.check() end
|
|
46
|
+
scopes[i] = stack[#stack] or 0
|
|
47
|
+
if T:text(i) == '{' and T.m[i] then stack[#stack + 1] = i
|
|
48
|
+
elseif T:text(i) == '}' and stack[#stack] and T.m[stack[#stack]] == i then stack[#stack] = nil end
|
|
49
|
+
end
|
|
50
|
+
local function visible(router, at)
|
|
51
|
+
if not router or router.token >= at then return false end
|
|
52
|
+
local scope = scopes[at]
|
|
53
|
+
while scope and scope ~= router.scope and scope ~= 0 do scope = scopes[scope] end
|
|
54
|
+
return scope == router.scope
|
|
55
|
+
end
|
|
56
|
+
local function add(list, entry)
|
|
57
|
+
if #list >= M.MAX_SITES then D.incomplete = true; return end
|
|
58
|
+
list[#list + 1] = entry; D.weight = D.weight + 512 + #(entry.route or '')
|
|
59
|
+
end
|
|
60
|
+
for id, n in ipairs(r.nodes) do
|
|
61
|
+
if n.kind == 'function' or n.kind == 'method' then
|
|
62
|
+
local routers, invalid = {}, {}
|
|
63
|
+
-- Receiver identities are deliberately local to one declaration.
|
|
64
|
+
-- Reassignments/shadows disable this cheap constructor evidence.
|
|
65
|
+
for i = n.ti, n.tj do
|
|
66
|
+
if i % 1024 == 0 then control.check() end
|
|
67
|
+
if T.k[i] == 'id' and (T:text(i + 1) == ':=' or T:text(i + 1) == '=') then
|
|
68
|
+
local name, root, method = T:text(i), T:text(i + 2), T:text(i + 4)
|
|
69
|
+
if routers[name] then invalid[name] = true end
|
|
70
|
+
if T:text(i + 3) == '.' and T:text(i + 5) == '(' then
|
|
71
|
+
local fw = aliases[root]
|
|
72
|
+
if fw and (method == 'New' or method == 'Default' or method == 'NewRouter' or method == 'NewServeMux') then
|
|
73
|
+
routers[name] = { framework = fw, prefix = '', token = i, scope = scopes[i], alias = root, at = T.s[i + 2] - 1 }
|
|
74
|
+
elseif not invalid[root] and visible(routers[root], i) and method == 'Group' then
|
|
75
|
+
local prefix = literal(T, i + 6)
|
|
76
|
+
if prefix then routers[name] = { framework = routers[root].framework,
|
|
77
|
+
prefix = routers[root].prefix .. prefix, token = i, scope = scopes[i],
|
|
78
|
+
alias = routers[root].alias, at = routers[root].at } end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
local dispatcher = false
|
|
84
|
+
for i = n.ti, n.tj do
|
|
85
|
+
if i % 1024 == 0 then control.check() end
|
|
86
|
+
local root, method = T:text(i), T:text(i + 2)
|
|
87
|
+
local router = not invalid[root] and routers[root]
|
|
88
|
+
if not visible(router, i) then router = nil end
|
|
89
|
+
local fw = router and router.framework or aliases[root] == 'http' and 'http'
|
|
90
|
+
if T.k[i] == 'id' and T:text(i + 1) == '.' and T:text(i + 3) == '(' and T.m[i + 3] and fw then
|
|
91
|
+
local args = parts(T, i + 4, T.m[i + 3] - 1)
|
|
92
|
+
local use = fw == 'gin' and method == 'Use'
|
|
93
|
+
local group = fw == 'gin' and method == 'Group'
|
|
94
|
+
local path = args[1] and args[1][1] == args[1][2] and literal(T, args[1][1])
|
|
95
|
+
local verb = verbs[method] and method:upper() or (method == 'Handle' or method == 'HandleFunc') and 'ANY'
|
|
96
|
+
if path and verb and fw == 'http' and verb == 'ANY' then
|
|
97
|
+
local v, p = path:match('^(%u+)%s+(/.*)$')
|
|
98
|
+
if v and ({ GET = true, POST = true, PUT = true, PATCH = true, DELETE = true,
|
|
99
|
+
HEAD = true, OPTIONS = true, CONNECT = true, TRACE = true })[v] then verb, path = v, p end
|
|
100
|
+
end
|
|
101
|
+
if use or (verb or group) and path and path:sub(1, 1) == '/' then
|
|
102
|
+
for a = use and 1 or 2, #args do
|
|
103
|
+
local first, last = args[a][1], args[a][2]
|
|
104
|
+
local name, recv
|
|
105
|
+
if first == last and T.k[first] == 'id' then name = T:text(first)
|
|
106
|
+
elseif last == first + 2 and T.k[first] == 'id' and T:text(first + 1) == '.' and T.k[last] == 'id' then
|
|
107
|
+
name, recv = T:text(last), T:text(first)
|
|
108
|
+
end
|
|
109
|
+
if name then add(D.sites, { from = id, name = name, recv = recv, at = T.s[first] - 1,
|
|
110
|
+
line = T:line(i), framework = fw, route = not (use or group) and (verb .. ' ' .. (router and router.prefix or '') .. path),
|
|
111
|
+
alias = router and router.alias or root, alias_at = router and router.at or T.s[i] - 1,
|
|
112
|
+
kind = (use or group) and 'middleware' or 'route' }) end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
if n.name == 'Next' and n.recv == 'Context' and T:text(i) == 'handlers'
|
|
117
|
+
and T:text(i + 1) == '[' and T.m[i + 1] and T:text(T.m[i + 1] + 1) == '(' then dispatcher = true end
|
|
118
|
+
-- protoc server handlers assert the registered server interface.
|
|
119
|
+
if r.path:match('_grpc%.pb%.go$') and T:text(i) == '.' and T:text(i + 1) == '(' and T.m[i + 1] then
|
|
120
|
+
local close = T.m[i + 1]
|
|
121
|
+
if close == i + 3 and T.k[i + 2] == 'id' and T:text(close + 1) == '.'
|
|
122
|
+
and T.k[close + 2] == 'id' and T:text(close + 3) == '(' then
|
|
123
|
+
add(D.assertions, { from = id, type = T:text(i + 2), name = T:text(close + 2), line = T:line(i) })
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
if dispatcher and r.package == 'gin' then D.dispatchers[id] = true; D.weight = D.weight + 32 end
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
function M.context(G, ctx, report)
|
|
133
|
+
local C = { incomplete = false, stats = { files = 0, bytes = 0, links = 0 } }
|
|
134
|
+
local cache, outgoing = {}, {}
|
|
135
|
+
local methods, deadline
|
|
136
|
+
local function expired()
|
|
137
|
+
control.check()
|
|
138
|
+
deadline = deadline or xtimer.now_ms() + M.MAX_TIME_MS
|
|
139
|
+
if xtimer.now_ms() > deadline then C.incomplete = true; return true end
|
|
140
|
+
return false
|
|
141
|
+
end
|
|
142
|
+
local modules = require('codeoutline.analysis.go.go_modules')
|
|
143
|
+
local function data(f)
|
|
144
|
+
if cache[f] then return cache[f] end
|
|
145
|
+
local rec = G.files[f]
|
|
146
|
+
if rec.language ~= 'go' then return nil end
|
|
147
|
+
local size = ctx.ordinary.source_size(f) or rec.go_frameworks and rec.go_frameworks.source_bytes or 0
|
|
148
|
+
if expired() or C.stats.files >= M.MAX_FILES or C.stats.bytes + size > M.MAX_BYTES then C.incomplete = true; return nil end
|
|
149
|
+
C.stats.files, C.stats.bytes = C.stats.files + 1, C.stats.bytes + size
|
|
150
|
+
local d = ctx.ordinary.data(f).go_frameworks or { sites = {}, dispatchers = {}, assertions = {} }
|
|
151
|
+
if size == 0 and d.source_bytes then
|
|
152
|
+
if C.stats.bytes + d.source_bytes > M.MAX_BYTES then C.incomplete = true; return nil end
|
|
153
|
+
C.stats.bytes = C.stats.bytes + d.source_bytes
|
|
154
|
+
end
|
|
155
|
+
cache[f] = d
|
|
156
|
+
if d.incomplete then C.incomplete = true end
|
|
157
|
+
return d
|
|
158
|
+
end
|
|
159
|
+
local function relevant(rec)
|
|
160
|
+
if rec.language ~= 'go' then return false end
|
|
161
|
+
if rec.package == 'gin' or rec.path:match('_grpc%.pb%.go$') then return true end
|
|
162
|
+
for _, imp in ipairs(rec.imports) do if framework(imp.path) then return true end end
|
|
163
|
+
for _, n in ipairs(rec.nodes) do if n.embedded and n.name:match('^Unimplemented.+Server$') then return true end end
|
|
164
|
+
return false
|
|
165
|
+
end
|
|
166
|
+
local function target(f, site)
|
|
167
|
+
if methods.bound(f, site.alias, site.alias_at) ~= nil then return {} end
|
|
168
|
+
if site.recv then
|
|
169
|
+
local receiver = methods.receiver(f, site.recv, site.at)
|
|
170
|
+
if receiver then
|
|
171
|
+
local out = {}; for _, m in ipairs(methods.members(receiver, f, site.name)) do
|
|
172
|
+
if m.kind == 'method' then out[#out + 1] = m.id end
|
|
173
|
+
end
|
|
174
|
+
return out
|
|
175
|
+
end
|
|
176
|
+
if receiver == false then return {} end
|
|
177
|
+
elseif methods.bound(f, site.name, site.at) ~= nil then return {} end
|
|
178
|
+
local out = {}
|
|
179
|
+
for _, id in ipairs(modules.resolve(G, f, site.name, site.recv, ctx) or {}) do
|
|
180
|
+
if G.nodes[id].kind == 'function' then out[#out + 1] = id end
|
|
181
|
+
end
|
|
182
|
+
return out
|
|
183
|
+
end
|
|
184
|
+
local function emit(out, source, dst, line, kind, registration)
|
|
185
|
+
if source == dst then return end
|
|
186
|
+
local label = 'possible:go-' .. kind
|
|
187
|
+
for _, e in ipairs(out) do if e.target == dst and e.line == line and e.kind == label then return end end
|
|
188
|
+
if C.stats.links >= M.MAX_LINKS then C.incomplete = true; return end
|
|
189
|
+
C.stats.links = C.stats.links + 1
|
|
190
|
+
out[#out + 1] = { target = dst, line = line, kind = label }
|
|
191
|
+
if report then report:add({ source = source, target = dst, line = line,
|
|
192
|
+
kind = 'possible Go ' .. kind .. ' (framework evidence; runtime execution unverified)', registered_at = registration }) end
|
|
193
|
+
end
|
|
194
|
+
local function signature(f, index)
|
|
195
|
+
local d = methods.data(f)
|
|
196
|
+
local sig = d and d.nodes[index] and d.nodes[index].signature
|
|
197
|
+
if not sig then return nil end
|
|
198
|
+
local aliases = modules.aliases(G, f, ctx)
|
|
199
|
+
local function key(t)
|
|
200
|
+
if not t then return nil end
|
|
201
|
+
if t.kind == 'name' then
|
|
202
|
+
local ids = methods.types(f, t.name)
|
|
203
|
+
if #ids == 1 then return 'type:' .. ids[1] end
|
|
204
|
+
local pkg, name = t.name:match('^([^.]+)%.(.+)$')
|
|
205
|
+
if pkg then return aliases[pkg] and aliases[pkg].path .. '.' .. name end
|
|
206
|
+
if ({ bool = true, byte = true, rune = true, string = true, error = true, any = true,
|
|
207
|
+
int = true, int8 = true, int16 = true, int32 = true, int64 = true, uint = true,
|
|
208
|
+
uint8 = true, uint16 = true, uint32 = true, uint64 = true, uintptr = true,
|
|
209
|
+
float32 = true, float64 = true, complex64 = true, complex128 = true })[t.name] then return t.name end
|
|
210
|
+
return nil
|
|
211
|
+
end
|
|
212
|
+
if t.kind == 'any' then return 'any' end
|
|
213
|
+
if t.kind == 'map' or t.kind == 'function' then return nil end
|
|
214
|
+
local child = key(t.child)
|
|
215
|
+
return child and t.kind .. ':' .. tostring(t.extra or '') .. ':' .. child or nil
|
|
216
|
+
end
|
|
217
|
+
local groups = {}
|
|
218
|
+
for _, list in ipairs({ sig.params, sig.results }) do
|
|
219
|
+
local items = {}; for _, t in ipairs(list) do local k = key(t); if not k then return nil end; items[#items + 1] = k end
|
|
220
|
+
groups[#groups + 1] = table.concat(items, ',')
|
|
221
|
+
end
|
|
222
|
+
return table.concat(groups, ' -> ')
|
|
223
|
+
end
|
|
224
|
+
function C.outgoing(id)
|
|
225
|
+
if outgoing[id] then return outgoing[id] end
|
|
226
|
+
local f, node, out = G.node_file[id], G.nodes[id], {}
|
|
227
|
+
outgoing[id] = out
|
|
228
|
+
if not relevant(G.files[f]) then return out end
|
|
229
|
+
methods = methods or require('codeoutline.analysis.go.go_methods').context(G, ctx)
|
|
230
|
+
local d = data(f); if not d then return out end
|
|
231
|
+
for _, site in ipairs(d.sites) do
|
|
232
|
+
if G.id_of[f][site.from] == id then
|
|
233
|
+
for _, dst in ipairs(target(f, site)) do emit(out, id, dst, site.line, site.route and ('route ' .. site.route) or 'middleware', G.files[f].path .. ':' .. site.line) end
|
|
234
|
+
end
|
|
235
|
+
end
|
|
236
|
+
for _, site in ipairs(d.assertions) do
|
|
237
|
+
if G.id_of[f][site.from] == id then
|
|
238
|
+
for _, ty in ipairs(methods.types(f, site.type)) do
|
|
239
|
+
for _, m in ipairs(methods.members({ id = ty, pointer = false }, f, site.name)) do
|
|
240
|
+
emit(out, id, m.id, site.line, 'grpc server assertion')
|
|
241
|
+
end
|
|
242
|
+
end
|
|
243
|
+
end
|
|
244
|
+
end
|
|
245
|
+
if d.dispatchers[id - G.id_of[f][1] + 1] then
|
|
246
|
+
for g, rec in ipairs(G.files) do
|
|
247
|
+
if g > M.MAX_SCANNED_FILES or expired() then C.incomplete = true; break end
|
|
248
|
+
if relevant(rec) then
|
|
249
|
+
local other = data(g)
|
|
250
|
+
for _, site in ipairs(other and other.sites or {}) do
|
|
251
|
+
if site.framework == 'gin' then for _, dst in ipairs(target(g, site)) do
|
|
252
|
+
emit(out, id, dst, node.line, 'gin middleware dispatch', rec.path .. ':' .. site.line)
|
|
253
|
+
end end
|
|
254
|
+
end
|
|
255
|
+
end
|
|
256
|
+
end
|
|
257
|
+
end
|
|
258
|
+
-- A generated server interface/stub reaches only structs that actually
|
|
259
|
+
-- embed that service's generated Unimplemented server, not namesakes.
|
|
260
|
+
local owner = node.recv or (node.parent and G.files[f].nodes[node.parent].name)
|
|
261
|
+
if owner and G.files[f].path:match('_grpc%.pb%.go$') then
|
|
262
|
+
local service = owner:match('^Unimplemented(.+Server)$') or owner:match('^(.+Server)$')
|
|
263
|
+
if service then
|
|
264
|
+
local stub = 'Unimplemented' .. service
|
|
265
|
+
local expected = signature(f, id - G.id_of[f][1] + 1)
|
|
266
|
+
for candidate, field in ipairs(G.by_name[stub] or {}) do
|
|
267
|
+
if candidate > M.MAX_CANDIDATES or expired() then C.incomplete = true; break end
|
|
268
|
+
local n, g = G.nodes[field], G.node_file[field]
|
|
269
|
+
if n.embedded and n.parent and G.files[g].language == 'go' then
|
|
270
|
+
local md = methods.data(g)
|
|
271
|
+
local type_index = n.parent
|
|
272
|
+
local details = md and md.nodes[type_index]
|
|
273
|
+
local matches = false
|
|
274
|
+
for _, embed in ipairs(details and details.embeds or {}) do
|
|
275
|
+
local ty = embed.kind == 'pointer' and embed.child or embed
|
|
276
|
+
for _, base in ipairs(ty.kind == 'name' and methods.types(g, ty.name) or {}) do
|
|
277
|
+
if G.node_file[base] == f and G.nodes[base].name == stub then matches = true end
|
|
278
|
+
end
|
|
279
|
+
end
|
|
280
|
+
if matches and expected then
|
|
281
|
+
local type_id = G.id_of[g][type_index]
|
|
282
|
+
for _, m in ipairs(methods.members({ id = type_id, pointer = true }, g, node.name)) do
|
|
283
|
+
local mf = G.node_file[m.id]
|
|
284
|
+
if not G.files[mf].path:match('%.pb%.go$') and expected == signature(mf, m.id - G.id_of[mf][1] + 1) then
|
|
285
|
+
emit(out, id, m.id, node.line, 'grpc server implementation', G.files[g].path .. ':' .. n.line)
|
|
286
|
+
end
|
|
287
|
+
end
|
|
288
|
+
end
|
|
289
|
+
end
|
|
290
|
+
end
|
|
291
|
+
end
|
|
292
|
+
end
|
|
293
|
+
return out
|
|
294
|
+
end
|
|
295
|
+
function C.incoming(wanted)
|
|
296
|
+
local result = {}
|
|
297
|
+
local go = false
|
|
298
|
+
for id in pairs(wanted) do if G.files[G.node_file[id]].language == 'go' then go = true; break end end
|
|
299
|
+
if not go then return result end
|
|
300
|
+
for f, rec in ipairs(G.files) do
|
|
301
|
+
if f > M.MAX_SCANNED_FILES or expired() then C.incomplete = true; break end
|
|
302
|
+
if relevant(rec) then
|
|
303
|
+
local d, candidates = data(f), {}
|
|
304
|
+
for _, site in ipairs(d and d.sites or {}) do candidates[G.id_of[f][site.from]] = true end
|
|
305
|
+
for _, site in ipairs(d and d.assertions or {}) do candidates[G.id_of[f][site.from]] = true end
|
|
306
|
+
for index in pairs(d and d.dispatchers or {}) do candidates[G.id_of[f][index]] = true end
|
|
307
|
+
if rec.path:match('_grpc%.pb%.go$') then
|
|
308
|
+
for index, n in ipairs(rec.nodes) do
|
|
309
|
+
if index > M.MAX_CANDIDATES then C.incomplete = true; break end
|
|
310
|
+
if n.kind == 'method' then candidates[G.id_of[f][index]] = true end
|
|
311
|
+
end
|
|
312
|
+
end
|
|
313
|
+
local ordered = {}; for id in pairs(candidates) do ordered[#ordered + 1] = id end
|
|
314
|
+
table.sort(ordered)
|
|
315
|
+
for _, id in ipairs(ordered) do
|
|
316
|
+
for _, edge in ipairs(C.outgoing(id)) do
|
|
317
|
+
if wanted[edge.target] then result[id] = result[id] or {}; result[id][#result[id] + 1] = edge end
|
|
318
|
+
end
|
|
319
|
+
end
|
|
320
|
+
end
|
|
321
|
+
end
|
|
322
|
+
return result
|
|
323
|
+
end
|
|
324
|
+
return C
|
|
325
|
+
end
|
|
326
|
+
|
|
327
|
+
return M
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
-- Query-owned Go signatures, method sets and declared receiver bindings.
|
|
2
|
-
local control = require('codeoutline.control')
|
|
2
|
+
local control = require('codeoutline.shared.control')
|
|
3
3
|
local M = { MAX_FILES = 16, MAX_BYTES = 8388608, MAX_TYPES = 512, MAX_NODES = 8192,
|
|
4
4
|
MAX_DEPTH = 16, MAX_RESULTS = 64, MAX_CANDIDATES = 512, MAX_TIME_MS = 500 }
|
|
5
5
|
local kinds = { struct = true, interface = true, typedef = true }
|
|
@@ -428,7 +428,7 @@ function M.context(G, ctx, report)
|
|
|
428
428
|
local deadline = xtimer.now_ms() + M.MAX_TIME_MS
|
|
429
429
|
ctx.go_methods = C
|
|
430
430
|
local data, packages, owners, sets, signatures, outgoing, incoming = {}, {}, {}, {}, {}, {}, {}
|
|
431
|
-
local modules = require('codeoutline.go_modules')
|
|
431
|
+
local modules = require('codeoutline.analysis.go.go_modules')
|
|
432
432
|
local function limited() C.incomplete, ctx.go_methods_incomplete = true, true end
|
|
433
433
|
local function expired()
|
|
434
434
|
control.check()
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
-- Query-owned local Go module lookup. No go command, module cache or network.
|
|
2
2
|
local M = { MAX_CONFIGS = 1024, MAX_CONFIG_BYTES = 1048576, MAX_TOTAL_BYTES = 8388608,
|
|
3
3
|
MAX_MODULES = 256, MAX_FILES = 512, MAX_NODES = 8192, MAX_RESULTS = 64, MAX_DIRECTORIES = 4096 }
|
|
4
|
-
local control = require('codeoutline.control')
|
|
5
|
-
local paths = require('codeoutline.path')
|
|
4
|
+
local control = require('codeoutline.shared.control')
|
|
5
|
+
local paths = require('codeoutline.shared.path')
|
|
6
6
|
local function dir(p) return p:match('^(.*)/[^/]+$') or '' end
|
|
7
7
|
local function join(a, b) return a == '' and b or b == '' and a or a .. '/' .. b end
|
|
8
8
|
local function valid(p)
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
-- included header > same directory), never across languages. Ties keep up
|
|
27
27
|
-- to MAX_TIES targets instead of guessing.
|
|
28
28
|
|
|
29
|
-
local control = require('codeoutline.control')
|
|
30
|
-
local js_resolution = require('codeoutline.js_resolution')
|
|
31
|
-
local lua_bindings = require('codeoutline.lua_bindings')
|
|
29
|
+
local control = require('codeoutline.shared.control')
|
|
30
|
+
local js_resolution = require('codeoutline.analysis.js.js_resolution')
|
|
31
|
+
local lua_bindings = require('codeoutline.analysis.lua.lua_bindings')
|
|
32
32
|
local M = {}
|
|
33
33
|
|
|
34
34
|
M.EDGE = 3
|
|
@@ -80,7 +80,7 @@ local function resolve_deps(G, f, js_context, imports_only)
|
|
|
80
80
|
for _, imp in ipairs(rec.imports) do
|
|
81
81
|
local path = imp.path
|
|
82
82
|
if C_FAMILY[rec.language] then
|
|
83
|
-
for _, g in ipairs(require('codeoutline.cpp_includes').resolve(G, f, imp, js_context)) do add(g) end
|
|
83
|
+
for _, g in ipairs(require('codeoutline.analysis.cpp.cpp_includes').resolve(G, f, imp, js_context)) do add(g) end
|
|
84
84
|
elseif rec.language == 'python' then
|
|
85
85
|
local rel = path
|
|
86
86
|
local base = here
|
|
@@ -119,14 +119,14 @@ local function resolve_deps(G, f, js_context, imports_only)
|
|
|
119
119
|
-- dofile/loadfile take a path.
|
|
120
120
|
for _, g in ipairs(lua_bindings.modules(G, imp, js_context and js_context.lua)) do add(g) end
|
|
121
121
|
elseif rec.language == 'go' then
|
|
122
|
-
for _, g in ipairs(require('codeoutline.go_modules').files(G, f, path, js_context)) do add(g) end
|
|
122
|
+
for _, g in ipairs(require('codeoutline.analysis.go.go_modules').files(G, f, path, js_context)) do add(g) end
|
|
123
123
|
elseif rec.language == 'javascript' or rec.language == 'typescript' or rec.language == 'arkts' then
|
|
124
124
|
add(js_resolution.module(G, f, path, js_context, imp.kind))
|
|
125
125
|
elseif rec.language == 'csharp' then
|
|
126
126
|
for _, g in ipairs(G.ns_files[path] or {}) do add(g) end
|
|
127
127
|
elseif rec.language == 'rust' then
|
|
128
128
|
if js_context then
|
|
129
|
-
local files = require('codeoutline.rust_resolution').imports(G, f, imp, js_context)
|
|
129
|
+
local files = require('codeoutline.analysis.rust.rust_resolution').imports(G, f, imp, js_context)
|
|
130
130
|
if files then for _, g in ipairs(files) do add(g) end; goto next_import end
|
|
131
131
|
end
|
|
132
132
|
if imp.kind == 'mod' then
|
|
@@ -175,7 +175,7 @@ local function resolve_deps(G, f, js_context, imports_only)
|
|
|
175
175
|
for _, g in ipairs(G.pkg_files[rec.package] or {}) do add(g) end
|
|
176
176
|
elseif rec.language == 'go' then
|
|
177
177
|
if not imports_only then
|
|
178
|
-
for _, g in ipairs(require('codeoutline.go_modules').peers(G, f, js_context)) do add(g) end
|
|
178
|
+
for _, g in ipairs(require('codeoutline.analysis.go.go_modules').peers(G, f, js_context)) do add(g) end
|
|
179
179
|
end
|
|
180
180
|
elseif rec.language == 'csharp' then
|
|
181
181
|
for _, node in ipairs(rec.nodes) do
|
|
@@ -188,7 +188,7 @@ local function resolve_deps(G, f, js_context, imports_only)
|
|
|
188
188
|
-- x.h also "depends on" x.c for resolution purposes.
|
|
189
189
|
local paired = {}
|
|
190
190
|
if C_FAMILY[rec.language] and not imports_only then
|
|
191
|
-
local strict = require('codeoutline.cpp_includes').policy(G, f, js_context).configured
|
|
191
|
+
local strict = require('codeoutline.analysis.cpp.cpp_includes').policy(G, f, js_context).configured
|
|
192
192
|
local function can_pair(source, header)
|
|
193
193
|
if not strict then return true end
|
|
194
194
|
return M.directly_includes(G, source, header, js_context)
|
|
@@ -302,13 +302,7 @@ local function score(G, f, src_id, ref_kind, recv, cid, deps, paired, owner)
|
|
|
302
302
|
if not s then return nil end
|
|
303
303
|
local kind = c.kind
|
|
304
304
|
if kind == 'prototype' then s = s - 3 end
|
|
305
|
-
if ref_kind == 'member_call' and
|
|
306
|
-
if owner and c.parent and G.id_of[cf][c.parent] == owner then
|
|
307
|
-
s = s + 80
|
|
308
|
-
elseif kind ~= 'method' then
|
|
309
|
-
s = s - 20
|
|
310
|
-
end
|
|
311
|
-
elseif ref_kind == 'member_call' and s <= 0 then
|
|
305
|
+
if ref_kind == 'member_call' and s <= 0 then
|
|
312
306
|
-- obj.name() on an unknown receiver: binding it to any same-named
|
|
313
307
|
-- method project-wide (str.format -> some format()) is mostly wrong,
|
|
314
308
|
-- so only local candidates qualify.
|
|
@@ -327,11 +321,11 @@ local function is_decl(node) return node.kind == 'prototype' or node.decl end
|
|
|
327
321
|
local scored_ids, scored_vals = {}, {}
|
|
328
322
|
|
|
329
323
|
-- accept overrides the node kinds the ref kind may bind to (navigation only).
|
|
330
|
-
local function resolve_ref(G, f, src_id, name, kind, recv, deps, paired, accept, evidence, js_context, line)
|
|
324
|
+
local function resolve_ref(G, f, src_id, name, kind, recv, deps, paired, accept, evidence, js_context, line, offset)
|
|
331
325
|
if kind == 'annotation' or kind == 'type' then return nil end
|
|
332
326
|
local macro_state
|
|
333
327
|
if kind == 'call' and C_FAMILY[G.files[f].language] and (not src_id or G.nodes[src_id].kind ~= 'macro') then
|
|
334
|
-
local macro, _, state = require('codeoutline.cpp_macros').resolve(G, f, name, line, js_context)
|
|
328
|
+
local macro, _, state = require('codeoutline.analysis.cpp.cpp_macros').resolve(G, f, name, line, js_context)
|
|
335
329
|
macro_state = state
|
|
336
330
|
if macro then return macro, #macro > 0 and 'visible macro' or 'unknown or unsupported macro visibility', macro_state end
|
|
337
331
|
if macro == false then accept = accept or NO_MACRO end
|
|
@@ -345,41 +339,40 @@ local function resolve_ref(G, f, src_id, name, kind, recv, deps, paired, accept,
|
|
|
345
339
|
or G.files[f].language == 'python' or G.files[f].language == 'java' or G.files[f].language == 'kotlin')
|
|
346
340
|
if function_value and recv then kind = 'member_call' end
|
|
347
341
|
if evidence == '' then evidence = nil end
|
|
342
|
+
local receiver_ids, receiver_reason = require('codeoutline.analysis.receivers').resolve(G, f, src_id, name, kind, recv,
|
|
343
|
+
evidence, js_context, accept, offset)
|
|
344
|
+
if receiver_ids ~= nil then
|
|
345
|
+
local filtered = {}
|
|
346
|
+
for _, id in ipairs(receiver_ids) do if accept[G.nodes[id].kind] then filtered[#filtered + 1] = id end end
|
|
347
|
+
return filtered, receiver_reason, macro_state
|
|
348
|
+
end
|
|
348
349
|
local strategy = 'js/ts binding'
|
|
349
350
|
local exact, binding_reason = js_resolution.resolve(G, f, name, kind, recv, evidence, js_context)
|
|
350
|
-
if G.files[f].language == 'go' then
|
|
351
|
-
strategy = 'go method set'
|
|
352
|
-
exact, binding_reason = require('codeoutline.go_methods').resolve(G, f, name, recv, evidence, js_context)
|
|
353
|
-
if exact == nil then
|
|
354
|
-
strategy = 'go package binding'
|
|
355
|
-
exact, binding_reason = require('codeoutline.go_modules').resolve(G, f, name, recv, js_context)
|
|
356
|
-
end
|
|
357
|
-
end
|
|
358
351
|
if G.files[f].language == 'rust' and js_context then
|
|
359
352
|
strategy = 'cargo crate/module binding'
|
|
360
|
-
exact, binding_reason = require('codeoutline.rust_resolution').resolve(G, f, src_id, name, recv, evidence, js_context)
|
|
353
|
+
exact, binding_reason = require('codeoutline.analysis.rust.rust_resolution').resolve(G, f, src_id, name, recv, evidence, js_context)
|
|
361
354
|
end
|
|
362
355
|
if exact == nil and G.files[f].language == 'python' then
|
|
363
356
|
strategy = 'python binding'
|
|
364
|
-
exact = require('codeoutline.python_bindings').resolve(G, f, evidence, js_context)
|
|
357
|
+
exact = require('codeoutline.analysis.python.python_bindings').resolve(G, f, evidence, js_context)
|
|
365
358
|
end
|
|
366
359
|
if exact == nil and C_FAMILY[G.files[f].language] and evidence and evidence:match('^cxx:expr:') then
|
|
367
360
|
strategy = 'c/c++ call-result receiver'
|
|
368
|
-
exact, binding_reason = require('codeoutline.cpp_receivers').context(G, js_context).resolve(f, src_id, name, evidence)
|
|
361
|
+
exact, binding_reason = require('codeoutline.analysis.cpp.cpp_receivers').context(G, js_context).resolve(f, src_id, name, evidence)
|
|
369
362
|
end
|
|
370
363
|
if exact == nil and G.files[f].language == 'cpp' then
|
|
371
364
|
strategy = evidence and evidence:match('^cpp:name:') and 'c++ namespace/import' or 'c++ declared receiver'
|
|
372
|
-
exact, binding_reason = require('codeoutline.cpp_bindings').resolve(G, f, src_id, name, evidence, deps, js_context, accept)
|
|
365
|
+
exact, binding_reason = require('codeoutline.analysis.cpp.cpp_bindings').resolve(G, f, src_id, name, evidence, deps, js_context, accept)
|
|
373
366
|
end
|
|
374
367
|
if exact == nil and G.files[f].language == 'csharp' then
|
|
375
368
|
strategy = 'c# binding'
|
|
376
|
-
exact = require('codeoutline.csharp_bindings').resolve(G, f, src_id, name, kind, recv, evidence, js_context)
|
|
369
|
+
exact = require('codeoutline.analysis.csharp.csharp_bindings').resolve(G, f, src_id, name, kind, recv, evidence, js_context)
|
|
377
370
|
end
|
|
378
371
|
if exact == nil and (G.files[f].language == 'java' or G.files[f].language == 'kotlin') then
|
|
379
372
|
strategy = 'declared JVM receiver'
|
|
380
|
-
exact = require('codeoutline.implementations').resolve(G, f, src_id, name, evidence, js_context)
|
|
373
|
+
exact = require('codeoutline.analysis.implementations').resolve(G, f, src_id, name, evidence, js_context)
|
|
381
374
|
if function_value and recv and exact == nil then
|
|
382
|
-
exact = require('codeoutline.implementations').resolve(G, f, src_id, name,
|
|
375
|
+
exact = require('codeoutline.analysis.implementations').resolve(G, f, src_id, name,
|
|
383
376
|
'jvm:type:' .. recv .. '\0' .. '0', js_context)
|
|
384
377
|
end
|
|
385
378
|
end
|
|
@@ -392,7 +385,7 @@ local function resolve_ref(G, f, src_id, name, kind, recv, deps, paired, accept,
|
|
|
392
385
|
for _, id in ipairs(exact) do if accept[G.nodes[id].kind] then result[#result + 1] = id end end
|
|
393
386
|
return result, #result == 0 and (binding_reason or 'binding target unresolved') or strategy, macro_state
|
|
394
387
|
end
|
|
395
|
-
if function_value and recv
|
|
388
|
+
if function_value and recv then
|
|
396
389
|
return {}, 'unresolved function-value receiver'
|
|
397
390
|
end
|
|
398
391
|
local cands = G.by_name[name]
|
|
@@ -415,12 +408,11 @@ local function resolve_ref(G, f, src_id, name, kind, recv, deps, paired, accept,
|
|
|
415
408
|
-- candidates this call could actually reach. (Asking it over all
|
|
416
409
|
-- same-named nodes let a Python `def work` hide the C prototype of
|
|
417
410
|
-- `work`, after which the Python def was filtered out too.)
|
|
418
|
-
local
|
|
419
|
-
local owner = (self_call or (kind == 'call' and src_id and (G.files[f].language == 'java' or G.files[f].language == 'kotlin')))
|
|
411
|
+
local owner = (kind == 'call' and src_id and (G.files[f].language == 'java' or G.files[f].language == 'kotlin'))
|
|
420
412
|
and owner_class(G, src_id) or nil
|
|
421
413
|
-- score() rejects an unknown-receiver member call to an unrelated file;
|
|
422
414
|
-- checking placement first skips most candidates of common method names.
|
|
423
|
-
local local_only = kind == 'member_call'
|
|
415
|
+
local local_only = kind == 'member_call'
|
|
424
416
|
local n, has_def, has_name = 0, false, false
|
|
425
417
|
for i = 1, math.min(#cands, M.MAX_CANDIDATES) do
|
|
426
418
|
local cid = cands[i]
|
|
@@ -624,21 +616,21 @@ function M.query(symbols, opts)
|
|
|
624
616
|
stats = { expanded = 0, incoming_scans = 0, resolved_refs = 0 }, incomplete = false }, { __index = symbols })
|
|
625
617
|
local reasons = {}; Q.stats.incomplete_reasons = reasons
|
|
626
618
|
local function incomplete(reason) Q.incomplete = true; reasons[reason] = true end
|
|
627
|
-
local resolution, observe = require('codeoutline.resolution').new()
|
|
619
|
+
local resolution, observe = require('codeoutline.analysis.resolution').new()
|
|
628
620
|
Q.stats.resolution = resolution
|
|
629
621
|
local dependencies, references = {}, {}
|
|
630
622
|
local js_context = js_resolution.context(symbols)
|
|
631
623
|
js_context.include_paths = opts.include_paths
|
|
632
624
|
js_context.lua = lua_bindings.context(symbols)
|
|
633
|
-
js_context.ordinary = require('codeoutline.ordinary_bindings').context(symbols, js_context)
|
|
625
|
+
js_context.ordinary = require('codeoutline.analysis.ordinary_bindings').context(symbols, js_context)
|
|
634
626
|
js_context.lua.ordinary = js_context.ordinary
|
|
635
627
|
Q.stats.ordinary = js_context.ordinary.stats
|
|
636
|
-
local macros = require('codeoutline.cpp_macros').context(symbols, js_context)
|
|
628
|
+
local macros = require('codeoutline.analysis.cpp.cpp_macros').context(symbols, js_context)
|
|
637
629
|
Q.stats.macros = macros.stats
|
|
638
630
|
Q.stats.workspace = js_context.workspace_stats
|
|
639
631
|
Q.stats.go = js_context.go_stats
|
|
640
632
|
Q.stats.rust = js_context.rust_stats
|
|
641
|
-
local report = opts.explain and require('codeoutline.query_report').new() or nil
|
|
633
|
+
local report = opts.explain and require('codeoutline.query.query_report').new() or nil
|
|
642
634
|
Q.report = report
|
|
643
635
|
if report then
|
|
644
636
|
local add = report.add
|
|
@@ -651,21 +643,25 @@ function M.query(symbols, opts)
|
|
|
651
643
|
return add(self, entry)
|
|
652
644
|
end
|
|
653
645
|
end
|
|
654
|
-
local indirect = require('codeoutline.indirect').query(symbols, opts.dispatch_rules, report)
|
|
655
|
-
local static_dispatch = require('codeoutline.static_dispatch').query(symbols, report, js_context)
|
|
656
|
-
local implementations = require('codeoutline.implementations').context(symbols, js_context, report)
|
|
646
|
+
local indirect = require('codeoutline.analysis.indirect').query(symbols, opts.dispatch_rules, report)
|
|
647
|
+
local static_dispatch = require('codeoutline.analysis.static_dispatch').query(symbols, report, js_context)
|
|
648
|
+
local implementations = require('codeoutline.analysis.implementations').context(symbols, js_context, report)
|
|
657
649
|
Q.stats.implementations = implementations.stats
|
|
658
|
-
local events = require('codeoutline.automatic_events').context(symbols, js_context, report)
|
|
650
|
+
local events = require('codeoutline.analysis.automatic_events').context(symbols, js_context, report)
|
|
659
651
|
Q.stats.events = events.stats
|
|
660
|
-
local callback_loops = require('codeoutline.lua_callback_loops').context(symbols, js_context, report)
|
|
652
|
+
local callback_loops = require('codeoutline.analysis.lua.lua_callback_loops').context(symbols, js_context, report)
|
|
661
653
|
Q.stats.callback_loops = callback_loops.stats
|
|
654
|
+
local go_frameworks = require('codeoutline.analysis.go.go_frameworks').context(symbols, js_context, report)
|
|
655
|
+
Q.stats.go_frameworks = go_frameworks.stats
|
|
662
656
|
local function context_limits()
|
|
663
657
|
if js_context.include_incomplete then incomplete('include_closure_limit') end
|
|
664
658
|
if js_context.workspace_incomplete then incomplete('js_workspace_analysis_incomplete') end
|
|
665
659
|
if js_context.go_incomplete then incomplete('go_module_analysis_incomplete') end
|
|
666
660
|
if js_context.go_methods_incomplete then incomplete('go_method_set_analysis_incomplete') end
|
|
661
|
+
if go_frameworks.incomplete then incomplete('go_framework_analysis_incomplete') end
|
|
667
662
|
if js_context.cpp_receivers_incomplete then incomplete('cpp_receiver_analysis_incomplete') end
|
|
668
663
|
if js_context.rust_incomplete then incomplete('rust_resolution_incomplete') end
|
|
664
|
+
if js_context.receiver_incomplete then incomplete('receiver_resolution_incomplete') end
|
|
669
665
|
end
|
|
670
666
|
local function deps(f)
|
|
671
667
|
local entry = dependencies[f]
|
|
@@ -722,7 +718,7 @@ function M.query(symbols, opts)
|
|
|
722
718
|
-- Opt-in inspection of already reported failures. Suggestions never load
|
|
723
719
|
-- outgoing/incoming edges or change the execution resolver's results.
|
|
724
720
|
function Q:definition_candidates()
|
|
725
|
-
return require('codeoutline.definition_candidates').suggest(self, report, js_context)
|
|
721
|
+
return require('codeoutline.query.definition_candidates').suggest(self, report, js_context)
|
|
726
722
|
end
|
|
727
723
|
setmetatable(Q.out, { __index = function(cache, id)
|
|
728
724
|
control.check()
|
|
@@ -768,6 +764,12 @@ function M.query(symbols, opts)
|
|
|
768
764
|
edges[#edges + 1] = edge.kind
|
|
769
765
|
end
|
|
770
766
|
if callback_loops.incomplete then incomplete('lua_callback_analysis_incomplete') end
|
|
767
|
+
for _, edge in ipairs(go_frameworks.outgoing(id)) do
|
|
768
|
+
edges[#edges + 1] = edge.target
|
|
769
|
+
edges[#edges + 1] = edge.line
|
|
770
|
+
edges[#edges + 1] = edge.kind
|
|
771
|
+
end
|
|
772
|
+
if go_frameworks.incomplete then incomplete('go_framework_analysis_incomplete') end
|
|
771
773
|
for _, i in ipairs(grouped[id] or {}) do
|
|
772
774
|
control.check()
|
|
773
775
|
for _, dst in ipairs(targets(f, i, true) or {}) do
|
|
@@ -814,6 +816,10 @@ function M.query(symbols, opts)
|
|
|
814
816
|
if progress then progress(incoming) end
|
|
815
817
|
if implementations.incomplete then incomplete('implementation_analysis_incomplete') end
|
|
816
818
|
local indirect_incoming = indirect.incoming(wanted)
|
|
819
|
+
for src, edges in pairs(go_frameworks.incoming(wanted)) do
|
|
820
|
+
for _, edge in ipairs(edges) do push3(incoming, edge.target, src, edge.line, edge.kind) end
|
|
821
|
+
end
|
|
822
|
+
if go_frameworks.incomplete then incomplete('go_framework_analysis_incomplete') end
|
|
817
823
|
for src, edges in pairs(callback_loops.incoming(wanted)) do
|
|
818
824
|
for _, edge in ipairs(edges) do push3(incoming, edge.target, src, edge.line, edge.kind) end
|
|
819
825
|
end
|
|
@@ -876,7 +882,7 @@ function M.query(symbols, opts)
|
|
|
876
882
|
file_names = file_names or {}
|
|
877
883
|
local alias_refs = js_context.ordinary.aliases(f, wanted, candidates)
|
|
878
884
|
if files[f].language == 'rust' then
|
|
879
|
-
for i in pairs(require('codeoutline.rust_resolution').alias_refs(symbols, f, wanted, js_context)) do alias_refs[i] = true end
|
|
885
|
+
for i in pairs(require('codeoutline.analysis.rust.rust_resolution').alias_refs(symbols, f, wanted, js_context)) do alias_refs[i] = true end
|
|
880
886
|
end
|
|
881
887
|
local aliases = {}
|
|
882
888
|
if files[f].language == 'kotlin' then
|