@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.
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} +78 -41
  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} +18 -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} +136 -12
  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 +559 -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} +19 -13
  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} +172 -57
  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
@@ -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,28 +1264,30 @@ 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.
1272
1271
  if #targets == 0 and c and type(c.evidence) == 'string' and c.evidence:match('^lua%-value:') then return {} end
1272
+ local lua_self = c and c.recv == 'self' and V.files[f].language == 'lua'
1273
+ and (c.kind == 'member_call' or c.kind == 'member_symbol')
1273
1274
  local importer = false
1274
- if c and not c.decl then
1275
+ if c and not c.decl and not lua_self then
1275
1276
  -- `require`/`dofile` themselves name the file they load, not a same-named project function.
1276
1277
  for _, imp in ipairs(V.files[f].imports or {}) do
1277
1278
  if imp.line == line and imp.kind == c.name then importer = true end
1278
1279
  end
1279
1280
  end
1280
- if #targets == 0 or importer then
1281
+ if (#targets == 0 and not lua_self) or importer then
1281
1282
  -- An import line: `require "a.b"`, `dofile("x.lua")`, `#include <x.h>`, `from . import m`.
1282
1283
  local files = import_targets(V, f, line)
1283
1284
  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
1285
+ 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
1286
  end
1286
1287
  end
1287
1288
  if #targets == 0 then
1288
1289
  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)
1290
+ local entries, info = require('codeoutline.query.external_headers').find(V, f, c, V.js_context, probe_includes)
1290
1291
  if #entries > 0 then
1291
1292
  local result = {}
1292
1293
  for _, entry in ipairs(entries) do
@@ -1296,7 +1297,8 @@ function handlers.lsp_definition(req)
1296
1297
  return result, info.truncated
1297
1298
  end
1298
1299
  end
1299
- local ids, info = require('codeoutline.definition_candidates').find(V, f, c, V.js_context)
1300
+ local self_fallback = lua_self and c.evidence and c.evidence:match('^lua%-self:%d+$')
1301
+ local ids, info = require('codeoutline.query.definition_candidates').find(V, f, c, V.js_context, self_fallback)
1300
1302
  local result, seen, bytes, started = {}, {}, 0, os.clock()
1301
1303
  local count = 0
1302
1304
  for _, id in ipairs(ids) do
