@codua/codeoutline-win32-x64 0.3.3 → 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 (100) hide show
  1. package/README.md +13 -1
  2. package/README.zh-CN.md +11 -1
  3. package/bin/xnet.exe +0 -0
  4. package/build-info.json +1 -1
  5. package/editors/codeoutline.vsix +0 -0
  6. package/editors/zed/extension.wasm +0 -0
  7. package/package.json +1 -1
  8. package/scripts/codeoutline/{automatic_events.lua → analysis/automatic_events.lua} +4 -4
  9. package/scripts/codeoutline/{cpp_bindings.lua → analysis/cpp/cpp_bindings.lua} +7 -7
  10. package/scripts/codeoutline/{cpp_implementations.lua → analysis/cpp/cpp_implementations.lua} +3 -3
  11. package/scripts/codeoutline/{cpp_includes.lua → analysis/cpp/cpp_includes.lua} +3 -3
  12. package/scripts/codeoutline/{cpp_macros.lua → analysis/cpp/cpp_macros.lua} +3 -3
  13. package/scripts/codeoutline/{cpp_receivers.lua → analysis/cpp/cpp_receivers.lua} +7 -7
  14. package/scripts/codeoutline/{cpp_types.lua → analysis/cpp/cpp_types.lua} +5 -5
  15. package/scripts/codeoutline/{csharp_bindings.lua → analysis/csharp/csharp_bindings.lua} +1 -1
  16. package/scripts/codeoutline/{dispatch_aliases.lua → analysis/dispatch_aliases.lua} +3 -3
  17. package/scripts/codeoutline/{foreign.lua → analysis/foreign.lua} +2 -2
  18. package/scripts/codeoutline/{function_values.lua → analysis/function_values.lua} +2 -2
  19. package/scripts/codeoutline/analysis/go/go_frameworks.lua +327 -0
  20. package/scripts/codeoutline/{go_methods.lua → analysis/go/go_methods.lua} +2 -2
  21. package/scripts/codeoutline/{go_modules.lua → analysis/go/go_modules.lua} +2 -2
  22. package/scripts/codeoutline/{graph.lua → analysis/graph.lua} +53 -47
  23. package/scripts/codeoutline/{implementations.lua → analysis/implementations.lua} +16 -9
  24. package/scripts/codeoutline/{indirect.lua → analysis/indirect.lua} +71 -13
  25. package/scripts/codeoutline/{js_evidence.lua → analysis/js/js_evidence.lua} +4 -3
  26. package/scripts/codeoutline/{js_resolution.lua → analysis/js/js_resolution.lua} +2 -2
  27. package/scripts/codeoutline/{js_workspace.lua → analysis/js/js_workspace.lua} +2 -2
  28. package/scripts/codeoutline/{ts_implementations.lua → analysis/js/ts_implementations.lua} +3 -3
  29. package/scripts/codeoutline/{foreign_lua.lua → analysis/lua/foreign_lua.lua} +3 -3
  30. package/scripts/codeoutline/{lua_bindings.lua → analysis/lua/lua_bindings.lua} +97 -11
  31. package/scripts/codeoutline/{lua_callback_loops.lua → analysis/lua/lua_callback_loops.lua} +1 -1
  32. package/scripts/codeoutline/{ordinary_bindings.lua → analysis/ordinary_bindings.lua} +45 -21
  33. package/scripts/codeoutline/{python_bindings.lua → analysis/python/python_bindings.lua} +2 -2
  34. package/scripts/codeoutline/analysis/receivers.lua +547 -0
  35. package/scripts/codeoutline/{rust_packages.lua → analysis/rust/rust_packages.lua} +2 -2
  36. package/scripts/codeoutline/analysis/rust/rust_resolution.lua +609 -0
  37. package/scripts/codeoutline/{shared_events.lua → analysis/shared_events.lua} +3 -3
  38. package/scripts/codeoutline/{static_dispatch.lua → analysis/static_dispatch.lua} +5 -5
  39. package/scripts/codeoutline/{type_uses.lua → analysis/type_uses.lua} +1 -1
  40. package/scripts/codeoutline/cli.lua +1 -1
  41. package/scripts/codeoutline/command.lua +10 -8
  42. package/scripts/codeoutline/{cpp_fragments.lua → indexing/cpp_fragments.lua} +4 -4
  43. package/scripts/codeoutline/{index.lua → indexing/index.lua} +12 -12
  44. package/scripts/codeoutline/{parse_pool.lua → indexing/parse_pool.lua} +1 -1
  45. package/scripts/codeoutline/{agent_config.lua → install/agent_config.lua} +21 -1
  46. package/scripts/codeoutline/{agent_install.lua → install/agent_install.lua} +2 -2
  47. package/scripts/codeoutline/{editor_install.lua → install/editor_install.lua} +34 -6
  48. package/scripts/codeoutline/lang/c.lua +2 -2
  49. package/scripts/codeoutline/lang/cpp.lua +2 -2
  50. package/scripts/codeoutline/lang/csharp.lua +2 -2
  51. package/scripts/codeoutline/lang/go.lua +2 -2
  52. package/scripts/codeoutline/lang/java.lua +2 -2
  53. package/scripts/codeoutline/lang/js.lua +2 -2
  54. package/scripts/codeoutline/lang/kotlin.lua +4 -2
  55. package/scripts/codeoutline/lang/lua.lua +3 -3
  56. package/scripts/codeoutline/lang/python.lua +2 -2
  57. package/scripts/codeoutline/lang/rust.lua +3 -3
  58. package/scripts/codeoutline/main.lua +9 -9
  59. package/scripts/codeoutline/{common.lua → parsing/common.lua} +22 -17
  60. package/scripts/codeoutline/{language_detect.lua → parsing/language_detect.lua} +1 -1
  61. package/scripts/codeoutline/{parse.lua → parsing/parse.lua} +4 -4
  62. package/scripts/codeoutline/{http.lua → protocol/http.lua} +1 -1
  63. package/scripts/codeoutline/{lsp.lua → protocol/lsp.lua} +4 -4
  64. package/scripts/codeoutline/{mcp.lua → protocol/mcp.lua} +9 -9
  65. package/scripts/codeoutline/{affected.lua → query/affected.lua} +6 -6
  66. package/scripts/codeoutline/{callers.lua → query/callers.lua} +9 -9
  67. package/scripts/codeoutline/{completion.lua → query/completion.lua} +37 -49
  68. package/scripts/codeoutline/{definition_candidates.lua → query/definition_candidates.lua} +6 -6
  69. package/scripts/codeoutline/{documents.lua → query/documents.lua} +4 -4
  70. package/scripts/codeoutline/{explore.lua → query/explore.lua} +85 -25
  71. package/scripts/codeoutline/{external_headers.lua → query/external_headers.lua} +6 -6
  72. package/scripts/codeoutline/{navigation.lua → query/navigation.lua} +53 -54
  73. package/scripts/codeoutline/{on_demand.lua → query/on_demand.lua} +6 -6
  74. package/scripts/codeoutline/{query_report.lua → query/query_report.lua} +9 -5
  75. package/scripts/codeoutline/{search_ranking.lua → query/search_ranking.lua} +10 -7
  76. package/scripts/codeoutline/{type_hierarchy.lua → query/type_hierarchy.lua} +11 -11
  77. package/scripts/codeoutline/{type_references.lua → query/type_references.lua} +17 -17
  78. package/scripts/codeoutline/{index_worker.lua → runtime/index_worker.lua} +10 -10
  79. package/scripts/codeoutline/{parse_worker.lua → runtime/parse_worker.lua} +2 -2
  80. package/scripts/codeoutline/{update_worker.lua → runtime/update_worker.lua} +1 -1
  81. package/scripts/codeoutline/service.lua +11 -11
  82. package/scripts/codeoutline/update_sequence.lua +1 -1
  83. package/scripts/codeoutline/version.lua +1 -1
  84. package/scripts/codeoutline/rust_resolution.lua +0 -301
  85. /package/scripts/codeoutline/{lua_literal.lua → analysis/lua/lua_literal.lua} +0 -0
  86. /package/scripts/codeoutline/{resolution.lua → analysis/resolution.lua} +0 -0
  87. /package/scripts/codeoutline/{cargo_toml.lua → analysis/rust/cargo_toml.lua} +0 -0
  88. /package/scripts/codeoutline/{type_bases.lua → analysis/type_bases.lua} +0 -0
  89. /package/scripts/codeoutline/{cache_repairs.lua → indexing/cache_repairs.lua} +0 -0
  90. /package/scripts/codeoutline/{daemon.lua → install/daemon.lua} +0 -0
  91. /package/scripts/codeoutline/{install_prompt.lua → install/install_prompt.lua} +0 -0
  92. /package/scripts/codeoutline/{xscan.lua → parsing/xscan.lua} +0 -0
  93. /package/scripts/codeoutline/{lsp_trace.lua → protocol/lsp_trace.lua} +0 -0
  94. /package/scripts/codeoutline/{coverage.lua → query/coverage.lua} +0 -0
  95. /package/scripts/codeoutline/{query_filters.lua → query/query_filters.lua} +0 -0
  96. /package/scripts/codeoutline/{idle_gc.lua → runtime/idle_gc.lua} +0 -0
  97. /package/scripts/codeoutline/{control.lua → shared/control.lua} +0 -0
  98. /package/scripts/codeoutline/{path.lua → shared/path.lua} +0 -0
  99. /package/scripts/codeoutline/{rules.lua → shared/rules.lua} +0 -0
  100. /package/scripts/codeoutline/{text.lua → shared/text.lua} +0 -0
