@codua/codeoutline-win32-x64 0.3.2 → 0.3.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.
Files changed (103) hide show
  1. package/DISTRIBUTION.md +26 -1
  2. package/README.md +39 -4
  3. package/README.zh-CN.md +30 -3
  4. package/bin/xnet.exe +0 -0
  5. package/build-info.json +1 -1
  6. package/codeoutline +1 -1
  7. package/codeoutline.cmd +1 -0
  8. package/editors/codeoutline.vsix +0 -0
  9. package/editors/zed/extension.wasm +0 -0
  10. package/package.json +1 -1
  11. package/scripts/codeoutline/{automatic_events.lua → analysis/automatic_events.lua} +4 -4
  12. package/scripts/codeoutline/{cpp_bindings.lua → analysis/cpp/cpp_bindings.lua} +7 -7
  13. package/scripts/codeoutline/{cpp_implementations.lua → analysis/cpp/cpp_implementations.lua} +3 -3
  14. package/scripts/codeoutline/{cpp_includes.lua → analysis/cpp/cpp_includes.lua} +3 -3
  15. package/scripts/codeoutline/{cpp_macros.lua → analysis/cpp/cpp_macros.lua} +3 -3
  16. package/scripts/codeoutline/{cpp_receivers.lua → analysis/cpp/cpp_receivers.lua} +7 -7
  17. package/scripts/codeoutline/{cpp_types.lua → analysis/cpp/cpp_types.lua} +5 -5
  18. package/scripts/codeoutline/{csharp_bindings.lua → analysis/csharp/csharp_bindings.lua} +1 -1
  19. package/scripts/codeoutline/{dispatch_aliases.lua → analysis/dispatch_aliases.lua} +3 -3
  20. package/scripts/codeoutline/{foreign.lua → analysis/foreign.lua} +2 -2
  21. package/scripts/codeoutline/{function_values.lua → analysis/function_values.lua} +2 -2
  22. package/scripts/codeoutline/analysis/go/go_frameworks.lua +327 -0
  23. package/scripts/codeoutline/{go_methods.lua → analysis/go/go_methods.lua} +2 -2
  24. package/scripts/codeoutline/{go_modules.lua → analysis/go/go_modules.lua} +2 -2
  25. package/scripts/codeoutline/{graph.lua → analysis/graph.lua} +53 -47
  26. package/scripts/codeoutline/{implementations.lua → analysis/implementations.lua} +16 -9
  27. package/scripts/codeoutline/{indirect.lua → analysis/indirect.lua} +71 -13
  28. package/scripts/codeoutline/{js_evidence.lua → analysis/js/js_evidence.lua} +4 -3
  29. package/scripts/codeoutline/{js_resolution.lua → analysis/js/js_resolution.lua} +2 -2
  30. package/scripts/codeoutline/{js_workspace.lua → analysis/js/js_workspace.lua} +2 -2
  31. package/scripts/codeoutline/{ts_implementations.lua → analysis/js/ts_implementations.lua} +3 -3
  32. package/scripts/codeoutline/{foreign_lua.lua → analysis/lua/foreign_lua.lua} +3 -3
  33. package/scripts/codeoutline/{lua_bindings.lua → analysis/lua/lua_bindings.lua} +97 -11
  34. package/scripts/codeoutline/{lua_callback_loops.lua → analysis/lua/lua_callback_loops.lua} +1 -1
  35. package/scripts/codeoutline/{ordinary_bindings.lua → analysis/ordinary_bindings.lua} +45 -21
  36. package/scripts/codeoutline/{python_bindings.lua → analysis/python/python_bindings.lua} +2 -2
  37. package/scripts/codeoutline/analysis/receivers.lua +547 -0
  38. package/scripts/codeoutline/{rust_packages.lua → analysis/rust/rust_packages.lua} +2 -2
  39. package/scripts/codeoutline/analysis/rust/rust_resolution.lua +609 -0
  40. package/scripts/codeoutline/{shared_events.lua → analysis/shared_events.lua} +3 -3
  41. package/scripts/codeoutline/{static_dispatch.lua → analysis/static_dispatch.lua} +5 -5
  42. package/scripts/codeoutline/{type_uses.lua → analysis/type_uses.lua} +1 -1
  43. package/scripts/codeoutline/cli.lua +1 -1
  44. package/scripts/codeoutline/command.lua +236 -19
  45. package/scripts/codeoutline/{cpp_fragments.lua → indexing/cpp_fragments.lua} +4 -4
  46. package/scripts/codeoutline/{index.lua → indexing/index.lua} +12 -12
  47. package/scripts/codeoutline/{parse_pool.lua → indexing/parse_pool.lua} +1 -1
  48. package/scripts/codeoutline/{agent_config.lua → install/agent_config.lua} +21 -1
  49. package/scripts/codeoutline/{agent_install.lua → install/agent_install.lua} +105 -10
  50. package/scripts/codeoutline/{editor_install.lua → install/editor_install.lua} +36 -6
  51. package/scripts/codeoutline/lang/c.lua +2 -2
  52. package/scripts/codeoutline/lang/cpp.lua +2 -2
  53. package/scripts/codeoutline/lang/csharp.lua +2 -2
  54. package/scripts/codeoutline/lang/go.lua +2 -2
  55. package/scripts/codeoutline/lang/java.lua +2 -2
  56. package/scripts/codeoutline/lang/js.lua +2 -2
  57. package/scripts/codeoutline/lang/kotlin.lua +4 -2
  58. package/scripts/codeoutline/lang/lua.lua +3 -3
  59. package/scripts/codeoutline/lang/python.lua +2 -2
  60. package/scripts/codeoutline/lang/rust.lua +3 -3
  61. package/scripts/codeoutline/main.lua +9 -9
  62. package/scripts/codeoutline/{common.lua → parsing/common.lua} +22 -17
  63. package/scripts/codeoutline/{language_detect.lua → parsing/language_detect.lua} +1 -1
  64. package/scripts/codeoutline/{parse.lua → parsing/parse.lua} +4 -4
  65. package/scripts/codeoutline/{http.lua → protocol/http.lua} +1 -1
  66. package/scripts/codeoutline/{lsp.lua → protocol/lsp.lua} +4 -4
  67. package/scripts/codeoutline/{mcp.lua → protocol/mcp.lua} +9 -9
  68. package/scripts/codeoutline/{affected.lua → query/affected.lua} +6 -6
  69. package/scripts/codeoutline/{callers.lua → query/callers.lua} +9 -9
  70. package/scripts/codeoutline/{completion.lua → query/completion.lua} +37 -49
  71. package/scripts/codeoutline/{definition_candidates.lua → query/definition_candidates.lua} +6 -6
  72. package/scripts/codeoutline/{documents.lua → query/documents.lua} +4 -4
  73. package/scripts/codeoutline/{explore.lua → query/explore.lua} +85 -25
  74. package/scripts/codeoutline/{external_headers.lua → query/external_headers.lua} +6 -6
  75. package/scripts/codeoutline/{navigation.lua → query/navigation.lua} +53 -54
  76. package/scripts/codeoutline/{on_demand.lua → query/on_demand.lua} +6 -6
  77. package/scripts/codeoutline/{query_report.lua → query/query_report.lua} +9 -5
  78. package/scripts/codeoutline/{search_ranking.lua → query/search_ranking.lua} +10 -7
  79. package/scripts/codeoutline/{type_hierarchy.lua → query/type_hierarchy.lua} +11 -11
  80. package/scripts/codeoutline/{type_references.lua → query/type_references.lua} +17 -17
  81. package/scripts/codeoutline/{index_worker.lua → runtime/index_worker.lua} +10 -10
  82. package/scripts/codeoutline/{parse_worker.lua → runtime/parse_worker.lua} +2 -2
  83. package/scripts/codeoutline/{update_worker.lua → runtime/update_worker.lua} +1 -1
  84. package/scripts/codeoutline/service.lua +11 -11
  85. package/scripts/codeoutline/update_sequence.lua +1 -1
  86. package/scripts/codeoutline/version.lua +1 -1
  87. package/scripts/codeoutline/rust_resolution.lua +0 -301
  88. /package/scripts/codeoutline/{lua_literal.lua → analysis/lua/lua_literal.lua} +0 -0
  89. /package/scripts/codeoutline/{resolution.lua → analysis/resolution.lua} +0 -0
  90. /package/scripts/codeoutline/{cargo_toml.lua → analysis/rust/cargo_toml.lua} +0 -0
  91. /package/scripts/codeoutline/{type_bases.lua → analysis/type_bases.lua} +0 -0
  92. /package/scripts/codeoutline/{cache_repairs.lua → indexing/cache_repairs.lua} +0 -0
  93. /package/scripts/codeoutline/{daemon.lua → install/daemon.lua} +0 -0
  94. /package/scripts/codeoutline/{install_prompt.lua → install/install_prompt.lua} +0 -0
  95. /package/scripts/codeoutline/{xscan.lua → parsing/xscan.lua} +0 -0
  96. /package/scripts/codeoutline/{lsp_trace.lua → protocol/lsp_trace.lua} +0 -0
  97. /package/scripts/codeoutline/{coverage.lua → query/coverage.lua} +0 -0
  98. /package/scripts/codeoutline/{query_filters.lua → query/query_filters.lua} +0 -0
  99. /package/scripts/codeoutline/{idle_gc.lua → runtime/idle_gc.lua} +0 -0
  100. /package/scripts/codeoutline/{control.lua → shared/control.lua} +0 -0
  101. /package/scripts/codeoutline/{path.lua → shared/path.lua} +0 -0
  102. /package/scripts/codeoutline/{rules.lua → shared/rules.lua} +0 -0
  103. /package/scripts/codeoutline/{text.lua → shared/text.lua} +0 -0