@@ -1311,7 +1313,7 @@ function handlers.lsp_definition(req)
1311
1313
  if hit then result[#result + 1] = { uri = target_doc.uri, range = target_doc:range(hit.name_start, hit.name_end) } end
1312
1314
  end
1313
1315
  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
1316
+ 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
1317
  end
1316
1318
  if c.decl and is_decl(V.nodes[targets[1]]) then
1317
1319
  -- From a declaration, go to its definitions.
@@ -1323,7 +1325,7 @@ function handlers.lsp_definition(req)
1323
1325
  end
1324
1326
  local result = {}
1325
1327
  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
1328
+ 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
1329
  end
1328
1330
 
1329
1331
  -- Display tags may be truncated before a heavily annotated SDK declaration's
@@ -1341,6 +1343,115 @@ local function external_signature(entry)
1341
1343
  return label
1342
1344
  end
1343
1345
 
1346
+ -- Read adjacent comments from the validated definition source or its draft.
1347
+ local function leading_comments(doc, hit, language)
1348
+ local line = doc:position(hit.start_byte).line + 1
1349
+ local prefix = doc.source:sub(doc.lines[line] + 1, hit.start_byte)
1350
+ local c_style = language ~= 'lua' and language ~= 'python'
1351
+ local marker = c_style and '//[/!]?' or language == 'lua' and '%-%-%-?' or '#'
1352
+ local comments = {}
1353
+ local in_block = false
1354
+ if prefix:find('%S') then
1355
+ local inline = c_style and prefix:match('^%s*/%*%*?(.-)%*/%s*$')
1356
+ if not inline or inline:find('*/', 1, true) or (language == 'rust' and prefix:match('^%s*/%*!')) then return comments end
1357
+ comments[1] = inline:match('^%s*(.-)%s*$')
1358
+ end
1359
+ for i = line - 1, math.max(1, line - 40), -1 do
1360
+ if doc.lines[line] - doc.lines[i] > 8192 then break end
1361
+ local text = doc.source:sub(doc.lines[i] + 1, doc.lines[i + 1]):match('^%s*(.-)%s*$')
1362
+ if (language == 'rust' and (text:match('^//!') or text:match('^/%*!')))
1363
+ or (language == 'python' and text:match('^#!')) then break end
1364
+ local comment = not in_block and text:match('^' .. marker .. '[ \t]*(.*)$')
1365
+ if comment then
1366
+ if language == 'lua' and (comment:match('^%[=*%[') or comment:match('^%]=*%]')) then break end
1367
+ comments[#comments + 1] = comment
1368
+ elseif c_style and (in_block or text:sub(-2) == '*/') then
1369
+ if not in_block then
1370
+ text = text:sub(1, -3)
1371
+ in_block = #comments + 1
1372
+ end
1373
+ if text:find('*/', 1, true) then break end
1374
+ local opening = text:match('^/%*[%*!]?(.*)$')
1375
+ comment = (opening or text:gsub('^%*', '')):match('^%s*(.-)%s*$')
1376
+ if comment ~= '' or not opening then comments[#comments + 1] = comment end
1377
+ if opening then in_block = false end
1378
+ else
1379
+ break
1380
+ end
1381
+ end
1382
+ if in_block then for i = #comments, in_block, -1 do comments[i] = nil end end
1383
+ return comments
1384
+ end
1385
+
1386
+ local function python_docstring(V, f, hit)
1387
+ local _, T = M.full(V, f)
1388
+ if not T then return nil end
1389
+ local lo, hi = 1, T.n
1390
+ while lo < hi do
1391
+ local mid = math.floor((lo + hi) / 2)
1392
+ if T.s[mid] <= hit.name_start then lo = mid + 1 else hi = mid end
1393
+ end
1394
+ if T.s[lo] ~= hit.name_start + 1 then return nil end
1395
+ local i = lo + 1
1396
+ while T.s[i] and T.s[i] - 1 < math.min(hit.end_byte, hit.name_start + 8192) and T.k[i] ~= 'nl' do
1397
+ if T:text(i) == ':' then break end
1398
+ i = (T.m[i] and T.m[i] > i) and T.m[i] + 1 or i + 1
1399
+ end
1400
+ if T:text(i) ~= ':' then return nil end
1401
+ i = i + 1
1402
+ while T.k[i] == 'nl' or T.k[i] == 'indent' do i = i + 1 end
1403
+ if T.k[i] ~= 'str' or T.e[i] > hit.end_byte or T.e[i] - T.s[i] > 8192
1404
+ or (T.k[i + 1] and T.k[i + 1] ~= 'nl' and T.k[i + 1] ~= 'dedent' and T:text(i + 1) ~= ';') then return nil end
1405
+ local literal = T:text(i):gsub('^[rRuU]', '')
1406
+ local quote = literal:match('^"""') or literal:match("^'''") or literal:match('^["\']')
1407
+ if not quote or #literal < 2 * #quote or literal:sub(-#quote) ~= quote then return nil end
1408
+ local value = literal:sub(#quote + 1, -#quote - 1):gsub('\r\n?', '\n')
1409
+ local margin
1410
+ for indent in value:gmatch('\n([ \t]*)%S') do margin = math.min(margin or #indent, #indent) end
1411
+ if margin and margin > 0 then value = value:gsub('\n[ \t]+', function(indent) return '\n' .. indent:sub(margin + 2) end) end
1412
+ return value:match('^%s*(.-)%s*$')
1413
+ end
1414
+
1415
+ local function definition_documentation(V, id)
1416
+ local node, f = V.nodes[id], V.node_file[id]
1417
+ local record = V.files[f]
1418
+ if not REFERENCE[node.kind] or (not V.drafts[f] and (record.size or 0) > M.MAX_FILE_BYTES) then return nil end
1419
+ local doc, hit = locate(V, id)
1420
+ if not hit then return nil end
1421
+ local language = record.language
1422
+ if language == 'python' then
1423
+ local value = python_docstring(V, f, hit)
1424
+ if value and value ~= '' then return { kind = 'markdown', value = value } end
1425
+ end
1426
+ local comments = leading_comments(doc, hit, language)
1427
+ local prose, annotations = {}, {}
1428
+ for i = #comments, 1, -1 do
1429
+ local comment = comments[i]
1430
+ if comment:match('^[@\\]%a+[%s:]') then
1431
+ annotations[#annotations + 1] = language == 'lua' and '---' .. comment or comment
1432
+ else
1433
+ prose[#prose + 1] = comment
1434
+ end
1435
+ end
1436
+ local value = table.concat(prose, ' \n'):match('^%s*(.-)%s*$')
1437
+ if language == 'csharp' then
1438
+ value = value:gsub('<param%s+name="([%w_]+)">', '**Parameter `%1`** ')
1439
+ :gsub('<typeparam%s+name="([%w_]+)">', '**Type parameter `%1`** ')
1440
+ :gsub('<paramref%s+name="([%w_]+)"%s*/>', '`%1`')
1441
+ :gsub('<see%s+cref="([^"\r\n]+)"%s*/>', '`%1`')
1442
+ :gsub('<returns>', '**Returns** '):gsub('<value>', '**Value** ')
1443
+ for _, tag in ipairs({ 'summary', 'remarks', 'param', 'typeparam', 'returns', 'value' }) do
1444
+ value = value:gsub('</?' .. tag .. '>', '')
1445
+ end
1446
+ value = value:match('^%s*(.-)%s*$')
1447
+ end
1448
+ if #annotations > 0 then
1449
+ local fence = language == 'lua' and '```lua\n' or '```text\n'
1450
+ value = value .. (value ~= '' and '\n\n' or '') .. fence .. table.concat(annotations, '\n') .. '\n```'
1451
+ end
1452
+ if value ~= '' then return { kind = 'markdown', value = value } end
1453
+ end
1454
+
1344
1455
  -- Follow unmatched delimiters up to the cursor. Commas in nested calls,
1345
1456
  -- literals and indexing expressions do not advance the enclosing argument.
1346
1457
  function handlers.lsp_signature(req)
@@ -1402,9 +1513,10 @@ function handlers.lsp_signature(req)
1402
1513
  local V, _, c, targets, f = at(query)
1403
1514
  if not V or not c or c.decl then return false end
1404
1515
  local signatures, seen = {}, {}
1405
- local function add_signature(node, label, uri, foreign)
1516
+ local function add_signature(node, label, uri, foreign, id)
1406
1517
  if foreign and not seen[foreign.label] then
1407
1518
  foreign.activeParameter = #foreign.parameters > 0 and math.min(call.argument, #foreign.parameters - 1) or nil
1519
+ foreign.documentation = id and definition_documentation(V, id) or foreign.documentation
1408
1520
  signatures[#signatures + 1] = foreign
1409
1521
  seen[foreign.label] = true
1410
1522
  elseif not foreign and REFERENCE[node.kind] and label and not seen[label] then
@@ -1431,6 +1543,7 @@ function handlers.lsp_signature(req)
1431
1543
  i = i + 1
1432
1544
  end
1433
1545
  signatures[#signatures + 1] = { label = label, parameters = parameters,
1546
+ documentation = id and definition_documentation(V, id),
1434
1547
  activeParameter = #parameters > 0 and math.min(call.argument, #parameters - 1) or nil }
1435
1548
  seen[label] = true
1436
1549
  end
@@ -1439,12 +1552,12 @@ function handlers.lsp_signature(req)
1439
1552
  for _, id in ipairs(targets) do
1440
1553
  local node = V.nodes[id]
1441
1554
  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)))
1555
+ require('codeoutline.analysis.foreign').signature(node, language, T:text(name_token)), id)
1443
1556
  end
1444
1557
  if #targets == 0 and C_FAMILY[doc:parse().language] then
1445
1558
  -- Share definition lookup's bounded, source-validated external-header
1446
1559
  -- cache. SDK declarations stay query-local and never enter the index.
1447
- local entries = require('codeoutline.external_headers').find(V, f,
1560
+ local entries = require('codeoutline.query.external_headers').find(V, f,
1448
1561
  c, V.js_context, probe_includes)
1449
1562
  for _, entry in ipairs(entries) do
1450
1563
  add_signature(entry.node, external_signature(entry), documents.uri(entry.file))
@@ -1461,9 +1574,11 @@ function handlers.lsp_hover(req)
1461
1574
  for k, id in ipairs(targets) do
1462
1575
  if k > M.MAX_HOVER then break end
1463
1576
  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))
1577
+ local foreign = require('codeoutline.analysis.foreign').signature(node, doc:parse().language, doc.source:sub(c.first + 1, c.last))
1465
1578
  parts[#parts + 1] = '```' .. (foreign and doc:parse().language or rec.language or '') .. '\n'
1466
1579
  .. (foreign and foreign.label or M.detail(V, V.node_file[id], node).sig or node.qualified) .. '\n```'
1580
+ local documentation = definition_documentation(V, id)
1581
+ if documentation then parts[#parts + 1] = documentation.value end
1467
1582
  parts[#parts + 1] = node.kind .. ' `' .. node.qualified .. '` — ' .. rec.path .. ':' .. node.line
1468
1583
  end
1469
1584
  return { contents = { kind = 'markdown', value = table.concat(parts, '\n\n') }, range = doc:range(c.first, c.last) }
@@ -1537,20 +1652,20 @@ function handlers.lsp_outgoing(req)
1537
1652
  end
1538
1653
  end
1539
1654
  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
1655
+ 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
1656
  end
1542
1657
 
1543
1658
  function handlers.lsp_references(req)
1544
1659
  local V, _, c, targets = at(req)
1545
1660
  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
1661
+ 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
1662
  local set = {}
1548
1663
  local type_ids = {}
1549
1664
  for _, id in ipairs(targets) do if TYPES[V.nodes[id].kind] then type_ids[#type_ids + 1] = id end end
1550
1665
  if #type_ids > 0 then
1551
- local engine = require('codeoutline.type_references')
1666
+ local engine = require('codeoutline.query.type_references')
1552
1667
  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
1668
+ 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
1669
  return { error = 'Type references currently support explicit C/C++, C#, Java, Kotlin, TypeScript, Go and Rust positions' }
1555
1670
  end
1556
1671
  end
@@ -1,10 +1,10 @@
1
1
  -- Explicit unknown-suffix files live in a bounded query overlay, never in idx.
2
2
  local M = { MAX_FILES = 4, MAX_BYTES = 2 * 1048576, MAX_PROBES = 16 }
3
- local graph = require('codeoutline.graph')
4
- local parse = require('codeoutline.parse')
5
- local documents = require('codeoutline.documents')
6
- local paths = require('codeoutline.path')
7
- local control = require('codeoutline.control')
3
+ local graph = require('codeoutline.analysis.graph')
4
+ local parse = require('codeoutline.parsing.parse')
5
+ local documents = require('codeoutline.query.documents')
6
+ local paths = require('codeoutline.shared.path')
7
+ local control = require('codeoutline.shared.control')
8
8
 
9
9
  local function fork(G)
10
10
  local V = setmetatable({}, { __index = G })
@@ -57,7 +57,7 @@ function M.open(G, idx, query)
57
57
  result.truncated = true
58
58
  else
59
59
  local doc = documents.read(real)
60
- local filters = require('codeoutline.query_filters').parse(query)
60
+ local filters = require('codeoutline.query.query_filters').parse(query)
61
61
  local hint = #filters.languages == 1 and filters.languages[1] or nil
62
62
  local rec = doc and parse.parse(rel, doc.source, { detect = true, language = hint, ordinary_bindings = true })
63
63
  if rec then
@@ -10,7 +10,7 @@ end
10
10
  local function renderer(G, initial)
11
11
  local lines, references, size = {}, {}, 0
12
12
  local function append(line, ids, registration)
13
- line = require('codeoutline.text').valid(line)
13
+ line = require('codeoutline.shared.text').valid(line)
14
14
  local files, seen = {}, {}
15
15
  local function add(f) if f and not seen[f] then seen[f] = true; files[#files + 1] = f end end
16
16
  for _, id in ipairs(ids or {}) do add(G.node_file[id]) end
@@ -27,7 +27,7 @@ function M.new(limit)
27
27
  local seen = {}
28
28
  function report:add(entry)
29
29
  local key = table.concat({ entry.source or '', entry.target or '', entry.line or '',
30
- entry.kind or '', entry.reason or '', entry.rule or '', entry.call or '' }, ':')
30
+ entry.kind or '', entry.reason or '', entry.rule or '', entry.call or '', entry.candidate or '' }, ':')
31
31
  if seen[key] then return end
32
32
  if #self.entries >= (limit or 64) then self.truncated = true; return end
33
33
  seen[key] = true
@@ -82,7 +82,7 @@ function M.path_breakpoints(report, G, searches, connected)
82
82
  table.sort(candidates, function(a, b)
83
83
  if a.priority ~= b.priority then return a.priority > b.priority end
84
84
  if #a.path ~= #b.path then return #a.path > #b.path end
85
- if a.from ~= b.from then return require('codeoutline.graph').before(G, a.from, b.from) end
85
+ if a.from ~= b.from then return require('codeoutline.analysis.graph').before(G, a.from, b.from) end
86
86
  if (a.line or 0) ~= (b.line or 0) then return (a.line or 0) < (b.line or 0) end
87
87
  return (a.call or '') < (b.call or '')
88
88
  end)
@@ -105,7 +105,7 @@ end
105
105
 
106
106
  function M.render_breakpoints(report, G)
107
107
  if #report.entries == 0 then return nil end
108
- local graph = require('codeoutline.graph')
108
+ local graph = require('codeoutline.analysis.graph')
109
109
  local function label(id) return G.nodes[id].qualified .. ' (' .. graph.where(G, id) .. ')' end
110
110
  local special = false
111
111
  for _, entry in ipairs(report.entries) do
@@ -153,8 +153,12 @@ function M.render(report, G)
153
153
  if e.call then detail = detail .. ' via ' .. e.call end
154
154
  if e.rule then detail = detail .. ' (rule #' .. e.rule .. ', argument ' .. e.argument .. ')' end
155
155
  if e.registered_at then detail = detail .. '; registered at ' .. e.registered_at end
156
+ if e.candidate then
157
+ detail = detail .. '; unconfirmed dispatch candidate: ' .. G.nodes[e.candidate].qualified
158
+ .. ' (' .. require('codeoutline.analysis.graph').where(G, e.candidate) .. '); not a call edge'
159
+ end
156
160
  append(string.format('- %s:%d %s%s: %s', path, e.line or 0,
157
- source and source.qualified or '?', target and ' -> ' .. target or '', detail), { e.source, e.target }, e.registered_at)
161
+ source and source.qualified or '?', target and ' -> ' .. target or '', detail), { e.source, e.target or e.candidate }, e.registered_at)
158
162
  end
159
163
  if report.truncated then append('Evidence limit reached; additional explanations omitted.') end
160
164
  return finish()
@@ -1,6 +1,6 @@
1
1
  -- Per-query search policy. Directory penalties never change graph visibility.
2
- local rules = require('codeoutline.rules')
3
- local text = require('codeoutline.text')
2
+ local rules = require('codeoutline.shared.rules')
3
+ local text = require('codeoutline.shared.text')
4
4
  local M = { MAX_DIRECTORIES = 32, MAX_PATH_BYTES = 1024, PENALTY = 6 }
5
5
  local defaults = { '/3rd/', '^3rd/', '/third_party/', '^third_party/', '/thirdparty/',
6
6
  '/vendor/', '^vendor/', '/node_modules/', '/external/', '^external/', '/deps/', '^deps/' }
@@ -42,10 +42,9 @@ function M.policy(root)
42
42
  local cache = {}
43
43
  local P = { configured = configured, stats = { configured = configured,
44
44
  rules = configured and #prefixes or #defaults, checked_files = 0, matched_files = 0 } }
45
- function P.penalty(path, explicit)
46
- -- Keep legacy scores unchanged without configuration. A configured
47
- -- directory never penalizes an explicitly qualified symbol request.
48
- if configured and explicit then return 0 end
45
+ function P.penalty(path, explicit, node)
46
+ -- Exact qualified requests bypass both configured and default hints.
47
+ if explicit then return 0 end
49
48
  local amount = cache[path]
50
49
  if amount == nil then
51
50
  amount = 0
@@ -57,12 +56,16 @@ function M.policy(root)
57
56
  for _, pattern in ipairs(defaults) do
58
57
  if path:find(pattern) then amount = M.PENALTY; break end
59
58
  end
59
+ local lower = '/' .. path:lower()
60
+ if lower:match('%.min%.[cm]?js$') or lower:match('%.bundle%.js$') then amount = math.max(amount, 18) end
61
+ if lower:find('/builtins/', 1, true) or lower:find('/typings/', 1, true)
62
+ or lower:match('%.d%.[cm]?ts$') then amount = math.max(amount, 10) end
60
63
  end
61
64
  cache[path] = amount
62
65
  P.stats.checked_files = P.stats.checked_files + 1
63
66
  if amount > 0 then P.stats.matched_files = P.stats.matched_files + 1 end
64
67
  end
65
- return amount
68
+ return amount + (not configured and node and (node.decl or node.kind == 'prototype') and 4 or 0)
66
69
  end
67
70
  return P
68
71
  end