@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
@@ -1,14 +1,14 @@
1
1
  -- Declared type relationships over resident headers, resolved only for this query.
2
2
  local M = { MAX_CANDIDATES = 512, MAX_SCAN_NODES = 1000000, MAX_FILES = 128,
3
3
  MAX_BYTES = 8 * 1024 * 1024, MAX_BASES = 64, MAX_EDGES = 4096 }
4
- local graph = require('codeoutline.graph')
5
- local control = require('codeoutline.control')
4
+ local graph = require('codeoutline.analysis.graph')
5
+ local control = require('codeoutline.shared.control')
6
6
  local kinds = { class = true, interface = true, struct = true, record = true }
7
7
  local languages = { csharp = true, java = true, kotlin = true, typescript = true, cpp = true }
8
8
 
9
9
  function M.validate(query, opts)
10
- local budget = require('codeoutline.explore').validate(query, opts)
11
- assert(require('codeoutline.query_filters').parse(query).text ~= '', 'type hierarchy requires an exact type name in addition to filters')
10
+ local budget = require('codeoutline.query.explore').validate(query, opts)
11
+ assert(require('codeoutline.query.query_filters').parse(query).text ~= '', 'type hierarchy requires an exact type name in addition to filters')
12
12
  opts = opts or {}
13
13
  for _, item in ipairs({ { 'depth', 8, 32 }, { 'max_nodes', 200, 2000 } }) do
14
14
  local value = opts[item[1]]
@@ -37,7 +37,7 @@ local function run(G, idx, query, opts, retry)
37
37
  relationships_incomplete = false, cycle_detected = false,
38
38
  query_stats = { scanned_nodes = 0, candidates = 0, source_files = 0, source_bytes = 0, reverse_unresolved = 0 } }
39
39
  local stats, limited = result.query_stats, {}
40
- local ctx = require('codeoutline.js_resolution').context(G)
40
+ local ctx = require('codeoutline.analysis.js.js_resolution').context(G)
41
41
  ctx.include_paths = opts.include_paths
42
42
  local loaded, summaries, parents, issues = {}, {}, {}, {}
43
43
  local function source(f)
@@ -57,7 +57,7 @@ local function run(G, idx, query, opts, retry)
57
57
  return raw
58
58
  end
59
59
  end