@@ -1,301 +0,0 @@
1
- -- Rust crate/module evidence is produced only for queries, never serialized.
2
- local M = { MAX_DEPTH = 16, MAX_RESULTS = 128, MAX_ALIAS_FILES = 64, MAX_NODES = 8192 }
3
- local cargo, control = require('codeoutline.rust_packages'), require('codeoutline.control')
4
- local function join(a, b) return a == '' and b or b == '' and a or a .. '::' .. b end
5
- local function text(T, i) return i >= 1 and i <= T.n and T:text(i) or '' end
6
-
7
- function M.collect(r, T)
8
- r.rust_imports, r.rust_public, r.has_bindings = {}, {}, true
9
- for n, node in ipairs(r.nodes) do
10
- r.rust_public[n] = text(T, node.ti) == 'pub' and text(T, node.ti + 1) ~= '('
11
- end
12
- for i = 1, T.n do
13
- if text(T, i) == 'use' then
14
- local parent, in_function, last, j = nil, false, i + 1, i + 1
15
- for n, node in ipairs(r.nodes) do
16
- if node.ti <= i and i <= node.tj then
17
- if node.kind == 'namespace' then parent = n
18
- elseif node.kind == 'function' or node.kind == 'method' then in_function = true end
19
- end
20
- end
21
- while j <= T.n and text(T, j) ~= ';' do
22
- if T.m[j] and T.m[j] > j then j = T.m[j] end
23
- j = j + 1
24
- end
25
- last = j - 1
26
- local cursor, count = i + 1, 0
27
- if text(T, cursor) == '::' then cursor = cursor + 1 end
28
- local branch
29
- branch = function(prefix, depth)
30
- if depth > M.MAX_DEPTH then error('Rust use nesting limit reached', 0) end
31
- local path = prefix
32
- while cursor <= last do
33
- local token = text(T, cursor)
34
- if token == '{' then
35
- cursor = cursor + 1
36
- while cursor <= last and text(T, cursor) ~= '}' do
37
- branch(path, depth + 1)
38
- if text(T, cursor) == ',' then cursor = cursor + 1 else break end
39
- end
40
- if text(T, cursor) ~= '}' then error('unsupported Rust use group', 0) end
41
- cursor = cursor + 1; return
42
- end
43
- if token == '' or token == ',' or token == '}' then break end
44
- if token ~= 'self' or path == '' then path = join(path, token) end
45
- cursor = cursor + 1
46
- if text(T, cursor) == '::' then cursor = cursor + 1 else break end
47
- end
48
- local alias = path:match('([^:]+)$')
49
- if text(T, cursor) == 'as' then alias = text(T, cursor + 1); cursor = cursor + 2 end
50
- count = count + 1
51
- if count > M.MAX_RESULTS then error('Rust use binding limit reached', 0) end
52
- if not in_function then r.rust_imports[#r.rust_imports + 1] = { path = path, alias = alias,
53
- parent = parent, public = text(T, i - 1) == 'pub', line = T:line(i) } end
54
- end
55
- branch('', 0)
56
- end
57
- end
58
- for _, ref in ipairs(r.refs) do
59
- local i, path = ref.tok, ref.name
60
- if text(T, i - 1) == '.' then ref.binding = 'rust:member'
61
- else
62
- while text(T, i - 1) == '::' and (T.k[i - 2] == 'id' or T.k[i - 2] == 'kw') do
63
- path, i = text(T, i - 2) .. '::' .. path, i - 2
64
- end
65
- ref.binding = 'rust:path:' .. path
66
- end
67
- end
68
- end
69
-
70
- local function data(G, f, ctx)
71
- local rec = G.files[f]
72
- if rec.rust_imports then return rec end
73
- return ctx.ordinary and cargo.guard(ctx, function() return ctx.ordinary.data(f) end) or rec
74
- end
75
- local function scope_of(G, f, src)
76
- local node = src and G.nodes[src]
77
- local p = node and node.parent
78
- while p do
79
- local owner = G.files[f].nodes[p]
80
- if owner.kind == 'namespace' then return owner.qualified end
81
- p = owner.parent
82
- end
83
- return ''
84
- end
85
- local function parent_scope(G, f, p) return p and G.files[f].nodes[p].qualified or '' end
86
- local function nodes(G, f, ctx)
87
- local list = G.files[f].nodes
88
- if #list > M.MAX_NODES then
89
- ctx.rust_incomplete, ctx.rust_error = true, 'Rust module node limit reached'
90
- return {}
91
- end
92
- return list
93
- end
94
- local function child(G, entry, name, ctx)
95
- local wanted, found = join(entry.scope, name), nil
96
- local rec, detail = G.files[entry.file], data(G, entry.file, ctx)
97
- for n, node in ipairs(nodes(G, entry.file, ctx)) do
98
- if node.kind == 'namespace' and node.qualified == wanted then
99
- if entry.external and not (detail.rust_public or {})[n] then return nil end
100
- local external = false
101
- for _, imp in ipairs(rec.imports) do if imp.kind == 'mod' and imp.path == name then external = true; break end end
102
- if not external then return { file = entry.file, scope = wanted, external = entry.external, root = entry.root } end
103
- local path = rec.path
104
- local directory, stem = cargo.dir(path), path:match('([^/]+)%.rs$')
105
- if not entry.root and stem ~= 'lib' and stem ~= 'main' and stem ~= 'mod' then directory = cargo.join(directory, stem) end
106
- if entry.scope ~= '' then directory = cargo.join(directory, entry.scope:gsub('::', '/')) end
107
- for _, candidate in ipairs({ cargo.join(directory, name .. '.rs'), cargo.join(directory, name .. '/mod.rs') }) do
108
- local id = G.file_index[candidate]
109
- if id then
110
- if found then return nil end
111
- if cargo.owner(G, id, ctx) ~= cargo.owner(G, entry.file, ctx) then return nil end
112
- found = { file = id, scope = '', external = entry.external }
113
- end
114
- end
115
- return found
116
- end
117
- end
118
- end
119
-
120
- local walk
121
- local function terminal(G, entry, name, ctx, seen, depth)
122
- local result, rec, detail = {}, G.files[entry.file], data(G, entry.file, ctx)
123
- local wanted = join(entry.scope, name)
124
- for n, node in ipairs(nodes(G, entry.file, ctx)) do
125
- if node.qualified == wanted and node.kind ~= 'namespace'
126
- and (not entry.external or (detail.rust_public or {})[n]) then
127
- result[#result + 1] = G.id_of[entry.file][n]
128
- end
129
- end
130
- if #result > 0 then return { ids = result } end
131
- for _, imp in ipairs(detail.rust_imports or {}) do
132
- if imp.alias == name and parent_scope(G, entry.file, imp.parent) == entry.scope
133
- and (not entry.external or imp.public) then
134
- local found = walk(G, entry.file, imp.path, ctx, entry.scope, seen, depth + 1)
135
- if entry.external and found and found.ids then
136
- local visible = {}
137
- for _, id in ipairs(found.ids) do
138
- local f = G.node_file[id]
139
- for n, local_id in ipairs(G.id_of[f]) do
140
- if local_id == id and (data(G, f, ctx).rust_public or {})[n] then visible[#visible + 1] = id end
141
- end
142
- end
143
- found.ids = visible
144
- end
145
- return found
146
- end
147
- end
148
- end
149
- walk = function(G, f, path, ctx, scope, seen, depth)
150
- control.check()
151
- if depth > M.MAX_DEPTH then error('Rust module resolution depth limit reached', 0) end
152
- local key = G.files[f].path .. '\0' .. scope .. '\0' .. path
153
- if seen[key] then return nil end
154
- seen[key] = true
155
- local parts = {}; for name in path:gmatch('[^:]+') do parts[#parts + 1] = name end
156
- if #parts == 0 then return nil end
157
- local owner = cargo.owner(G, f, ctx)
158
- if not owner then return nil end
159
- local first, index, entry = parts[1], 2, nil
160
- if first == 'crate' then
161
- local id = cargo.entry(G, owner, ctx, f)
162
- if id then entry = { file = id, scope = '', root = true } end
163
- elseif first == 'self' then entry = { file = f, scope = scope, root = cargo.entry(G, owner, ctx, f) == f }
164
- elseif first == 'super' then
165
- if scope ~= '' then entry = { file = f, scope = scope:match('^(.*)::[^:]+$') or '', root = cargo.entry(G, owner, ctx, f) == f }
166
- else
167
- local root = cargo.entry(G, owner, ctx, f)
168
- if root and root ~= f then
169
- local directory = cargo.dir(G.files[f].path)
170
- if G.files[f].path:match('/mod%.rs$') then directory = cargo.dir(directory) end
171
- local candidates = directory == cargo.dir(G.files[root].path) and { G.files[root].path }
172
- or { directory .. '.rs', cargo.join(directory, 'mod.rs') }
173
- for _, candidate in ipairs(candidates) do
174
- local id = G.file_index[candidate]
175
- if id and cargo.owner(G, id, ctx) == owner then
176
- if entry then return nil end
177
- entry = { file = id, scope = '', root = id == root }
178
- end
179
- end
180
- end
181
- end
182
- else
183
- for _, imp in ipairs(data(G, f, ctx).rust_imports or {}) do
184
- if imp.alias == first and parent_scope(G, f, imp.parent) == scope then
185
- local replacement = imp.path
186
- if #parts > 1 then replacement = replacement .. '::' .. table.concat(parts, '::', 2) end
187
- if replacement ~= path then return walk(G, f, replacement, ctx, scope, seen, depth + 1) end
188
- end
189
- end
190
- local id = cargo.crates(G, f, ctx)[first]
191
- if id then entry = { file = id, scope = '', external = cargo.owner(G, id, ctx) ~= owner, root = true }
192
- else entry, index = { file = f, scope = scope }, 1 end
193
- end
194
- if not entry then return nil end
195
- if first == 'super' and parts[2] == 'super' then
196
- return walk(G, entry.file, table.concat(parts, '::', 2), ctx, entry.scope, seen, depth + 1)
197
- end
198
- while index <= #parts do
199
- local next_entry = child(G, entry, parts[index], ctx)
200
- if next_entry then entry = next_entry
201
- else
202
- local found = terminal(G, entry, parts[index], ctx, seen, depth)
203
- if index == #parts then return found end
204
- if found and found.module then
205
- found.module.external = entry.external; entry = found.module
206
- elseif found and found.ids and index + 1 == #parts then
207
- local ids = {}
208
- for _, type_id in ipairs(found.ids) do
209
- local ty, tf = G.nodes[type_id], G.node_file[type_id]
210
- for _, id in ipairs(G.by_name[parts[index + 1]] or {}) do
211
- local method, mf = G.nodes[id], G.node_file[id]
212
- if mf == tf and method.kind == 'method' and method.qualified == ty.qualified .. '::' .. parts[index + 1] then
213
- for n, local_id in ipairs(G.id_of[mf]) do
214
- if local_id == id and (not entry.external or (data(G, mf, ctx).rust_public or {})[n]) then ids[#ids + 1] = id end
215
- end
216
- end
217
- end
218
- end
219
- return { ids = ids }
220
- else return nil end
221
- end
222
- index = index + 1
223
- end
224
- return { module = entry }
225
- end
226
-
227
- function M.path(G, f, path, ctx, scope)
228
- return cargo.guard(ctx, walk, G, f, path, ctx, scope or '', {}, 0)
229
- end
230
- function M.resolve(G, f, src, name, recv, evidence, ctx)
231
- if not cargo.owner(G, f, ctx) then return ctx.rust_incomplete and {} or nil, ctx.rust_error end
232
- if evidence == 'rust:member' then return nil end
233
- local path = evidence and evidence:match('^rust:path:(.*)$') or (recv and recv .. '::' .. name or name)
234
- local found, reason = M.path(G, f, path, ctx, scope_of(G, f, src))
235
- return found and found.ids or {}, reason or 'Cargo crate/module target is not indexed or visible'
236
- end
237
- function M.imports(G, f, imp, ctx)
238
- if not cargo.owner(G, f, ctx) then return ctx.rust_incomplete and {} or nil end
239
- local result, seen = {}, {}
240
- local function add(id) if id and not seen[id] then seen[id] = true; result[#result + 1] = id end end
241
- if imp.kind == 'mod' then
242
- local entry = child(G, { file = f, scope = '' }, imp.path, ctx)
243
- if entry then add(entry.file) end
244
- else
245
- for _, binding in ipairs(data(G, f, ctx).rust_imports or {}) do
246
- if binding.line == imp.line then
247
- local found = M.path(G, f, binding.path, ctx, parent_scope(G, f, binding.parent))
248
- if found then
249
- if found.module then add(found.module.file) end
250
- for _, id in ipairs(found.ids or {}) do add(G.node_file[id]) end
251
- end
252
- end
253
- end
254
- end
255
- return result
256
- end
257
- function M.members(G, entry, ctx)
258
- return cargo.guard(ctx, function()
259
- local result, names, detail = {}, {}, data(G, entry.file, ctx)
260
- for n, node in ipairs(nodes(G, entry.file, ctx)) do
261
- if node.kind ~= 'impl' and parent_scope(G, entry.file, node.parent) == entry.scope
262
- and (not entry.external or (detail.rust_public or {})[n]) then
263
- names[node.name] = true
264
- result[#result + 1] = { name = node.name, node = node, file = entry.file, kind = node.kind }
265
- end
266
- end
267
- for _, imp in ipairs(detail.rust_imports or {}) do
268
- if imp.public and imp.alias ~= '*' and not names[imp.alias]
269
- and parent_scope(G, entry.file, imp.parent) == entry.scope then
270
- local found = M.path(G, entry.file, imp.path, ctx, entry.scope)
271
- for _, id in ipairs(found and found.ids or {}) do
272
- result[#result + 1] = { name = imp.alias, node = G.nodes[id], file = G.node_file[id], kind = G.nodes[id].kind }
273
- end
274
- end
275
- end
276
- if #result > M.MAX_RESULTS then error('Rust module member limit reached', 0) end
277
- return result
278
- end) or {}
279
- end
280
-
281
- function M.alias_refs(G, f, wanted, ctx)
282
- local rec = G.files[f]
283
- if rec.language ~= 'rust' or #rec.imports == 0 or not cargo.owner(G, f, ctx) then return {} end
284
- local relevant = false
285
- for id in pairs(wanted) do
286
- local target = cargo.owner(G, G.node_file[id], ctx)
287
- if cargo.reaches(G, f, target, ctx) then relevant = true end
288
- end
289
- if not relevant then return {} end
290
- ctx.rust_alias_files = ctx.rust_alias_files or {}
291
- if not ctx.rust_alias_files[f] then
292
- ctx.rust_alias_count = (ctx.rust_alias_count or 0) + 1
293
- if ctx.rust_alias_count > M.MAX_ALIAS_FILES then ctx.rust_incomplete = true; return {} end
294
- ctx.rust_alias_files[f] = true
295
- end
296
- local refs, result = data(G, f, ctx).refs, {}
297
- for i, binding in ipairs(refs.binding or {}) do if binding:match('^rust:path:') then result[i] = true end end
298
- return result
299
- end
300
- M.scope = scope_of
301
- return M