@@ -10,12 +10,12 @@
10
10
  -- grouped by file, as `line<TAB>code` like the Read tool
11
11
  -- 3. callers / callees of the named symbols (locations only)
12
12
  -- 4. other matches that did not fit, as pointers
13
- -- Big bodies are cut to head + tail; classes over the limit collapse to a
13
+ -- Big bodies keep their head/tail and relevant call windows; classes over the limit collapse to a
14
14
  -- member outline; anything past the budget becomes a pointer line.
15
15
 
16
- local graph = require('codeoutline.graph')
17
- local text = require('codeoutline.text')
18
- local control = require('codeoutline.control')
16
+ local graph = require('codeoutline.analysis.graph')
17
+ local text = require('codeoutline.shared.text')
18
+ local control = require('codeoutline.shared.control')
19
19
 
20
20
  local M = {}
21
21
 
@@ -27,7 +27,7 @@ function M.validate(query, opts)
27
27
  assert(type(query) == 'string' and query:find('%S') and #query <= 4096 and not query:find('%z'),
28
28
  'query must contain 1-4096 bytes of non-empty text without NUL')
29
29
  assert(text.valid(query) == query, 'query must be valid UTF-8')
30
- require('codeoutline.query_filters').parse(query)
30
+ require('codeoutline.query.query_filters').parse(query)
31
31
  assert(opts == nil or type(opts) == 'table', 'options must be a table')
32
32
  local budget = M.DEFAULT_BUDGET
33
33
  if opts and opts.budget ~= nil then budget = opts.budget end
@@ -79,6 +79,14 @@ local function terms(query)
79
79
  local key = kind .. ':' .. text