60
- ctx.ordinary = require('codeoutline.ordinary_bindings').context(G, ctx,
60
+ ctx.ordinary = require('codeoutline.analysis.ordinary_bindings').context(G, ctx,
61
61
  (idx or G.root) and function(f)
62
62
  if idx then return source(f) end
63
63
  source(f) -- enforce the same budget for direct graph embeddings
@@ -120,11 +120,11 @@ local function run(G, idx, query, opts, retry)
120
120
  end
121
121
  local ids
122
122
  if language == 'cpp' then
123
- ids = require('codeoutline.cpp_types').resolve(G, f, base.written, {
123
+ ids = require('codeoutline.analysis.cpp.cpp_types').resolve(G, f, base.written, {
124
124
  context = ctx, scope = n.qualified, at = evidence.at, accept = kinds,
125
125
  undecorated = true, definitions = true, aliases = function(g) return data(g).aliases end })
126
126
  else
127
- ids = require('codeoutline.implementations').types(G, f, base.written, ctx, n.qualified, evidence.at)
127
+ ids = require('codeoutline.analysis.implementations').types(G, f, base.written, ctx, n.qualified, evidence.at)
128
128
  end
129
129
  if #ids == 1 and supported(ids[1]) then
130
130
  local parent = ids[1]
@@ -155,10 +155,10 @@ local function run(G, idx, query, opts, retry)
155
155
  return out
156
156
  end
157
157
  local ordered = {}
158
- local filters = require('codeoutline.query_filters').parse(query)
158
+ local filters = require('codeoutline.query.query_filters').parse(query)
159
159
  for i, id in ipairs(G.by_qualified[filters.text] or G.by_name[filters.text] or {}) do
160
160
  if i % 256 == 0 then control.check() end
161
- if supported(id) and not G.nodes[id].decl and require('codeoutline.query_filters').id(filters, G, id) then
161
+ if supported(id) and not G.nodes[id].decl and require('codeoutline.query.query_filters').id(filters, G, id) then
162
162
  if #ordered >= cap then result.node_limit_reached = true; break end
163
163
  ordered[#ordered + 1] = id
164
164
  end
@@ -305,7 +305,7 @@ local function run(G, idx, query, opts, retry)
305
305
  lines[#lines + 1] = string.format('Unresolved: %s -> %s (%s:%d): %s', entry.name,
306
306
  entry.written or '?', entry.file, entry.line, entry.reason)
307
307
  end
308
- local output, cut = require('codeoutline.text').limit(table.concat(lines, '\n'), budget)
308
+ local output, cut = require('codeoutline.shared.text').limit(table.concat(lines, '\n'), budget)
309
309
  result.truncated = cut
310
310
  return output, result
311
311
  end
@@ -1,12 +1,12 @@
1
1
  -- Query explicit type sites without a separate resident type-use graph.
2
- local graph, control = require('codeoutline.graph'), require('codeoutline.control')
2
+ local graph, control = require('codeoutline.analysis.graph'), require('codeoutline.shared.control')
3
3
  local M = { MAX_FILES = 64, MAX_BYTES = 8 * 1024 * 1024, MAX_NAMES = 32, MAX_SITES = 4096,
4
4
  MAX_SCAN_FILES = 20000, MAX_SCAN_BYTES = 256 * 1024 * 1024, TIME_MS = 5000 }
5
5
  M.kinds = { class = true, struct = true, union = true, interface = true, enum = true, record = true, typedef = true, annotation_type = true, trait = true }
6
- local languages = require('codeoutline.type_uses').languages
6
+ local languages = require('codeoutline.analysis.type_uses').languages
7
7
  function M.validate(query, opts)
8
- local budget = require('codeoutline.explore').validate(query, opts)
9
- assert(require('codeoutline.query_filters').parse(query).text ~= '', 'type references require an exact type name')
8
+ local budget = require('codeoutline.query.explore').validate(query, opts)
9
+ assert(require('codeoutline.query.query_filters').parse(query).text ~= '', 'type references require an exact type name')
10
10
  local cap = opts and opts.max_nodes or 200
11
11
  assert(type(cap) == 'number' and cap % 1 == 0 and cap >= 1 and cap <= 2000, 'max_nodes must be an integer between 1 and 2000')
12
12
  return budget
@@ -21,7 +21,7 @@ function M.resolve(G, f, from, site, ctx, details, navigation)
21
21
  local scope = from and from > 0 and G.nodes[from] and G.nodes[from].qualified or ''
22
22
  local ids
23
23
  if language == 'cpp' then
24
- ids = require('codeoutline.cpp_types').resolve(G, f, written, { context = ctx, scope = scope,
24
+ ids = require('codeoutline.analysis.cpp.cpp_types').resolve(G, f, written, { context = ctx, scope = scope,
25
25
  at = site.at, accept = M.kinds, definitions = true, navigation_alias = navigation })
26
26
  elseif language == 'c' then
27
27
  local visible = graph.visible_dependencies(G, f, ctx); ids = {}
@@ -36,26 +36,26 @@ function M.resolve(G, f, from, site, ctx, details, navigation)
36
36
  end
37
37
  end
38
38
  if #own > 0 then ids = own end
39
- elseif language == 'go' then ids = require('codeoutline.go_methods').context(G, ctx).types(f, written)
39
+ elseif language == 'go' then ids = require('codeoutline.analysis.go.go_methods').context(G, ctx).types(f, written)
40
40
  elseif language == 'rust' then
41
- local resolver = require('codeoutline.rust_resolution')
41
+ local resolver = require('codeoutline.analysis.rust.rust_resolution')
42
42
  local entry = resolver.path(G, f, written, ctx, resolver.scope(G, f, from)); ids = entry and entry.ids or {}
43
- if not entry and not require('codeoutline.rust_packages').owner(G, f, ctx) then
43
+ if not entry and not require('codeoutline.analysis.rust.rust_packages').owner(G, f, ctx) then
44
44
  for _, id in ipairs(G.by_name[written] or {}) do
45
45
  if G.node_file[id] == f and G.nodes[id].qualified == written then ids[#ids + 1] = id end
46
46
  end
47
47
  end
48
48
  elseif language == 'typescript' or language == 'arkts' then
49
- ids = require('codeoutline.ts_implementations').types(G, f, written, ctx)
49
+ ids = require('codeoutline.analysis.js.ts_implementations').types(G, f, written, ctx)
50
50
  if #ids == 0 then
51
51
  for _, imp in ipairs(G.files[f].js_imports or {}) do
52
- if imp.local_name == written and imp.imported ~= '*' then ids = require('codeoutline.js_resolution').imported(G, f, imp.path, imp.imported, ctx); break end
52
+ if imp.local_name == written and imp.imported ~= '*' then ids = require('codeoutline.analysis.js.js_resolution').imported(G, f, imp.path, imp.imported, ctx); break end
53
53
  end
54
54
  if #ids == 0 then
55
55
  for _, id in ipairs(G.by_name[written] or {}) do if G.node_file[id] == f and not G.nodes[id].parent then ids[#ids + 1] = id end end
56
56
  end
57
57
  end
58
- else ids = require('codeoutline.implementations').types(G, f, written, ctx, scope, site.at) end
58
+ else ids = require('codeoutline.analysis.implementations').types(G, f, written, ctx, scope, site.at) end
59
59
  local result = {}
60
60
  for _, id in ipairs(ids or {}) do if M.kinds[G.nodes[id].kind] then result[#result + 1] = id end end
61
61
  return result, #result > 1 and 'ambiguous type' or #result == 0 and 'unresolved type' or nil
@@ -87,7 +87,7 @@ function M.query(G, idx, targets, opts)
87
87
  names[name], name_count = true, name_count + 1
88
88
  end
89
89
  if #targets == 0 then return result end
90
- local ctx = require('codeoutline.js_resolution').context(G); ctx.include_paths = opts.include_paths
90
+ local ctx = require('codeoutline.analysis.js.js_resolution').context(G); ctx.include_paths = opts.include_paths
91
91
  local function source(f)
92
92
  if not loaded[f] then
93
93
  if stats.source_files >= (opts.max_files or M.MAX_FILES) then limited('type_reference_file_limit') end
@@ -100,7 +100,7 @@ function M.query(G, idx, targets, opts)
100
100
  return assert(raw, 'cannot read type reference source')
101
101
  end
102
102
  end
103
- ctx.ordinary = require('codeoutline.ordinary_bindings').context(G, ctx,
103
+ ctx.ordinary = require('codeoutline.analysis.ordinary_bindings').context(G, ctx,
104
104
  (idx or G.root) and function(f) return source(f) end or nil, opts.cache and { cache = opts.cache } or nil)
105
105
  stats.ordinary = ctx.ordinary.stats
106
106
  local summaries, summary_bytes = {}, 0
@@ -186,7 +186,7 @@ function M.query(G, idx, targets, opts)
186
186
  if alias and names[tail] then add_name(alias) end
187
187
  for _, hint in ipairs(imp.type_aliases or {}) do if names[hint.name] then add_name(hint.alias) end end
188
188
  if imp.imported == 'default' and alias then
189
- local imported = require('codeoutline.js_resolution').imported(G, f, imp.path, imp.imported, ctx)
189
+ local imported = require('codeoutline.analysis.js.js_resolution').imported(G, f, imp.path, imp.imported, ctx)
190
190
  if matches(imported) then add_name(alias) end
191
191
  end
192
192
  end
@@ -260,11 +260,11 @@ function M.query(G, idx, targets, opts)
260
260
  end
261
261
  local function run(G, idx, query, opts, retry)
262
262
  local budget = M.validate(query, opts)
263
- local filters = require('codeoutline.query_filters').parse(query)
263
+ local filters = require('codeoutline.query.query_filters').parse(query)
264
264
  local ids = {}
265
265
  for number, id in ipairs(G.by_qualified[filters.text] or G.by_name[filters.text] or {}) do
266
266
  if number % 256 == 0 then control.check() end
267
- if M.kinds[G.nodes[id].kind] and languages[G.files[G.node_file[id]].language] and require('codeoutline.query_filters').id(filters, G, id) then
267
+ if M.kinds[G.nodes[id].kind] and languages[G.files[G.node_file[id]].language] and require('codeoutline.query.query_filters').id(filters, G, id) then
268
268
  ids[#ids + 1] = id
269
269
  if #ids > (opts.max_nodes or 200) then break end
270
270
  end
@@ -278,7 +278,7 @@ local function run(G, idx, query, opts, retry)
278
278
  for _, ref in ipairs(result.references) do lines[#lines + 1] = string.format('- %s:%d [%s] %s', ref.file, ref.line, ref.role, ref.written) end
279
279
  if #ids == 0 then lines[#lines + 1] = 'No supported type matched; use an exact type name or qualified name.' end
280
280
  if result.incomplete then lines[#lines + 1] = string.format('Coverage incomplete; %d unresolved and %d ambiguous candidate sites.', result.unresolved_sites, result.ambiguous_sites) end
281
- local output, cut = require('codeoutline.text').limit(table.concat(lines, '\n'), budget, result.node_limit_reached)
281
+ local output, cut = require('codeoutline.shared.text').limit(table.concat(lines, '\n'), budget, result.node_limit_reached)
282
282
  result.truncated = cut; return output, result
283
283
  end
284
284
  function M.run(G, idx, query, opts)
@@ -1,14 +1,14 @@
1
1
  local source = assert(xutils.realpath(debug.getinfo(1, 'S').source:sub(2))):gsub('\\', '/')
2
- local scripts = assert(source:match('^(.*)/codeoutline/[^/]+$'))
2
+ local scripts = assert(source:match('^(.*)/codeoutline/runtime/[^/]+$'))
3
3
  package.path = scripts .. '/?.lua;' .. package.path
4
4
  local service = require('codeoutline.service')
5
- local paths = require('codeoutline.path')
6
- local control = require('codeoutline.control')
7
- local documents = require('codeoutline.documents')
8
- local lsp = require('codeoutline.lsp')
9
- local navigation = require('codeoutline.navigation')
10
- local pool = require('codeoutline.parse_pool')
11
- require('codeoutline.completion') -- registers lsp_completion
5
+ local paths = require('codeoutline.shared.path')
6
+ local control = require('codeoutline.shared.control')
7
+ local documents = require('codeoutline.query.documents')
8
+ local lsp = require('codeoutline.protocol.lsp')
9
+ local navigation = require('codeoutline.query.navigation')
10
+ local pool = require('codeoutline.indexing.parse_pool')
11
+ require('codeoutline.query.completion') -- registers lsp_completion
12
12
  service.configure({ watch = true })
13
13
  local shared = assert(xshared.dict('codeoutline_control'))
14
14
 
@@ -85,7 +85,7 @@ local gc_every = gc_option('CODEOUTLINE_LSP_GC_EVERY', 1, 0)
85
85
  local requests = 0
86
86
  local gc_delay_ms = gc_option('CODEOUTLINE_LSP_GC_DELAY_MS', 1, 0)
87
87
  local gc_step_kb = gc_option('CODEOUTLINE_LSP_GC_STEP_KB', 4096, 1)
88
- local timer_gc = require('codeoutline.idle_gc').new({
88
+ local timer_gc = require('codeoutline.runtime.idle_gc').new({
89
89
  delay_ms = gc_delay_ms,
90
90
  busy = function() return active ~= nil or #queue > 0 end,
91
91
  request = service.request_collection,
@@ -141,7 +141,7 @@ return {
141
141
  assert(xnet.init())
142
142
  xtimer.init()
143
143
  local threads = tonumber(os.getenv('CODEOUTLINE_INDEX_THREADS') or '') or pool.THREADS
144
- pool.configure(scripts .. '/codeoutline/parse_worker.lua', math.max(0, math.floor(threads)))
144
+ pool.configure(scripts .. '/codeoutline/runtime/parse_worker.lua', math.max(0, math.floor(threads)))
145
145
  assert(xthread.post(1, 'worker_ready'))
146
146
  end,
147
147
  -- A suspended job still holds its project: sweeping waits for it. Idle
@@ -1,9 +1,9 @@
1
1
  -- Parse thread for parse_pool.lua: reads and parses the files it is posted
2
2
  -- and posts the results back to the thread that owns the index.
3
3
  local source = assert(xutils.realpath(debug.getinfo(1, 'S').source:sub(2))):gsub('\\', '/')
4
- local scripts = assert(source:match('^(.*)/codeoutline/[^/]+$'))
4
+ local scripts = assert(source:match('^(.*)/codeoutline/runtime/[^/]+$'))
5
5
  package.path = scripts .. '/?.lua;' .. package.path
6
- local index = require('codeoutline.index')
6
+ local index = require('codeoutline.indexing.index')
7
7
  local shared = assert(xshared.dict('codeoutline_control'))
8
8
 
9
9
  return {
@@ -1,7 +1,7 @@
1
1
  -- Background update thread: network, verification and installation stay off the
2
2
  -- service thread. Checks at startup and then hourly while the service runs.
3
3
  local source = assert(xutils.realpath(debug.getinfo(1, 'S').source:sub(2))):gsub('\\', '/')
4
- local scripts = assert(source:match('^(.*)/codeoutline/[^/]+$'))
4
+ local scripts = assert(source:match('^(.*)/codeoutline/runtime/[^/]+$'))
5
5
  package.path = scripts .. '/?.lua;' .. package.path
6
6
  local updater = require('codeoutline.updater')
7
7
  local INTERVAL_MS = 3600000
@@ -1,8 +1,8 @@
1
1
  -- Requests within one Lua state are serialized by the owning transport.
2
- local index = require('codeoutline.index')
3
- local explore = require('codeoutline.explore')
4
- local paths = require('codeoutline.path')
5
- local control = require('codeoutline.control')
2
+ local index = require('codeoutline.indexing.index')
3
+ local explore = require('codeoutline.query.explore')
4
+ local paths = require('codeoutline.shared.path')
5
+ local control = require('codeoutline.shared.control')
6
6
  local M = {}
7
7
  -- Loading uses tighter GC thresholds; queries retain the caller's settings.
8
8
  local startup_gc = os.getenv('CODEOUTLINE_MEMORY_POLICY') ~= 'default'
@@ -187,7 +187,7 @@ local function execute_query(engine, root, query, opts)
187
187
  while true do
188
188
  -- A GBK repair commits the decoded file, which renumbers its nodes.
189
189
  local symbols, source_index, dynamic = idx:symbols(), idx, nil
190
- if engine == explore then symbols, source_index, dynamic = require('codeoutline.on_demand').open(symbols, idx, query) end
190
+ if engine == explore then symbols, source_index, dynamic = require('codeoutline.query.on_demand').open(symbols, idx, query) end
191
191
  local output, details = engine.run(symbols, source_index, query, opts)
192
192
  if dynamic then
193
193
  details.on_demand_files, details.on_demand_rejected, details.on_demand_truncated = dynamic.files, dynamic.rejected, dynamic.truncated
@@ -196,7 +196,7 @@ local function execute_query(engine, root, query, opts)
196
196
  for _, file in ipairs(dynamic.files) do
197
197
  notices[#notices + 1] = string.format('On-demand source: %s (%s, %s); not stored in the index.', file.path, file.language, file.basis)
198
198
  end
199
- output, details.truncated = require('codeoutline.text').limit(table.concat(notices, '\n') .. '\n' .. output,
199
+ output, details.truncated = require('codeoutline.shared.text').limit(table.concat(notices, '\n') .. '\n' .. output,
200
200
  opts and opts.budget or explore.DEFAULT_BUDGET, details.truncated or dynamic.truncated)
201
201
  end
202
202
  end
@@ -211,7 +211,7 @@ local function execute_query(engine, root, query, opts)
211
211
  stats.cache_saved, stats.cache_error = saved, err
212
212
  end
213
213
  result.info.refresh = stats
214
- result.info.coverage = require('codeoutline.coverage').summarize(result.info)
214
+ result.info.coverage = require('codeoutline.query.coverage').summarize(result.info)
215
215
  result.info.resolution = result.info.query_stats and result.info.query_stats.resolution
216
216
  result.info.generation = idx.generation
217
217
  result.info.projectPath = idx.root
@@ -232,19 +232,19 @@ function M.explore(root, query, opts)
232
232
  end
233
233
 
234
234
  function M.callers(root, query, opts)
235
- return run_query(require('codeoutline.callers'), root, query, opts)
235
+ return run_query(require('codeoutline.query.callers'), root, query, opts)
236
236
  end
237
237
 
238
238
  function M.affected(root, files, opts)
239
- return run_query(require('codeoutline.affected'), root, files, opts)
239
+ return run_query(require('codeoutline.query.affected'), root, files, opts)
240
240
  end
241
241
 
242
242
  function M.type_hierarchy(root, query, opts)
243
- return run_query(require('codeoutline.type_hierarchy'), root, query, opts)
243
+ return run_query(require('codeoutline.query.type_hierarchy'), root, query, opts)
244
244
  end
245
245
 
246
246
  function M.type_references(root, query, opts)
247
- return run_query(require('codeoutline.type_references'), root, query, opts)
247
+ return run_query(require('codeoutline.query.type_references'), root, query, opts)
248
248
  end
249
249
 
250
250
  function M.status(root, opts)
@@ -1 +1 @@
1
- return 22
1
+ return 26
@@ -1 +1 @@
1
- return '0.3.3'
1
+ return '0.3.7'
@@ -1,301 +0,0 @@
1
- -- Rust crate/module evidence is produced only for queries, never serialized.
2
- local M = { MAX_DEPTH = 16, MAX_RESULTS = 128, MAX_ALIAS_FILES = 64, MAX_NODES = 8192 }
3
- local cargo, control = require('codeoutline.rust_packages'), require('codeoutline.control')
4
- local function join(a, b) return a == '' and b or b == '' and a or a .. '::' .. b end
5
- local function text(T, i) return i >= 1 and i <= T.n and T:text(i) or '' end
6
-
7
- function M.collect(r, T)
8
- r.rust_imports, r.rust_public, r.has_bindings = {}, {}, true
9
- for n, node in ipairs(r.nodes) do
10
- r.rust_public[n] = text(T, node.ti) == 'pub' and text(T, node.ti + 1) ~= '('
11
- end
12
- for i = 1, T.n do
13
- if text(T, i) == 'use' then
14
- local parent, in_function, last, j = nil, false, i + 1, i + 1
15
- for n, node in ipairs(r.nodes) do
16
- if node.ti <= i and i <= node.tj then
17
- if node.kind == 'namespace' then parent = n
18
- elseif node.kind == 'function' or node.kind == 'method' then in_function = true end
19
- end
20
- end
21
- while j <= T.n and text(T, j) ~= ';' do
22
- if T.m[j] and T.m[j] > j then j = T.m[j] end
23
- j = j + 1
24
- end
25
- last = j - 1
26
- local cursor, count = i + 1, 0
27
- if text(T, cursor) == '::' then cursor = cursor + 1 end
28
- local branch
29
- branch = function(prefix, depth)
30
- if depth > M.MAX_DEPTH then error('Rust use nesting limit reached', 0) end
31
- local path = prefix
32
- while cursor <= last do
33
- local token = text(T, cursor)
34
- if token == '{' then
35
- cursor = cursor + 1
36
- while cursor <= last and text(T, cursor) ~= '}' do
37
- branch(path, depth + 1)
38
- if text(T, cursor) == ',' then cursor = cursor + 1 else break end
39
- end
40
- if text(T, cursor) ~= '}' then error('unsupported Rust use group', 0) end
41
- cursor = cursor + 1; return
42
- end
43
- if token == '' or token == ',' or token == '}' then break end
44
- if token ~= 'self' or path == '' then path = join(path, token) end
45
- cursor = cursor + 1
46
- if text(T, cursor) == '::' then cursor = cursor + 1 else break end
47
- end
48
- local alias = path:match('([^:]+)$')
49
- if text(T, cursor) == 'as' then alias = text(T, cursor + 1); cursor = cursor + 2 end
50
- count = count + 1
51
- if count > M.MAX_RESULTS then error('Rust use binding limit reached', 0) end
52
- if not in_function then r.rust_imports[#r.rust_imports + 1] = { path = path, alias = alias,
53
- parent = parent, public = text(T, i - 1) == 'pub', line = T:line(i) } end
54
- end
55
- branch('', 0)
56
- end
57
- end
58
- for _, ref in ipairs(r.refs) do
59
- local i, path = ref.tok, ref.name
60
- if text(T, i - 1) == '.' then ref.binding = 'rust:member'
61
- else
62
- while text(T, i - 1) == '::' and (T.k[i - 2] == 'id' or T.k[i - 2] == 'kw') do
63
- path, i = text(T, i - 2) .. '::' .. path, i - 2
64
- end
65
- ref.binding = 'rust:path:' .. path
66
- end
67
- end
68
- end
69
-
70
- local function data(G, f, ctx)
71
- local rec = G.files[f]
72
- if rec.rust_imports then return rec end
73
- return ctx.ordinary and cargo.guard(ctx, function() return ctx.ordinary.data(f) end) or rec
74
- end
75
- local function scope_of(G, f, src)
76
- local node = src and G.nodes[src]
77
- local p = node and node.parent
78
- while p do
79
- local owner = G.files[f].nodes[p]
80
- if owner.kind == 'namespace' then return owner.qualified end
81
- p = owner.parent
82
- end
83
- return ''
84
- end
85
- local function parent_scope(G, f, p) return p and G.files[f].nodes[p].qualified or '' end
86
- local function nodes(G, f, ctx)
87
- local list = G.files[f].nodes
88
- if #list > M.MAX_NODES then
89
- ctx.rust_incomplete, ctx.rust_error = true, 'Rust module node limit reached'
90
- return {}
91
- end
92
- return list
93
- end
94
- local function child(G, entry, name, ctx)
95
- local wanted, found = join(entry.scope, name), nil
96
- local rec, detail = G.files[entry.file], data(G, entry.file, ctx)
97
- for n, node in ipairs(nodes(G, entry.file, ctx)) do
98
- if node.kind == 'namespace' and node.qualified == wanted then
99
- if entry.external and not (detail.rust_public or {})[n] then return nil end
100
- local external = false
101
- for _, imp in ipairs(rec.imports) do if imp.kind == 'mod' and imp.path == name then external = true; break end end
102
- if not external then return { file = entry.file, scope = wanted, external = entry.external, root = entry.root } end
103
- local path = rec.path
104
- local directory, stem = cargo.dir(path), path:match('([^/]+)%.rs$')
105
- if not entry.root and stem ~= 'lib' and stem ~= 'main' and stem ~= 'mod' then directory = cargo.join(directory, stem) end
106
- if entry.scope ~= '' then directory = cargo.join(directory, entry.scope:gsub('::', '/')) end
107
- for _, candidate in ipairs({ cargo.join(directory, name .. '.rs'), cargo.join(directory, name .. '/mod.rs') }) do
108
- local id = G.file_index[candidate]
109
- if id then
110
- if found then return nil end
111
- if cargo.owner(G, id, ctx) ~= cargo.owner(G, entry.file, ctx) then return nil end
112
- found = { file = id, scope = '', external = entry.external }
113
- end
114
- end
115
- return found
116
- end
117
- end
118
- end
119
-
120
- local walk
121
- local function terminal(G, entry, name, ctx, seen, depth)
122
- local result, rec, detail = {}, G.files[entry.file], data(G, entry.file, ctx)
123
- local wanted = join(entry.scope, name)
124
- for n, node in ipairs(nodes(G, entry.file, ctx)) do
125
- if node.qualified == wanted and node.kind ~= 'namespace'
126
- and (not entry.external or (detail.rust_public or {})[n]) then
127
- result[#result + 1] = G.id_of[entry.file][n]
128
- end
129
- end
130
- if #result > 0 then return { ids = result } end
131
- for _, imp in ipairs(detail.rust_imports or {}) do
132
- if imp.alias == name and parent_scope(G, entry.file, imp.parent) == entry.scope
133
- and (not entry.external or imp.public) then
134
- local found = walk(G, entry.file, imp.path, ctx, entry.scope, seen, depth + 1)
135
- if entry.external and found and found.ids then
136
- local visible = {}
137
- for _, id in ipairs(found.ids) do
138
- local f = G.node_file[id]
139
- for n, local_id in ipairs(G.id_of[f]) do
140
- if local_id == id and (data(G, f, ctx).rust_public or {})[n] then visible[#visible + 1] = id end
141
- end
142
- end
143
- found.ids = visible
144
- end
145
- return found
146
- end
147
- end
148
- end
149
- walk = function(G, f, path, ctx, scope, seen, depth)
150
- control.check()
151
- if depth > M.MAX_DEPTH then error('Rust module resolution depth limit reached', 0) end
152
- local key = G.files[f].path .. '\0' .. scope .. '\0' .. path
153
- if seen[key] then return nil end
154
- seen[key] = true
155
- local parts = {}; for name in path:gmatch('[^:]+') do parts[#parts + 1] = name end
156
- if #parts == 0 then return nil end
157
- local owner = cargo.owner(G, f, ctx)
158
- if not owner then return nil end
159
- local first, index, entry = parts[1], 2, nil
160
- if first == 'crate' then
161
- local id = cargo.entry(G, owner, ctx, f)
162
- if id then entry = { file = id, scope = '', root = true } end
163
- elseif first == 'self' then entry = { file = f, scope = scope, root = cargo.entry(G, owner, ctx, f) == f }
164
- elseif first == 'super' then
165
- if scope ~= '' then entry = { file = f, scope = scope:match('^(.*)::[^:]+$') or '', root = cargo.entry(G, owner, ctx, f) == f }
166
- else
167
- local root = cargo.entry(G, owner, ctx, f)
168
- if root and root ~= f then
169
- local directory = cargo.dir(G.files[f].path)
170
- if G.files[f].path:match('/mod%.rs$') then directory = cargo.dir(directory) end
171
- local candidates = directory == cargo.dir(G.files[root].path) and { G.files[root].path }
172
- or { directory .. '.rs', cargo.join(directory, 'mod.rs') }
173
- for _, candidate in ipairs(candidates) do
174
- local id = G.file_index[candidate]
175
- if id and cargo.owner(G, id, ctx) == owner then
176
- if entry then return nil end
177
- entry = { file = id, scope = '', root = id == root }
178
- end
179
- end
180
- end
181
- end
182
- else
183
- for _, imp in ipairs(data(G, f, ctx).rust_imports or {}) do
184
- if imp.alias == first and parent_scope(G, f, imp.parent) == scope then
185
- local replacement = imp.path
186
- if #parts > 1 then replacement = replacement .. '::' .. table.concat(parts, '::', 2) end
187
- if replacement ~= path then return walk(G, f, replacement, ctx, scope, seen, depth + 1) end
188
- end
189
- end
190
- local id = cargo.crates(G, f, ctx)[first]
191
- if id then entry = { file = id, scope = '', external = cargo.owner(G, id, ctx) ~= owner, root = true }
192
- else entry, index = { file = f, scope = scope }, 1 end
193
- end
194
- if not entry then return nil end
195
- if first == 'super' and parts[2] == 'super' then
196
- return walk(G, entry.file, table.concat(parts, '::', 2), ctx, entry.scope, seen, depth + 1)
197
- end
198
- while index <= #parts do
199
- local next_entry = child(G, entry, parts[index], ctx)
200
- if next_entry then entry = next_entry
201
- else
202
- local found = terminal(G, entry, parts[index], ctx, seen, depth)
203
- if index == #parts then return found end
204
- if found and found.module then
205
- found.module.external = entry.external; entry = found.module
206
- elseif found and found.ids and index + 1 == #parts then
207
- local ids = {}
208
- for _, type_id in ipairs(found.ids) do
209
- local ty, tf = G.nodes[type_id], G.node_file[type_id]
210
- for _, id in ipairs(G.by_name[parts[index + 1]] or {}) do
211
- local method, mf = G.nodes[id], G.node_file[id]
212
- if mf == tf and method.kind == 'method' and method.qualified == ty.qualified .. '::' .. parts[index + 1] then
213
- for n, local_id in ipairs(G.id_of[mf]) do
214
- if local_id == id and (not entry.external or (data(G, mf, ctx).rust_public or {})[n]) then ids[#ids + 1] = id end
215
- end
216
- end
217
- end
218
- end
219
- return { ids = ids }
220
- else return nil end
221
- end
222
- index = index + 1
223
- end
224
- return { module = entry }
225
- end
226
-
227
- function M.path(G, f, path, ctx, scope)
228
- return cargo.guard(ctx, walk, G, f, path, ctx, scope or '', {}, 0)
229
- end
230
- function M.resolve(G, f, src, name, recv, evidence, ctx)
231
- if not cargo.owner(G, f, ctx) then return ctx.rust_incomplete and {} or nil, ctx.rust_error end
232
- if evidence == 'rust:member' then return nil end
233
- local path = evidence and evidence:match('^rust:path:(.*)$') or (recv and recv .. '::' .. name or name)
234
- local found, reason = M.path(G, f, path, ctx, scope_of(G, f, src))
235
- return found and found.ids or {}, reason or 'Cargo crate/module target is not indexed or visible'
236
- end
237
- function M.imports(G, f, imp, ctx)
238
- if not cargo.owner(G, f, ctx) then return ctx.rust_incomplete and {} or nil end
239
- local result, seen = {}, {}
240
- local function add(id) if id and not seen[id] then seen[id] = true; result[#result + 1] = id end end
241
- if imp.kind == 'mod' then
242
- local entry = child(G, { file = f, scope = '' }, imp.path, ctx)
243
- if entry then add(entry.file) end
244
- else
245
- for _, binding in ipairs(data(G, f, ctx).rust_imports or {}) do
246
- if binding.line == imp.line then
247
- local found = M.path(G, f, binding.path, ctx, parent_scope(G, f, binding.parent))
248
- if found then
249
- if found.module then add(found.module.file) end
250
- for _, id in ipairs(found.ids or {}) do add(G.node_file[id]) end
251
- end
252
- end
253
- end
254
- end
255
- return result
256
- end
257
- function M.members(G, entry, ctx)
258
- return cargo.guard(ctx, function()
259
- local result, names, detail = {}, {}, data(G, entry.file, ctx)
260
- for n, node in ipairs(nodes(G, entry.file, ctx)) do
261
- if node.kind ~= 'impl' and parent_scope(G, entry.file, node.parent) == entry.scope
262
- and (not entry.external or (detail.rust_public or {})[n]) then
263
- names[node.name] = true
264
- result[#result + 1] = { name = node.name, node = node, file = entry.file, kind = node.kind }
265
- end
266
- end
267
- for _, imp in ipairs(detail.rust_imports or {}) do
268
- if imp.public and imp.alias ~= '*' and not names[imp.alias]
269
- and parent_scope(G, entry.file, imp.parent) == entry.scope then
270
- local found = M.path(G, entry.file, imp.path, ctx, entry.scope)
271
- for _, id in ipairs(found and found.ids or {}) do
272
- result[#result + 1] = { name = imp.alias, node = G.nodes[id], file = G.node_file[id], kind = G.nodes[id].kind }
273
- end
274
- end
275
- end
276
- if #result > M.MAX_RESULTS then error('Rust module member limit reached', 0) end
277
- return result
278
- end) or {}
279
- end
280
-
281
- function M.alias_refs(G, f, wanted, ctx)
282
- local rec = G.files[f]
283
- if rec.language ~= 'rust' or #rec.imports == 0 or not cargo.owner(G, f, ctx) then return {} end
284
- local relevant = false
285
- for id in pairs(wanted) do
286
- local target = cargo.owner(G, G.node_file[id], ctx)
287
- if cargo.reaches(G, f, target, ctx) then relevant = true end
288
- end
289
- if not relevant then return {} end
290
- ctx.rust_alias_files = ctx.rust_alias_files or {}
291
- if not ctx.rust_alias_files[f] then
292
- ctx.rust_alias_count = (ctx.rust_alias_count or 0) + 1
293
- if ctx.rust_alias_count > M.MAX_ALIAS_FILES then ctx.rust_incomplete = true; return {} end
294
- ctx.rust_alias_files[f] = true
295
- end
296
- local refs, result = data(G, f, ctx).refs, {}
297
- for i, binding in ipairs(refs.binding or {}) do if binding:match('^rust:path:') then result[i] = true end end
298
- return result
299
- end
300
- M.scope = scope_of
301
- return M