80
80
  if not seen[key] then seen[key] = true; out[#out + 1] = { kind = kind, text = text } end
81
81
  end
82
+ -- A path is one term, not a bag of directory names such as src/login.
83
+ query = query:gsub('\\', '/'):gsub('[%w_%-%./]+%.[%a][%w_]*', function(path)
84
+ local ext = path:match('%.(%a+)$')
85
+ if path:find('/') or ext and require('codeoutline.parsing.parse').EXTENSIONS[ext:lower()] then
86
+ add('file', path); return string.rep(' ', #path)
87
+ end
88
+ return path
89
+ end)
82
90
  for chain in query:gmatch('[%a_][%w_]*[%.:%->]+[%a_][%w_%.:%->]*') do
83
91
  if chain:match('%.%a+$') and chain:match('^[%w_/%-]+%.%a+$') and not chain:find('::') then
84
92
  add('file', chain)
@@ -108,10 +116,10 @@ local function terms(query)
108
116
  end
109
117
 
110
118
  local function find_seeds(G, query, filters, ranking)
111
- local predicate = require('codeoutline.query_filters')
119
+ local predicate = require('codeoutline.query.query_filters')
112
120
  local function seed_score(id, exact, explicit)
113
121
  local s = (KIND_WEIGHT[G.nodes[id].kind] or 1) + (exact and 20 or 0)
114
- return s - ranking.penalty(G.files[G.node_file[id]].path, explicit)
122
+ return s - ranking.penalty(G.files[G.node_file[id]].path, explicit, G.nodes[id])
115
123
  end
116
124
  local cands = {} -- id -> score
117
125
  local files = {} -- file indices named in the query
@@ -204,14 +212,13 @@ local function find_seeds(G, query, filters, ranking)
204
212
  end
205
213
  if query == '' then
206
214
  local count = 0
207
- -- With a configured policy, select the candidate window from preferred
215
+ -- With either policy, select the candidate window from preferred
208
216
  -- files first so an early generated directory cannot fill all 512 slots.
209
- for pass = 1, ranking.configured and 2 or 1 do
217
+ for pass = 1, 2 do
210
218
  for _, f in ipairs(G.file_order) do
211
219
  control.check()
212
220
  local rec = G.files[f]
213
- if predicate.file(filters, rec) and (not ranking.configured
214
- or (ranking.penalty(rec.path) > 0) == (pass == 2)) then
221
+ if predicate.file(filters, rec) and (ranking.penalty(rec.path) > 0) == (pass == 2) then
215
222
  for i, id in ipairs(G.id_of[f]) do
216
223
  if i % 256 == 0 then control.check() end
217
224
  if predicate.id(filters, G, id) then
@@ -300,9 +307,9 @@ local function render_range(lines, a, b, out)
300
307
  end
301
308
  end
302
309
 
303
- -- Source block for one node, cut to `full` lines (head + tail beyond).
310
+ -- Source block for one node, capped at `full` source lines, preserving call sites.
304
311
  -- Classes/structs over the limit collapse to their member outline.
305
- local function node_block(G, idx, id, full)
312
+ local function node_block(G, idx, id, full, focus)
306
313
  local node = G.nodes[id]
307
314
  local lines = file_lines(idx, G.files[G.node_file[id]].path)
308
315
  local a, b = node.line, math.max(node.end_line, node.line)
@@ -322,16 +329,62 @@ local function node_block(G, idx, id, full)
322
329
  for _, k in ipairs(kids) do
323
330
  local kn = G.nodes[k]
324
331
  if not rows[kn.line] then row_lines[#row_lines + 1] = kn.line end
325
- rows[kn.line] = require('codeoutline.navigation').detail(G, G.node_file[k], kn).sig or kn.name
332
+ rows[kn.line] = require('codeoutline.query.navigation').detail(G, G.node_file[k], kn).sig or kn.name
326
333
  end
327
334
  for _, ln in ipairs(row_lines) do
328
335
  out[#out + 1] = string.format('%d\t %s', ln, rows[ln])
329
336
  end
330
337
  out[#out + 1] = string.format('\t... (%s body of %d lines outlined; explore a member for its source)', node.kind, span)
331
338
  else
332
- render_range(lines, a, a + M.CUT_HEAD - 1, out)
333
- out[#out + 1] = string.format('\t... (%d lines omitted) ...', span - M.CUT_HEAD - M.CUT_TAIL)
334
- render_range(lines, b - M.CUT_TAIL + 1, b, out)
339
+ local selected, count = {}, 0
340
+ local function keep(first, last)
341
+ for line = math.max(a, first), math.min(b, last) do
342
+ if not selected[line] and count < full then selected[line], count = true, count + 1 end
343
+ end
344
+ end
345
+ local head, tail = math.min(32, math.floor(full / 3)), math.min(8, math.floor(full / 8))
346
+ keep(a, a + head - 1); keep(b - tail + 1, b)
347
+ local points, seen = {}, {}
348
+ for _, line in ipairs(focus or {}) do
349
+ if line >= a and line <= b and not selected[line] and not seen[line] and #points < 4 then
350
+ points[#points + 1], seen[line] = line, true
351
+ end
352
+ end
353
+ -- When no named path spans the body, sample actual call sites
354
+ -- across it rather than spending every line on the function head.
355
+ if #points == 0 then
356
+ local refs, calls = G.files[G.node_file[id]].refs, {}
357
+ local from = id - G.id_of[G.node_file[id]][1] + 1
358
+ for i, line in ipairs(refs.line) do
359
+ if i % 128 == 0 then control.check() end
360
+ if refs.from[i] == from and line > a + head and line < b - tail
361
+ and (refs.kind[i] == 'call' or refs.kind[i] == 'member_call') then
362
+ calls[#calls + 1] = line
363
+ if (refs.name[i] == 'pcall' or refs.name[i] == 'xpcall') and not seen[line] and #points < 2 then
364
+ points[#points + 1], seen[line] = line, true
365
+ end
366
+ end
367
+ end
368
+ table.sort(calls)
369
+ for i = 1, math.min(3, #calls) do
370
+ local line = calls[math.ceil(#calls * i / (math.min(3, #calls) + 1))]
371
+ if not seen[line] and #points < 4 then points[#points + 1], seen[line] = line, true end
372
+ end
373
+ end
374
+ local radius = math.max(0, math.min(12, math.floor((full - count) / math.max(1, #points) / 2) - 1))
375
+ for _, line in ipairs(points) do keep(line - radius, line + radius) end
376
+ if #points == 0 then
377
+ keep(a, a + math.min(M.CUT_HEAD, full - tail) - 1)
378
+ keep(b - M.CUT_TAIL + 1, b)
379
+ end
380
+ local ordered = {}; for line in pairs(selected) do ordered[#ordered + 1] = line end
381
+ table.sort(ordered)
382
+ local previous = a - 1
383
+ for _, line in ipairs(ordered) do
384
+ if line > previous + 1 then out[#out + 1] = string.format('\t... (%d lines omitted) ...', line - previous - 1) end
385
+ render_range(lines, line, line, out); previous = line
386
+ end
387
+ if previous < b then out[#out + 1] = string.format('\t... (%d lines omitted) ...', b - previous) end
335
388
  end
336
389
  end
337
390
  return table.concat(out, '\n'), span > full
@@ -342,7 +395,7 @@ local function label(G, id)
342
395
  return string.format('%s %s (%s)', node.kind, node.qualified, graph.where(G, id))
343
396
  end
344
397
 
345
- local edge_label = require('codeoutline.query_report').edge_label
398
+ local edge_label = require('codeoutline.query.query_report').edge_label
346
399
 
347
400
  local function candidate_text(G, idx, report, in_order)
348
401
  if #report.entries == 0 then return nil end
@@ -385,11 +438,11 @@ local function run(G, idx, query, opts)
385
438
  local query_opts = {}
386
439
  for key, value in pairs(opts) do query_opts[key] = value end
387
440
  query_opts.explain = true
388
- local ranking = require('codeoutline.search_ranking').policy(G.root or idx.root)
441
+ local ranking = require('codeoutline.query.search_ranking').policy(G.root or idx.root)
389
442
  G = graph.query(G, query_opts)
390
443
  G.stats.ranking = ranking.stats
391
444
  file_cache, source_cache = {}, {}
392
- local filters = require('codeoutline.query_filters').parse(query)
445
+ local filters = require('codeoutline.query.query_filters').parse(query)
393
446
  local ranked, named_files = find_seeds(G, filters.text, filters, ranking)
394
447
 
395
448
  -- Seeds: top-ranked, but at most 3 definitions per name so one generic
@@ -416,7 +469,7 @@ local function run(G, idx, query, opts)
416
469
 
417
470
  -- Spine: nodes on call paths between seeds.
418
471
  local flows, spine, on_spine, flow_edges, flow_files, non_call_paths = {}, {}, {}, {}, {}, false
419
- local reports = require('codeoutline.query_report')
472
+ local reports = require('codeoutline.query.query_report')
420
473
  local searches, missed, connected = {}, {}, {}
421
474
  local path_limited = false
422
475
  for _, a in ipairs(seeds) do
@@ -566,6 +619,13 @@ local function run(G, idx, query, opts)
566
619
  elseif #candidates.entries > 0 then candidate_cut = true end
567
620
  omitted = omitted or candidate_cut
568
621
 
622
+ local focus = {}
623
+ for _, hops in ipairs(flow_edges) do
624
+ for _, hop in ipairs(hops) do
625
+ focus[hop.source] = focus[hop.source] or {}
626
+ focus[hop.source][#focus[hop.source] + 1] = hop.line
627
+ end
628
+ end
569
629
  local reserve = math.floor(budget * 0.15) -- keep room for sections 3-4
570
630
  for _, f in ipairs(file_order) do
571
631
  local rec = G.files[f]
@@ -577,8 +637,8 @@ local function run(G, idx, query, opts)
577
637
  checked_source(idx, rec.path)
578
638
  local ol = {}
579
639
  for _, node in ipairs(rec.nodes) do
580
- if not node.parent and node.kind ~= 'macro' and require('codeoutline.query_filters').node(filters, rec, node) then
581
- ol[#ol + 1] = string.format('%d\t%s %s', node.line, node.kind, require('codeoutline.navigation').detail(G, f, node).sig or node.name)
640
+ if not node.parent and node.kind ~= 'macro' and require('codeoutline.query.query_filters').node(filters, rec, node) then
641
+ ol[#ol + 1] = string.format('%d\t%s %s', node.line, node.kind, require('codeoutline.query.navigation').detail(G, f, node).sig or node.name)
582
642
  end
583
643
  if #ol >= 60 then ol[#ol + 1] = '\t...'; break end
584
644
  end
@@ -587,7 +647,7 @@ local function run(G, idx, query, opts)
587
647
  elseif items.outline then omitted = true end
588
648
  for _, item in ipairs(items) do
589
649
  if not shown[item.id] and used + #header + 16 < budget - reserve then
590
- local block, source_cut = node_block(G, idx, item.id, item.full)
650
+ local block, source_cut = node_block(G, idx, item.id, item.full, focus[item.id])
591
651
  omitted = omitted or source_cut
592
652
  local need = #block + (wrote_header and 0 or #header + 1) + 1
593
653
  if used + need < budget - reserve then
@@ -664,7 +724,7 @@ local function run(G, idx, query, opts)
664
724
  end
665
725
 
666
726
  if G.incomplete then
667
- local reasons = require('codeoutline.coverage').relations({ relationships_incomplete = true, query_stats = G.stats })
727
+ local reasons = require('codeoutline.query.coverage').relations({ relationships_incomplete = true, query_stats = G.stats })
668
728
  prepend('Relationships incomplete: ' .. table.concat(reasons, ', ') .. '.')
669
729
  end
670
730
  if path_limited then
@@ -1,7 +1,7 @@
1
1
  -- Declaration navigation in selected external headers. Never extend the index.
2
2
  local M = { MAX_FILES = 64, MAX_PROJECT_FILES = 128, MAX_BYTES = 4 * 1024 * 1024,
3
3
  MAX_FILE_BYTES = 1024 * 1024, CACHE_FILES = 32, CACHE_BYTES = 8 * 1024 * 1024, TIME_MS = 500 }
4
- local paths, control = require('codeoutline.path'), require('codeoutline.control')
4
+ local paths, control = require('codeoutline.shared.path'), require('codeoutline.shared.control')
5
5
  local cache, order, cache_bytes, scanner = {}, {}, 0, nil
6
6
  local function directory(file) return file:match('^(.*)/[^/]+$') end
7
7
  local function existing(file)
@@ -31,7 +31,7 @@ local function read(file, info)
31
31
  if not scanner then
32
32
  local config = {}; for k, v in pairs(require('codeoutline.lang.c').config) do config[k] = v end
33
33
  config.pp_first_branch = false
34
- scanner = require('codeoutline.xscan').lang(config)
34
+ scanner = require('codeoutline.parsing.xscan').lang(config)
35
35
  end
36
36
  local T = scanner:tokenize(source)
37
37
  local imports = {}
@@ -58,7 +58,7 @@ local function declarations(entry, name, type_site, prefix)
58
58
  local source = prefix and entry.source:lower() or entry.source
59
59
  if not source:find('%f[%w_$]' .. escaped .. (prefix and '' or '%f[^%w_$]')) then return {} end
60
60
  if not entry.nodes then
61
- local rec = require('codeoutline.parse').parse(entry.file, entry.source, { type_uses = false, analysis = false })
61
+ local rec = require('codeoutline.parsing.parse').parse(entry.file, entry.source, { type_uses = false, analysis = false })
62
62
  entry.nodes = rec and rec.nodes or {}
63
63
  local weight = #entry.nodes * 256
64
64
  if cache[paths.key(entry.file)] == entry then
@@ -72,7 +72,7 @@ local function declarations(entry, name, type_site, prefix)
72
72
  for _, node in ipairs(entry.nodes) do
73
73
  if (prefix and node.name:sub(1, #name):lower() == name or not prefix and node.name == name)
74
74
  and node.qualified == node.name and not node.parent and node.name_start
75
- and (type_site and require('codeoutline.type_references').kinds[node.kind]
75
+ and (type_site and require('codeoutline.query.type_references').kinds[node.kind]
76
76
  or not type_site and (node.kind == 'prototype' or node.kind == 'function')) then
77
77
  result[#result + 1] = { node = node, file = entry.file, source = entry.source,
78
78
  declaration = node.kind == 'prototype' or node.decl == true }
@@ -87,8 +87,8 @@ function M.find(G, f, site, ctx, system_directories, completion)
87
87
  and not site.recv and site.evidence and site.evidence.written == site.name
88
88
  and not site.evidence.value_shadowed
89
89
  if not site or site.recv or not type_site and (site.kind ~= 'call'
90
- or not require('codeoutline.definition_candidates').allowed(site)) then return {}, info end
91
- local includes = require('codeoutline.cpp_includes')
90
+ or not require('codeoutline.query.definition_candidates').allowed(site)) then return {}, info end
91
+ local includes = require('codeoutline.analysis.cpp.cpp_includes')
92
92
  local headers, queued, projects, visited, project_queued = {}, {}, { f }, {}, { [f] = true }
93
93
  local defaults, started = nil, xtimer.now_ms()
94
94
  local function expired()
@@ -5,13 +5,13 @@
5
5
  -- file itself), so drafts hide the disk records of their files. Nothing here
6
6
  -- is persisted: exact positions come from reparsing only the files a result
7
7
  -- names, and callers are found by one scan of reference names per request.
8
- local graph = require('codeoutline.graph')
8
+ local graph = require('codeoutline.analysis.graph')
9
9
  local service = require('codeoutline.service')
10
- local documents = require('codeoutline.documents')
11
- local paths = require('codeoutline.path')
12
- local control = require('codeoutline.control')
13
- local lsp = require('codeoutline.lsp')
14
- local parse = require('codeoutline.parse')
10
+ local documents = require('codeoutline.query.documents')
11
+ local paths = require('codeoutline.shared.path')
12
+ local control = require('codeoutline.shared.control')
13
+ local lsp = require('codeoutline.protocol.lsp')
14
+ local parse = require('codeoutline.parsing.parse')
15
15
  -- Reference scans stop at a result count or time budget and report truncation.
16
16
  local M = { MAX_RESULTS = 1000, MAX_HOVER = 3, SCAN_SECONDS = 3, POSITION_SECONDS = 2,
17
17
  MAX_FILE_BYTES = 1048576, CACHE_FILES = 64 }
@@ -32,7 +32,6 @@ local CALLS = { ['function'] = true, method = true, macro = true, constructor =
32
32
  prototype = true, destructor = true, class = true, record = true }
33
33
  local MEMBER = { ['.'] = true, ['->'] = true, ['::'] = true, ['?.'] = true }
34
34
  local LUA_MEMBER = { ['.'] = true, [':'] = true }
35
- local SELF = { self = true, this = true, cls = true }
36
35
  local PROTOTYPE = { prototype = true }
37
36
  local C_FAMILY = { c = true, cpp = true }
38
37
 
@@ -79,10 +78,10 @@ local function view(session, root, include_paths, only)
79
78
  local G = idx:symbols()
80
79
  local V = setmetatable({ root = root, idx = idx, drafts = {}, disk = {}, dep_cache = {}, new_files = {},
81
80
  next_file = G.next_file, next_node = G.next_node, next_dir = G.next_dir }, { __index = G })
82
- V.js_context = require('codeoutline.js_resolution').context(V)
81
+ V.js_context = require('codeoutline.analysis.js.js_resolution').context(V)
83
82
  V.js_context.include_paths = include_paths
84
- V.js_context.lua = require('codeoutline.lua_bindings').context(V)
85
- V.js_context.ordinary = require('codeoutline.ordinary_bindings').context(V, V.js_context, function(f)
83
+ V.js_context.lua = require('codeoutline.analysis.lua.lua_bindings').context(V)
84
+ V.js_context.ordinary = require('codeoutline.analysis.ordinary_bindings').context(V, V.js_context, function(f)
86
85
  return V.drafts[f] and V.drafts[f].source
87
86
  end, { cache = binding_cache, parsed = function(f) return M.full(V, f) end })
88
87
  V.js_context.lua.ordinary = V.js_context.ordinary
@@ -95,7 +94,7 @@ local function view(session, root, include_paths, only)
95
94
  local f = rel and V.file_index[rel]
96
95
  if not rel or (f and V.drafts[f]) then return f end
97
96
  local hint = f and V.files[f].cpp_fragment
98
- and not require('codeoutline.language_detect').resolve('', doc.language, false) and V.files[f].language or nil
97
+ and not require('codeoutline.parsing.language_detect').resolve('', doc.language, false) and V.files[f].language or nil
99
98
  if doc.indexed_language ~= hint then
100
99
  doc.indexed_language, doc.parsed, doc.full, doc.branch_tokens = hint, nil, nil, nil
101
100
  end
@@ -125,7 +124,7 @@ local function view(session, root, include_paths, only)
125
124
  local list = added[node.name]
126
125
  if not list then list = {}; added[node.name] = list end
127
126
  list[#list + 1] = id
128
- for _, alias in ipairs(require('codeoutline.lua_bindings').aliases(node, V.lua_global_export_tables)) do
127
+ for _, alias in ipairs(require('codeoutline.analysis.lua.lua_bindings').aliases(node, V.lua_global_export_tables)) do
129
128
  added[alias] = added[alias] or {}
130
129
  added[alias][#added[alias] + 1] = id
131
130
  end
@@ -179,7 +178,6 @@ end
179
178
  -- self.f() inside f, or M.f() inside M.f / Box::f() inside Box::f.
180
179
  local function recursive(node, recv)
181
180
  if not recv then return false end
182
- if SELF[recv] then return true end
183
181
  local q = node.qualified
184
182
  for _, sep in ipairs({ '.', ':', '::' }) do
185
183
  local tail = recv .. sep .. node.name
@@ -193,7 +191,7 @@ local function resolve_site(V, f, from, name, kind, recv, evidence, offset, inde
193
191
  if kind == 'type' then
194
192
  local site = type(evidence) == 'table' and evidence
195
193
  if not site then return {}, 'unsupported type position' end
196
- return require('codeoutline.type_references').resolve(V, f, from > 0 and V.id_of[f][from] or nil,
194
+ return require('codeoutline.query.type_references').resolve(V, f, from > 0 and V.id_of[f][from] or nil,
197
195
  site, V.js_context, nil, definition)
198
196
  end
199
197
  if index then evidence = V.js_context.ordinary.evidence(f, index) end
@@ -208,7 +206,7 @@ local function resolve_site(V, f, from, name, kind, recv, evidence, offset, inde
208
206
  elseif kind == 'member_symbol' then rkind, accept = 'member_call', ANY
209
207
  elseif definition and kind == 'member_call' and V.files[f].language == 'cpp' then accept = ANY end
210
208
  local site_line = index and V.files[f].refs.line[index] or cursor_line
211
- local targets, reason, macro_state = graph.resolve(V, f, src, name, rkind, recv or nil, direct, paired, accept, evidence, V.js_context, site_line)
209
+ local targets, reason, macro_state = graph.resolve(V, f, src, name, rkind, recv or nil, direct, paired, accept, evidence, V.js_context, site_line, offset)
212
210
  targets = targets or {}
213
211
  if kind == 'symbol' then
214
212
  local kept = {}
@@ -221,7 +219,8 @@ local function resolve_site(V, f, from, name, kind, recv, evidence, offset, inde
221
219
  targets = kept
222
220
  end
223
221
  -- The resolver never binds a ref to its enclosing node, which hides recursion.
224
- if #targets == 0 and reason ~= 'unknown or unsupported macro visibility' and src and V.nodes[src].name == name and (kind == 'call' or recursive(V.nodes[src], recv)) then
222
+ local receiver_bound = recv and evidence and evidence ~= '' or reason and reason:match('^receiver:')
223
+ if #targets == 0 and not receiver_bound and reason ~= 'unknown or unsupported macro visibility' and src and V.nodes[src].name == name and (kind == 'call' or recursive(V.nodes[src], recv)) then
225
224
  targets = { src }
226
225
  end
227
226
  -- Definitions too far apart to choose between: a visible prototype still
@@ -233,10 +232,10 @@ local function resolve_site(V, f, from, name, kind, recv, evidence, offset, inde
233
232
  -- methods the C side registers (`local pool = mod.open()`, then `pool:read()`).
234
233
  if #targets == 0 and recv and (kind == 'member_call' or kind == 'member_symbol')
235
234
  and V.files[f].language == 'lua' then
236
- local bindings = require('codeoutline.lua_bindings')
235
+ local bindings = require('codeoutline.analysis.lua.lua_bindings')
237
236
  local ctx = V.js_context.lua
238
237
  local rec, T
239
- if offset and require('codeoutline.foreign').has_candidates(V, ctx) then rec, T = M.full(V, f) end
238
+ if offset and require('codeoutline.analysis.foreign').has_candidates(V, ctx) then rec, T = M.full(V, f) end
240
239
  if T then
241
240
  local target = bindings.receiver(V, rec, T, recv, offset, V.js_context.lua)
242
241
  for _, entry in ipairs(bindings.member(V, target, name)) do
@@ -311,7 +310,7 @@ local function macro_body_cursor(doc, offset, rec)
311
310
  local config = {}
312
311
  for k, v in pairs(require('codeoutline.lang.' .. rec.language).config) do config[k] = v end
313
312
  config.directive, config.pp_first_branch = nil, nil
314
- scanner = require('codeoutline.xscan').lang(config)
313
+ scanner = require('codeoutline.parsing.xscan').lang(config)
315
314
  macro_body_scanners[rec.language] = scanner
316
315
  end
317
316
  local body = scanner:tokenize(text)
@@ -391,12 +390,12 @@ local function cursor(doc, offset, V, f, include_inactive)
391
390
  if rec.language == 'csharp' then
392
391
  local first = t
393
392
  while (T:text(first - 1) == '.' or T:text(first - 1) == '::') and T.k[first - 2] == 'id' do first = first - 2 end
394
- local name = require('codeoutline.csharp_bindings').name(T.src:sub(T.s[first], T.e[t]))
393
+ local name = require('codeoutline.analysis.csharp.csharp_bindings').name(T.src:sub(T.s[first], T.e[t]))
395
394
  evidence = name and 'cs:name:' .. name .. '\0' .. (T.s[first] - 1)
396
395
  elseif C_FAMILY[rec.language] then
397
- evidence = require('codeoutline.cpp_receivers').evidence(T, t)
396
+ evidence = require('codeoutline.analysis.cpp.cpp_receivers').evidence(T, t)
398
397
  if not evidence and rec.language == 'cpp' and (not recv or T:text(t - 1) == '::') then
399
- evidence = require('codeoutline.cpp_types').evidence(T, t)
398
+ evidence = require('codeoutline.analysis.cpp.cpp_types').evidence(T, t)
400
399
  end
401
400
  end
402
401
  return { from = from, name = T:text(t), kind = kind, recv = recv, first = T.s[t] - 1, last = T.e[t], evidence = evidence }
@@ -589,10 +588,10 @@ local function expand(V, set)
589
588
  local f, g = V.node_file[id], V.node_file[candidate]
590
589
  local language = V.files[f].language
591
590
  if not C_FAMILY[language] then return true end
592
- local owner_a = language == 'cpp' and require('codeoutline.cpp_types').owner(V, f, a, V.js_context)
593
- local owner_b = V.files[g].language == 'cpp' and require('codeoutline.cpp_types').owner(V, g, b, V.js_context)
591
+ local owner_a = language == 'cpp' and require('codeoutline.analysis.cpp.cpp_types').owner(V, f, a, V.js_context)
592
+ local owner_b = V.files[g].language == 'cpp' and require('codeoutline.analysis.cpp.cpp_types').owner(V, g, b, V.js_context)
594
593
  if owner_a and owner_b then return owner_a == owner_b end
595
- if not require('codeoutline.cpp_includes').policy(V, f, V.js_context).configured then return true end
594
+ if not require('codeoutline.analysis.cpp.cpp_includes').policy(V, f, V.js_context).configured then return true end
596
595
  if owner_a or owner_b then return false end
597
596
  local source, header = is_decl(a) and g or f, is_decl(a) and f or g
598
597
  return graph.directly_includes(V, source, header, V.js_context)
@@ -623,7 +622,7 @@ local function scan(V, targets, name)
623
622
  local hits, deadline = {}, os.clock() + M.SCAN_SECONDS
624
623
  local wanted = { [name] = true }
625
624
  for id in pairs(targets) do
626
- for _, alias in ipairs(require('codeoutline.lua_bindings').aliases(V.nodes[id], V.lua_global_export_tables)) do wanted[alias] = true end
625
+ for _, alias in ipairs(require('codeoutline.analysis.lua.lua_bindings').aliases(V.nodes[id], V.lua_global_export_tables)) do wanted[alias] = true end
627
626
  local f = V.node_file[id]
628
627
  if V.files[f].language == 'lua' then
629
628
  local n = id - V.id_of[f][1] + 1
@@ -638,7 +637,7 @@ local function scan(V, targets, name)
638
637
  control.check()
639
638
  local alias_refs = V.js_context.ordinary.aliases(f, targets, candidates)
640
639
  if V.files[f].language == 'rust' then
641
- for i in pairs(require('codeoutline.rust_resolution').alias_refs(V, f, targets, V.js_context)) do alias_refs[i] = true end
640
+ for i in pairs(require('codeoutline.analysis.rust.rust_resolution').alias_refs(V, f, targets, V.js_context)) do alias_refs[i] = true end
642
641
  end
643
642
  local refs = V.files[f].refs
644
643
  local lua_evidence = refs.lua_binding
@@ -668,16 +667,16 @@ local function scan(V, targets, name)
668
667
  end
669
668
  end
670
669
  return hits, V.js_context.include_incomplete or V.js_context.workspace_incomplete or V.js_context.go_incomplete or V.js_context.go_methods_incomplete
671
- or V.js_context.rust_incomplete or false
670
+ or V.js_context.rust_incomplete or V.js_context.receiver_incomplete or false
672
671
  end
673
672
 
674
673
  -- Files one import record resolves to, through the graph's dependency
675
674
  -- rules: a temporary record holding only that import.
676
675
  function M.import_files(V, f, imp)
677
676
  local rec = V.files[f]
678
- if C_FAMILY[rec.language] then return (require('codeoutline.cpp_includes').resolve(V, f, imp, V.js_context)) end
677
+ if C_FAMILY[rec.language] then return (require('codeoutline.analysis.cpp.cpp_includes').resolve(V, f, imp, V.js_context)) end
679
678
  if rec.language == 'rust' then
680
- local files = require('codeoutline.rust_resolution').imports(V, f, imp, V.js_context)
679
+ local files = require('codeoutline.analysis.rust.rust_resolution').imports(V, f, imp, V.js_context)
681
680
  if files then return files end
682
681
  end
683
682
  local fake = { path = rec.path, language = rec.language,
@@ -753,7 +752,7 @@ local function probe_includes()
753
752
  end
754
753
 
755
754
  function M.external_completions(V, f, prefix, line, expired, limit)
756
- return require('codeoutline.external_headers').find(V, f,
755
+ return require('codeoutline.query.external_headers').find(V, f,
757
756
  { name = prefix, kind = 'call', reason = 'no indexed target', line = line },
758
757
  V.js_context, probe_includes, { expired = expired, limit = limit })
759
758
  end
@@ -768,14 +767,14 @@ local function import_targets(V, f, line)
768
767
  for _, imp in ipairs(rec.imports or {}) do
769
768
  if imp.line == line then
770
769
  if rec.language == 'lua' and imp.kind == 'require' then
771
- for _, id in ipairs(require('codeoutline.foreign').lua_entrypoints(V, imp.path)) do
770
+ for _, id in ipairs(require('codeoutline.analysis.foreign').lua_entrypoints(V, imp.path)) do
772
771
  local loc = location(V, id)
773
772
  if loc and not seen[loc.uri] then seen[loc.uri] = true; result[#result + 1] = loc end
774
773
  end
775
774
  end
776
775
  local files, selected, header
777
776
  if C_FAMILY[rec.language] then
778
- files, selected, header = require('codeoutline.cpp_includes').resolve(V, f, imp, V.js_context)
777
+ files, selected, header = require('codeoutline.analysis.cpp.cpp_includes').resolve(V, f, imp, V.js_context)
779
778
  if imp.system and not selected then files = {} end
780
779
  else files = M.import_files(V, f, imp) end
781
780
  for _, g in ipairs(files) do add(uri_of(V, g)) end
@@ -796,11 +795,11 @@ end
796
795
 
797
796
  -- Project-local declarative rules; read per request so configuration edits are live.
798
797
  local function definition_rules(root)
799
- return require('codeoutline.rules').load(root).definitions
798
+ return require('codeoutline.shared.rules').load(root).definitions
800
799
  end
801
800
 
802
801
  -- Decode literals without running source code. Lua long strings and quoted escapes.
803
- local string_value = require('codeoutline.lua_literal').decode
802
+ local string_value = require('codeoutline.analysis.lua.lua_literal').decode
804
803
 
805
804
  local function call_name(T, i)
806
805
  if T.k[i] ~= 'id' or T:text(i + 1) ~= '(' then return nil end
@@ -911,7 +910,7 @@ local function shared_definition(V, doc, offset, rules)
911
910
  end
912
911
  for _, rule in ipairs(rules) do
913
912
  if rule.shared and (not rule.language or rule.language == language)
914
- and require('codeoutline.indirect').candidate(record, rule.call) then
913
+ and require('codeoutline.analysis.indirect').candidate(record, rule.call) then
915
914
  applicable[#applicable + 1] = rule
916
915
  names[rule.call] = true
917
916
  if rule.register then names[rule.register] = true end
@@ -1001,7 +1000,7 @@ local function shared_definition(V, doc, offset, rules)
1001
1000
  end
1002
1001
  end
1003
1002
  else
1004
- resolver = resolver or require('codeoutline.indirect').query(V, { rule }).resolve_targets
1003
+ resolver = resolver or require('codeoutline.analysis.indirect').query(V, { rule }).resolve_targets
1005
1004
  for _, id in ipairs(resolver(f, match.site, match.arg, rule.kind == 'target')) do
1006
1005
  control.check()
1007
1006
  if os.clock() > deadline then return result, true end
@@ -1020,7 +1019,7 @@ local function shared_definition(V, doc, offset, rules)
1020
1019
  local candidate = false
1021
1020
  if V.files[file].language == language then
1022
1021
  for _, match in ipairs(events) do
1023
- if require('codeoutline.indirect').candidate(V.files[file], match.rule.register) then candidate = true; break end
1022
+ if require('codeoutline.analysis.indirect').candidate(V.files[file], match.rule.register) then candidate = true; break end
1024
1023
  end
1025
1024
  end
1026
1025
  if candidate then
@@ -1214,7 +1213,7 @@ function handlers.lsp_warm(req)
1214
1213
  if not rec then return false end
1215
1214
  files, bytes = files + 1, bytes + size
1216
1215
  local lang = rec.language
1217
- if require('codeoutline.type_uses').languages[lang] or lang == 'python' or lang == 'javascript'
1216
+ if require('codeoutline.analysis.type_uses').languages[lang] or lang == 'python' or lang == 'javascript'
1218
1217
  or lang == 'lua' then V.js_context.ordinary.data(target) end
1219
1218
  return true
1220
1219
  end
@@ -1233,7 +1232,7 @@ end
1233
1232
  function handlers.lsp_implementation(req)
1234
1233
  local V, _, _, targets = at(req)
1235
1234
  if not V then return {} end
1236
- local relationships = require('codeoutline.implementations').context(V, V.js_context)
1235
+ local relationships = require('codeoutline.analysis.implementations').context(V, V.js_context)
1237
1236
  local result, seen = {}, {}
1238
1237
  for _, target in ipairs(targets) do
1239
1238
  for _, id in ipairs(relationships.outgoing(target)) do
@@ -1247,7 +1246,7 @@ function handlers.lsp_definition(req)
1247
1246
  local V, doc, c, targets, f, offset = at(req)
1248
1247
  if not V then return false end
1249
1248
  if not c and (V.files[f].language == 'javascript' or V.files[f].language == 'typescript') then
1250
- local events = require('codeoutline.shared_events').context(V, V.js_context)
1249
+ local events = require('codeoutline.analysis.shared_events').context(V, V.js_context)
1251
1250
  local found, recognized = events.definition(f, offset, doc:position(offset).line + 1)
1252
1251
  if recognized then
1253
1252
  local result = {}; for _, id in ipairs(found) do result[#result + 1] = (location(V, id)) end
@@ -1265,7 +1264,7 @@ function handlers.lsp_definition(req)
1265
1264
  if #targets == 0 and c and c.kind == 'call' and C_FAMILY[V.files[f].language] then
1266
1265
  -- Unknown build flags block execution binding, but F12 can still show
1267
1266
  -- the macro declaration sites that may be active at this call.
1268
- local _, definitions = require('codeoutline.cpp_macros').resolve(V, f, c.name, line, V.js_context, true)
1267
+ local _, definitions = require('codeoutline.analysis.cpp.cpp_macros').resolve(V, f, c.name, line, V.js_context, true)
1269
1268
  if definitions and #definitions > 0 then targets = definitions end
1270
1269
  end
1271
1270
  -- Selecting a loader's member asks for that value, not the imported file.
@@ -1281,12 +1280,12 @@ function handlers.lsp_definition(req)
1281
1280
  -- An import line: `require "a.b"`, `dofile("x.lua")`, `#include <x.h>`, `from . import m`.
1282
1281
  local files = import_targets(V, f, line)
1283
1282
  if #files > 0 or importer then
1284
- return files, V.js_context.include_incomplete or V.js_context.workspace_incomplete or V.js_context.go_incomplete or V.js_context.go_methods_incomplete or V.js_context.rust_incomplete
1283
+ return files, V.js_context.include_incomplete or V.js_context.workspace_incomplete or V.js_context.go_incomplete or V.js_context.go_methods_incomplete or V.js_context.rust_incomplete or V.js_context.receiver_incomplete
1285
1284
  end
1286
1285
  end
1287
1286
  if #targets == 0 then
1288
1287
  if C_FAMILY[V.files[f].language] then
1289
- local entries, info = require('codeoutline.external_headers').find(V, f, c, V.js_context, probe_includes)
1288
+ local entries, info = require('codeoutline.query.external_headers').find(V, f, c, V.js_context, probe_includes)
1290
1289
  if #entries > 0 then
1291
1290
  local result = {}
1292
1291
  for _, entry in ipairs(entries) do
@@ -1296,7 +1295,7 @@ function handlers.lsp_definition(req)
1296
1295
  return result, info.truncated
1297
1296
  end
1298
1297
  end
1299
- local ids, info = require('codeoutline.definition_candidates').find(V, f, c, V.js_context)
1298
+ local ids, info = require('codeoutline.query.definition_candidates').find(V, f, c, V.js_context)
1300
1299
  local result, seen, bytes, started = {}, {}, 0, os.clock()
1301
1300
  local count = 0
1302
1301
  for _, id in ipairs(ids) do
@@ -1311,7 +1310,7 @@ function handlers.lsp_definition(req)
1311
1310
  if hit then result[#result + 1] = { uri = target_doc.uri, range = target_doc:range(hit.name_start, hit.name_end) } end
1312
1311
  end
1313
1312
  return result, info.truncated or V.js_context.include_incomplete or V.js_context.workspace_incomplete
1314
- or V.js_context.go_incomplete or V.js_context.go_methods_incomplete or V.js_context.cpp_receivers_incomplete or V.js_context.rust_incomplete
1313
+ or V.js_context.go_incomplete or V.js_context.go_methods_incomplete or V.js_context.cpp_receivers_incomplete or V.js_context.rust_incomplete or V.js_context.receiver_incomplete
1315
1314
  end
1316
1315
  if c.decl and is_decl(V.nodes[targets[1]]) then
1317
1316
  -- From a declaration, go to its definitions.
@@ -1323,7 +1322,7 @@ function handlers.lsp_definition(req)
1323
1322
  end
1324
1323
  local result = {}
1325
1324
  for _, id in ipairs(targets) do result[#result + 1] = (location(V, id)) end
1326
- return result, V.js_context.include_incomplete or V.js_context.workspace_incomplete or V.js_context.go_incomplete or V.js_context.go_methods_incomplete or V.js_context.cpp_receivers_incomplete or V.js_context.rust_incomplete
1325
+ return result, V.js_context.include_incomplete or V.js_context.workspace_incomplete or V.js_context.go_incomplete or V.js_context.go_methods_incomplete or V.js_context.cpp_receivers_incomplete or V.js_context.rust_incomplete or V.js_context.receiver_incomplete
1327
1326
  end
1328
1327
 
1329
1328
  -- Display tags may be truncated before a heavily annotated SDK declaration's
@@ -1439,12 +1438,12 @@ function handlers.lsp_signature(req)
1439
1438
  for _, id in ipairs(targets) do
1440
1439
  local node = V.nodes[id]
1441
1440
  add_signature(node, M.detail(V, V.node_file[id], node).sig, uri_of(V, V.node_file[id]),
1442
- require('codeoutline.foreign').signature(node, doc:parse().language, T:text(name_token)))
1441
+ require('codeoutline.analysis.foreign').signature(node, doc:parse().language, T:text(name_token)))
1443
1442
  end
1444
1443
  if #targets == 0 and C_FAMILY[doc:parse().language] then
1445
1444
  -- Share definition lookup's bounded, source-validated external-header
1446
1445
  -- cache. SDK declarations stay query-local and never enter the index.
1447
- local entries = require('codeoutline.external_headers').find(V, f,
1446
+ local entries = require('codeoutline.query.external_headers').find(V, f,
1448
1447
  c, V.js_context, probe_includes)
1449
1448
  for _, entry in ipairs(entries) do
1450
1449
  add_signature(entry.node, external_signature(entry), documents.uri(entry.file))
@@ -1461,7 +1460,7 @@ function handlers.lsp_hover(req)
1461
1460
  for k, id in ipairs(targets) do
1462
1461
  if k > M.MAX_HOVER then break end
1463
1462
  local node, rec = V.nodes[id], V.files[V.node_file[id]]
1464
- local foreign = require('codeoutline.foreign').signature(node, doc:parse().language, doc.source:sub(c.first + 1, c.last))
1463
+ local foreign = require('codeoutline.analysis.foreign').signature(node, doc:parse().language, doc.source:sub(c.first + 1, c.last))
1465
1464
  parts[#parts + 1] = '```' .. (foreign and doc:parse().language or rec.language or '') .. '\n'
1466
1465
  .. (foreign and foreign.label or M.detail(V, V.node_file[id], node).sig or node.qualified) .. '\n```'
1467
1466
  parts[#parts + 1] = node.kind .. ' `' .. node.qualified .. '` — ' .. rec.path .. ':' .. node.line
@@ -1537,20 +1536,20 @@ function handlers.lsp_outgoing(req)
1537
1536
  end
1538
1537
  end
1539
1538
  end
1540
- return result, V.js_context.include_incomplete or V.js_context.workspace_incomplete or V.js_context.go_incomplete or V.js_context.go_methods_incomplete or V.js_context.cpp_receivers_incomplete or V.js_context.rust_incomplete
1539
+ return result, V.js_context.include_incomplete or V.js_context.workspace_incomplete or V.js_context.go_incomplete or V.js_context.go_methods_incomplete or V.js_context.cpp_receivers_incomplete or V.js_context.rust_incomplete or V.js_context.receiver_incomplete
1541
1540
  end
1542
1541
 
1543
1542
  function handlers.lsp_references(req)
1544
1543
  local V, _, c, targets = at(req)
1545
1544
  if not V then return {} end
1546
- if #targets == 0 then return {}, V.js_context.workspace_incomplete or V.js_context.go_incomplete or V.js_context.go_methods_incomplete or V.js_context.cpp_receivers_incomplete or V.js_context.rust_incomplete end
1545
+ if #targets == 0 then return {}, V.js_context.workspace_incomplete or V.js_context.go_incomplete or V.js_context.go_methods_incomplete or V.js_context.cpp_receivers_incomplete or V.js_context.rust_incomplete or V.js_context.receiver_incomplete end
1547
1546
  local set = {}
1548
1547
  local type_ids = {}
1549
1548
  for _, id in ipairs(targets) do if TYPES[V.nodes[id].kind] then type_ids[#type_ids + 1] = id end end
1550
1549
  if #type_ids > 0 then
1551
- local engine = require('codeoutline.type_references')
1550
+ local engine = require('codeoutline.query.type_references')
1552
1551
  for _, id in ipairs(type_ids) do
1553
- if not engine.kinds[V.nodes[id].kind] or not require('codeoutline.type_uses').languages[V.files[V.node_file[id]].language] then
1552
+ if not engine.kinds[V.nodes[id].kind] or not require('codeoutline.analysis.type_uses').languages[V.files[V.node_file[id]].language] then
1554
1553
  return { error = 'Type references currently support explicit C/C++, C#, Java, Kotlin, TypeScript, Go and Rust positions' }
1555
1554
  end
1556
1555
  end