@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
@@ -15,7 +15,7 @@ local function code(source)
15
15
  i, first = last + 1, last + 1
16
16
  end
17
17
  while i <= #source do
18
- if i % 4096 == 0 then require('codeoutline.control').check() end
18
+ if i % 4096 == 0 then require('codeoutline.shared.control').check() end
19
19
  local pair, c = source:sub(i, i + 1), source:sub(i, i)
20
20
  local lua_comment = pair == '--' and source:match('^%-%-(%[=*%[)', i)
21
21
  if lua_comment then
@@ -1,6 +1,6 @@
1
- -- codeoutline/parse.lua — per-file symbol extraction for the code index
1
+ -- codeoutline/parsing/parse.lua — per-file symbol extraction for the code index
2
2
  -- behind the CodeExplore tool.
3
- -- local parse = require('codeoutline.parse')
3
+ -- local parse = require('codeoutline.parsing.parse')
4
4
  -- local result = parse.parse(path, source) -- nil for unsupported files
5
5
  --
6
6
  -- Tokenizing lives in xscan.lua (the runtime's native `xscan` module when
@@ -43,13 +43,13 @@ function M.parse_tokens(path, src, opts)
43
43
  local lang = M.language(path)
44
44
  local inferred, cpp_syntax
45
45
  if not lang and opts and (opts.language or opts.detect) then
46
- lang, inferred = require('codeoutline.language_detect').resolve(src, opts.language, opts.detect)
46
+ lang, inferred = require('codeoutline.parsing.language_detect').resolve(src, opts.language, opts.detect)
47
47
  end
48
48
  if not lang then return nil end
49
49
  if opts and opts.cpp_fragment then
50
50
  assert(not M.language(path) and (opts.cpp_fragment == 'c' or opts.cpp_fragment == 'cpp'))
51
51
  if src:find('\0', 1, true) then return nil end
52
- local detected = require('codeoutline.language_detect').resolve(src, nil, true)
52
+ local detected = require('codeoutline.parsing.language_detect').resolve(src, nil, true)
53
53
  if detected and detected ~= 'c' and detected ~= 'cpp' then return nil end
54
54
  cpp_syntax = not not parser('cpp').looks_cpp(src)
55
55
  if lang == 'c' and cpp_syntax then lang = 'cpp' end
@@ -1,4 +1,4 @@
1
- local mcp = require('codeoutline.mcp')
1
+ local mcp = require('codeoutline.protocol.mcp')
2
2
  local M = {}
3
3
  local MAX_BODY, MAX_HEADER = 1048576, 16384
4
4
 
@@ -1,6 +1,6 @@
1
- local documents = require('codeoutline.documents')
2
- local paths = require('codeoutline.path')
3
- local text = require('codeoutline.text')
1
+ local documents = require('codeoutline.query.documents')
2
+ local paths = require('codeoutline.shared.path')
3
+ local text = require('codeoutline.shared.text')
4
4
  local M = { MAX_HEADER = 16384, MAX_MESSAGE = 4194304, MAX_ROOTS = 16,
5
5
  MAX_DOCUMENTS = 128, MAX_DRAFT_BYTES = 33554432, MAX_PENDING = 64,
6
6
  MAX_QUERY = 4096, MAX_SYMBOLS = 200, POLL_MS = 1000, WARM_DELAY_MS = 150,
@@ -96,7 +96,7 @@ function M.new(config, emit, submit, cancel, stop, await_worker)
96
96
  local self = { state = 'new', documents = {}, roots = {}, pending = {}, scans = {}, ready = {},
97
97
  document_bytes = 0, document_count = 0, session = config.session or ('lsp-' .. sessions),
98
98
  synced = {}, features = {} }
99
- local trace = require('codeoutline.lsp_trace').open(os.getenv('CODEOUTLINE_LSP_TRACE'), self.session)
99
+ local trace = require('codeoutline.protocol.lsp_trace').open(os.getenv('CODEOUTLINE_LSP_TRACE'), self.session)
100
100
  if trace then
101
101
  local transport_emit = emit
102
102
  emit = function(msg) trace:message('send', msg); transport_emit(msg) end
@@ -1,12 +1,12 @@
1
- local paths = require('codeoutline.path')
2
- local explore = require('codeoutline.explore')
3
- local callers = require('codeoutline.callers')
4
- local affected = require('codeoutline.affected')
5
- local type_hierarchy = require('codeoutline.type_hierarchy')
6
- local type_references = require('codeoutline.type_references')
7
- local text = require('codeoutline.text')
1
+ local paths = require('codeoutline.shared.path')
2
+ local explore = require('codeoutline.query.explore')
3
+ local callers = require('codeoutline.query.callers')
4
+ local affected = require('codeoutline.query.affected')
5
+ local type_hierarchy = require('codeoutline.query.type_hierarchy')
6
+ local type_references = require('codeoutline.query.type_references')
7
+ local text = require('codeoutline.shared.text')
8
8
  local version = require('codeoutline.version')
9
- local coverage = require('codeoutline.coverage')
9
+ local coverage = require('codeoutline.query.coverage')
10
10
  local M = { VERSION = '2025-06-18' }
11
11
  local null = xutils.json_null
12
12
  local function array(t) return setmetatable(t or {}, xutils.json_array_mt) end
@@ -42,7 +42,7 @@ M.tools = array({
42
42
  max_nodes = { type = 'integer', minimum = 1, maximum = 2000, default = 200 },
43
43
  budget = { type = 'integer', minimum = 256, maximum = 262144, default = 16000 } },
44
44
  required = array({ 'query' }), additionalProperties = false } },
45
- { name = 'codeoutline_explore', description = 'Query symbols, line-numbered source, call paths and neighbors. Explicit unknown-suffix project file paths are parsed on demand using supported syntax or a lang: hint. Unresolved calls may include explicitly unconfirmed definition candidates; these are not call edges and require source inspection. Optional lang:/kind:/path:/name: filters select starting symbols only; dependencies may cross languages and files. Refreshes automatically.',
45
+ { name = 'codeoutline_explore', description = 'Query symbols, line-numbered source, call paths and neighbors. Explicit unknown-suffix project file paths are parsed on demand using supported syntax or a lang: hint. Unresolved calls and string commands may include explicitly unconfirmed candidates; these are not call edges and require source inspection. Long bodies preserve relevant call-site windows within the output budget. Optional lang:/kind:/path:/name: filters select starting symbols only; dependencies may cross languages and files. Refreshes automatically.',
46
46
  inputSchema = { type = 'object', properties = { projectPath = project,
47
47
  query = { type = 'string', minLength = 1, maxLength = 4096 },
48
48
  budget = { type = 'integer', minimum = 256, maximum = 262144, default = 16000 } },
@@ -1,8 +1,8 @@
1
1
  -- File changes seed one shared reverse traversal; no persistent impact graph.
2
- local paths = require('codeoutline.path')
3
- local control = require('codeoutline.control')
4
- local callers = require('codeoutline.callers')
5
- local text = require('codeoutline.text')
2
+ local paths = require('codeoutline.shared.path')
3
+ local control = require('codeoutline.shared.control')
4
+ local callers = require('codeoutline.query.callers')
5
+ local text = require('codeoutline.shared.text')
6
6
  local M = { MAX_FILES = 128, TIME_LIMIT_MS = 700 }
7
7
 
8
8
  local function checked(path)
@@ -125,7 +125,7 @@ function M.run(symbols, idx, files, opts)
125
125
  if result.depth_limit_reached then lines[#lines + 1] = 'Depth limit reached; deeper relationships were not checked.' end
126
126
  if result.time_limit_reached then lines[#lines + 1] = 'Time limit reached; verified paths from the scanned portion are returned.' end
127
127
  if result.relationships_incomplete then lines[#lines + 1] = 'Relationships incomplete: '
128
- .. table.concat(require('codeoutline.coverage').relations(result), ', ') .. '.' end
128
+ .. table.concat(require('codeoutline.query.coverage').relations(result), ', ') .. '.' end
129
129
  for _, entry in ipairs(result.callers) do
130
130
  local chain = {}
131
131
  for _, hop in ipairs(entry.path) do
@@ -136,7 +136,7 @@ function M.run(symbols, idx, files, opts)
136
136
  end
137
137
  lines[#lines + 1] = 'Affected files:\n' .. table.concat(result.files, '\n')
138
138
  lines[#lines + 1] = 'Test candidates (naming heuristic):\n' .. (#tests > 0 and table.concat(tests, '\n') or '(none identified)')
139
- local output, cut = text.limit(table.concat(lines, '\n'), require('codeoutline.explore').validate('affected', opts),
139
+ local output, cut = text.limit(table.concat(lines, '\n'), require('codeoutline.query.explore').validate('affected', opts),
140
140
  limited or result.node_limit_reached)
141
141
  result.truncated = cut
142
142
  return output, result
@@ -1,12 +1,12 @@
1
1
  -- Reverse BFS over query-owned relationships. No persistent impact graph.
2
- local graph = require('codeoutline.graph')
3
- local control = require('codeoutline.control')
4
- local text = require('codeoutline.text')
2
+ local graph = require('codeoutline.analysis.graph')
3
+ local control = require('codeoutline.shared.control')
4
+ local text = require('codeoutline.shared.text')
5
5
  local M = {}
6
6
 
7
7
  function M.validate(query, opts)
8
- require('codeoutline.explore').validate(query, opts)
9
- assert(require('codeoutline.query_filters').parse(query).text ~= '', 'callers requires an exact symbol name in addition to filters')
8
+ require('codeoutline.query.explore').validate(query, opts)
9
+ assert(require('codeoutline.query.query_filters').parse(query).text ~= '', 'callers requires an exact symbol name in addition to filters')
10
10
  opts = opts or {}
11
11
  for _, item in ipairs({ { 'depth', 3, 8 }, { 'max_nodes', 200, 2000 } }) do
12
12
  local value = opts[item[1]]
@@ -116,17 +116,17 @@ end
116
116
  function M.run(symbols, idx, query, opts)
117
117
  M.validate(query, opts)
118
118
  opts = opts or {}
119
- local filters = require('codeoutline.query_filters').parse(query)
119
+ local filters = require('codeoutline.query.query_filters').parse(query)
120
120
  local candidates = symbols.by_qualified[filters.text] or symbols.by_name[filters.text] or {}
121
121
  local ordered = {}
122
122
  for _, id in ipairs(candidates) do
123
- if require('codeoutline.query_filters').id(filters, symbols, id) then ordered[#ordered + 1] = id end
123
+ if require('codeoutline.query.query_filters').id(filters, symbols, id) then ordered[#ordered + 1] = id end
124
124
  end
125
125
  table.sort(ordered, function(a, b) return graph.before(symbols, a, b) end)
126
126
  local result = M.from_targets(symbols, idx, ordered, opts)
127
127
  if result.encoding_retry then return nil, result end
128
128
  local depth = opts.depth or 3
129
- local budget = require('codeoutline.explore').validate(query, opts)
129
+ local budget = require('codeoutline.query.explore').validate(query, opts)
130
130
  local lines = { string.format('Matched %d target(s); %d potential callers in %d files, searched up to %d levels.',
131
131
  #result.targets, #result.callers, #result.files, depth),
132
132
  'Static potential impact; each caller has one shortest path. This is not proof of runtime execution or complete impact coverage.' }
@@ -135,7 +135,7 @@ function M.run(symbols, idx, query, opts)
135
135
  if result.node_limit_reached then lines[#lines + 1] = 'Node limit reached; targets or callers were omitted.' end
136
136
  if result.depth_limit_reached then lines[#lines + 1] = 'Depth limit reached; callers beyond this depth were not checked.' end
137
137
  if result.relationships_incomplete then lines[#lines + 1] = 'Relationships incomplete: '
138
- .. table.concat(require('codeoutline.coverage').relations(result), ', ') .. '.' end
138
+ .. table.concat(require('codeoutline.query.coverage').relations(result), ', ') .. '.' end
139
139
  for _, target in ipairs(result.targets) do
140
140
  lines[#lines + 1] = string.format('Target: %s (%s:%d)', target.name, target.file, target.line)
141
141
  end
@@ -11,9 +11,9 @@
11
11
  -- are generated; the editor retains responsibility for ranking. Type
12
12
  -- files are reparsed on demand within a time budget; running out of it, or
13
13
  -- of items, marks the list incomplete.
14
- local graph = require('codeoutline.graph')
15
- local navigation = require('codeoutline.navigation')
16
- local control = require('codeoutline.control')
14
+ local graph = require('codeoutline.analysis.graph')
15
+ local navigation = require('codeoutline.query.navigation')
16
+ local control = require('codeoutline.shared.control')
17
17
  local M = { MAX_ITEMS = 500, AUTO_MAX_ITEMS = 100, MIN_GLOBAL_PREFIX = 2,
18
18
  BUDGET_SECONDS = 0.3, MAX_DEPTH = 6 }
19
19
 
@@ -58,7 +58,7 @@ end
58
58
  local function normalize(text, language)
59
59
  if type(text) ~= 'string' then return nil end
60
60
  if language == 'cpp' then
61
- local named = require('codeoutline.cpp_types').normalize(text)
61
+ local named = require('codeoutline.analysis.cpp.cpp_types').normalize(text)
62
62
  if named then return named end
63
63
  end
64
64
  text = text:gsub('^%s+', ''):gsub('%s+$', '')
@@ -67,7 +67,7 @@ local function normalize(text, language)
67
67
  if first and MODIFIERS[first] then text = rest else break end
68
68
  end
69
69
  if language == 'csharp' then
70
- local named = require('codeoutline.csharp_bindings').name(text)
70
+ local named = require('codeoutline.analysis.csharp.csharp_bindings').name(text)
71
71
  if named then return named end
72
72
  end
73
73
  text = text:gsub('^[%*&%[%]]+', ''):gsub('[%*&%?!%s]+$', ''):gsub('%[%]$', '')
@@ -453,18 +453,18 @@ Completion.__index = Completion
453
453
  function Completion:types(name, f, scope, at)
454
454
  if not name then return {} end
455
455
  f = f or self.f
456
- if self.V.files[f].language == 'go' then return require('codeoutline.go_methods').context(self.V, self.V.js_context).types(f, name) end
456
+ if self.V.files[f].language == 'go' then return require('codeoutline.analysis.go.go_methods').context(self.V, self.V.js_context).types(f, name) end
457
457
  local accept = self.language == 'lua' and LUA_TYPES or TYPES
458
458
  local direct, paired = navigation.deps(self.V, f)
459
459
  if self.V.files[f].language == 'csharp' then
460
- local ids = require('codeoutline.csharp_bindings').types(self.V, f, name,
460
+ local ids = require('codeoutline.analysis.csharp.csharp_bindings').types(self.V, f, name,
461
461
  at or (f == self.f and self.offset) or 0, self.V.js_context, { scope = scope })
462
462
  return ids
463
463
  end
464
464
  if self.V.files[f].language == 'java' or self.V.files[f].language == 'kotlin' then
465
465
  local owner = self.fn and self.rec.nodes[self.fn] or self.owner and self.rec.nodes[self.owner]
466
466
  scope = scope or owner and owner.qualified
467
- return require('codeoutline.implementations').types(self.V, f, name, self.V.js_context, scope, at)
467
+ return require('codeoutline.analysis.implementations').types(self.V, f, name, self.V.js_context, scope, at)
468
468
  end
469
469
  if self.V.files[f].language == 'cpp' then
470
470
  if not scope and f == self.f then
@@ -472,7 +472,7 @@ function Completion:types(name, f, scope, at)
472
472
  scope = owner and (CALLABLE[owner.kind] and owner.qualified:match('^(.*)::[^:]+$') or owner.qualified)
473
473
  end
474
474
  if at == nil and f == self.f then at = self.offset end
475
- local ids = require('codeoutline.cpp_types').resolve(self.V, f, name,
475
+ local ids = require('codeoutline.analysis.cpp.cpp_types').resolve(self.V, f, name,
476
476
  { scope = scope, at = at or nil, context = self.V.js_context, accept = TYPES, forward = true })
477
477
  return ids
478
478
  end
@@ -513,7 +513,7 @@ function Completion:members(ids, depth, seen)
513
513
  depth, seen = depth or 0, seen or {}
514
514
  local V, out = self.V, {}
515
515
  if self.language == 'go' then
516
- local methods = require('codeoutline.go_methods').context(V, V.js_context)
516
+ local methods = require('codeoutline.analysis.go.go_methods').context(V, V.js_context)
517
517
  for _, id in ipairs(ids) do
518
518
  for _, entry in ipairs(methods.members({ id = id, pointer = false, addressable = true }, self.f)) do out[#out + 1] = entry end
519
519
  end
@@ -540,10 +540,10 @@ function Completion:members(ids, depth, seen)
540
540
  -- Out-of-line members anywhere: `Box::area`, Go methods, Lua `M.f` / `M:f`.
541
541
  for _, entry in ipairs(self:owned(node.qualified, graph.family(language))) do
542
542
  if self:expired() then break end
543
- local owner = language == 'cpp' and require('codeoutline.cpp_types').owner(V, entry.file, entry.node, V.js_context)
543
+ local owner = language == 'cpp' and require('codeoutline.analysis.cpp.cpp_types').owner(V, entry.file, entry.node, V.js_context)
544
544
  local parent = entry.node.parent and V.files[entry.file].nodes[entry.node.parent]
545
545
  local legacy = language == 'cpp' and not owner and (not parent or not TYPES[parent.kind])
546
- and not require('codeoutline.cpp_includes').policy(V, self.f, V.js_context).configured
546
+ and not require('codeoutline.analysis.cpp.cpp_includes').policy(V, self.f, V.js_context).configured
547
547
  if language ~= 'cpp' or owner == id or legacy then
548
548
  out[#out + 1] = entry
549
549
  end
@@ -634,7 +634,7 @@ function Completion:module_members(files, module_name)
634
634
  if self:expired() then break end
635
635
  local rec = self.V.files[g]
636
636
  local language = rec.language
637
- local native = require('codeoutline.foreign').exports(rec, self.language, module_name)
637
+ local native = require('codeoutline.analysis.foreign').exports(rec, self.language, module_name)
638
638
  if native then
639
639
  for name, n in pairs(native) do
640
640
  local node = rec.nodes[n]
@@ -784,21 +784,8 @@ end
784
784
  -- A receiver: { types = ids } or { modules = files }.
785
785
  function Completion:receiver(item, depth)
786
786
  local name = item.name
787
- if self.language == 'go' then
788
- local receiver = require('codeoutline.go_methods').context(self.V, self.V.js_context).receiver(self.f, name, self.offset)
789
- if receiver == false then return { go_blocked = true } end
790
- if receiver then return { go_receiver = receiver } end
791
- end
792
- if self.language == 'lua' then
793
- local target, bound = require('codeoutline.lua_bindings').receiver(
794
- self.V, self.rec, self.T, name, self.offset, self.V.js_context.lua)
795
- if target then return target end
796
- if bound then return { owner = name, local_only = true } end
797
- end
798
- if SELF[name] or (self.language == 'rust' and name == 'self') then
799
- local ids = self:self_types()
800
- if #ids > 0 then return { types = ids } end
801
- end
787
+ local receiver = require('codeoutline.analysis.receivers').completion(self, item)
788
+ if receiver then return receiver end
802
789
  local entry = find_local(self:locals(), name)
803
790
  if entry then
804
791
  if entry.module then
@@ -819,12 +806,12 @@ function Completion:receiver(item, depth)
819
806
  if #files > 0 then return { modules = files, module_name = alias.path } end
820
807
  end
821
808
  if self.language == 'lua' and not entry then
822
- local files = require('codeoutline.lua_bindings').native_modules(self.V, name, self.V.js_context.lua)
809
+ local files = require('codeoutline.analysis.lua.lua_bindings').native_modules(self.V, name, self.V.js_context.lua)
823
810
  if #files > 0 then return { modules = files, module_name = name } end
824
811
  end
825
812
  if self.language == 'csharp' then
826
813
  if name == 'global' then return { csharp_namespace = '' } end
827
- local ids, namespace, known = require('codeoutline.csharp_bindings').types(self.V, self.f, name, self.offset, self.V.js_context)
814
+ local ids, namespace, known = require('codeoutline.analysis.csharp.csharp_bindings').types(self.V, self.f, name, self.offset, self.V.js_context)
828
815
  if namespace then return { csharp_namespace = namespace } end
829
816
  if known then return #ids > 0 and { types = ids, static = not item.call } or nil end
830
817
  end
@@ -844,10 +831,11 @@ end
844
831
 
845
832
  function Completion:entries(target)
846
833
  if not target then return {} end
834
+ if target.receiver then return require('codeoutline.analysis.receivers').entries(self, target.receiver) end
847
835
  if target.go_blocked or target.cxx_blocked then return {} end
848
- if target.go_receiver then return require('codeoutline.go_methods').context(self.V, self.V.js_context).members(target.go_receiver, self.f) end
836
+ if target.go_receiver then return require('codeoutline.analysis.go.go_methods').context(self.V, self.V.js_context).members(target.go_receiver, self.f) end
849
837
  if target.cxx_receiver then
850
- local receivers = require('codeoutline.cpp_receivers').context(self.V, self.V.js_context)
838
+ local receivers = require('codeoutline.analysis.cpp.cpp_receivers').context(self.V, self.V.js_context)
851
839
  local out, names = {}, {}
852
840
  for _, entry in ipairs(self:members({ target.cxx_receiver.id })) do
853
841
  if self:expired() then break end
@@ -861,9 +849,9 @@ function Completion:entries(target)
861
849
  end
862
850
  return out
863
851
  end
864
- if target.rust_module then return require('codeoutline.rust_resolution').members(self.V, target.rust_module, self.V.js_context) end
852
+ if target.rust_module then return require('codeoutline.analysis.rust.rust_resolution').members(self.V, target.rust_module, self.V.js_context) end
865
853
  if target.cpp_namespace then
866
- local bindings, result = require('codeoutline.cpp_types'), {}
854
+ local bindings, result = require('codeoutline.analysis.cpp.cpp_types'), {}
867
855
  local any = setmetatable({}, { __index = function() return true end })
868
856
  for _, entry in ipairs(bindings.namespace_members(self.V, self.f, target.cpp_namespace, self.V.js_context, self.offset,
869
857
  nil, nil, function() return self:expired() end)) do
@@ -875,7 +863,7 @@ function Completion:entries(target)
875
863
  return result
876
864
  end
877
865
  if target.csharp_namespace ~= nil then
878
- return require('codeoutline.csharp_bindings').namespace_members(self.V, self.f, target.csharp_namespace, self.V.js_context)
866
+ return require('codeoutline.analysis.csharp.csharp_bindings').namespace_members(self.V, self.f, target.csharp_namespace, self.V.js_context)
879
867
  end
880
868
  if target.modules then return self:module_members(target.modules, target.module_name) end
881
869
  if target.owner then
@@ -888,7 +876,7 @@ function Completion:entries(target)
888
876
  local kept = {}
889
877
  for _, entry in ipairs(entries) do
890
878
  local n = entry.node
891
- local bindings = require('codeoutline.csharp_bindings')
879
+ local bindings = require('codeoutline.analysis.csharp.csharp_bindings')
892
880
  if not n or TYPES[n.kind] or (bindings.static_node(self.V, entry.file, n, self.V.js_context) == (target.static or false)
893
881
  and bindings.visible_node(self.V, self.f, entry.file, n, self.offset, self.V.js_context)) then kept[#kept + 1] = entry end
894
882
  end
@@ -900,12 +888,12 @@ end
900
888
  -- Type of a receiver chain, element by element.
901
889
  function Completion:chain(chain, depth)
902
890
  depth = depth or 0
903
- if self.rust_static and require('codeoutline.rust_packages').owner(self.V, self.f, self.V.js_context) then
891
+ if self.rust_static and require('codeoutline.analysis.rust.rust_packages').owner(self.V, self.f, self.V.js_context) then
904
892
  local names, plain = {}, true
905
893
  for _, element in ipairs(chain) do names[#names + 1] = element.name; if element.call then plain = false end end
906
894
  if plain then
907
- local scope = require('codeoutline.rust_resolution').scope(self.V, self.f, self.fn and self.V.id_of[self.f][self.fn])
908
- local found = require('codeoutline.rust_resolution').path(self.V, self.f, table.concat(names, '::'), self.V.js_context, scope)
895
+ local scope = require('codeoutline.analysis.rust.rust_resolution').scope(self.V, self.f, self.fn and self.V.id_of[self.f][self.fn])
896
+ local found = require('codeoutline.analysis.rust.rust_resolution').path(self.V, self.f, table.concat(names, '::'), self.V.js_context, scope)
909
897
  if found and found.module then return { rust_module = found.module } end
910
898
  end
911
899
  end
@@ -922,7 +910,7 @@ function Completion:chain(chain, depth)
922
910
  elseif self.language == 'csharp' and node.kind == 'namespace' then next_namespace = node.qualified
923
911
  elseif self.language == 'csharp' and TYPES[node.kind] then
924
912
  next_static = not element.call
925
- local ids = require('codeoutline.csharp_bindings').types(self.V, self.f, 'global::' .. node.qualified, self.offset, self.V.js_context)
913
+ local ids = require('codeoutline.analysis.csharp.csharp_bindings').types(self.V, self.f, 'global::' .. node.qualified, self.offset, self.V.js_context)
926
914
  for _, id in ipairs(ids) do next_ids[#next_ids + 1] = id end
927
915
  elseif TYPES[node.kind] then
928
916
  for _, id in ipairs(self:types(node.name, entry.file)) do next_ids[#next_ids + 1] = id end
@@ -939,7 +927,7 @@ function Completion:chain(chain, depth)
939
927
  if #next_ids == 0 and element.call and self.language == 'lua' then
940
928
  -- A native object: the C implementation names the metatable
941
929
  -- it returns, which is the type the guest sees.
942
- local value = require('codeoutline.lua_bindings').return_target(self.V, node, self.V.js_context.lua)
930
+ local value = require('codeoutline.analysis.lua.lua_bindings').return_target(self.V, node, self.V.js_context.lua)
943
931
  if value then next_files, next_module = value.modules, value.module_name end
944
932
  end
945
933
  end
@@ -958,7 +946,7 @@ local function receiver_chain(T, op, member)
958
946
  local call = false
959
947
  if is(T, i, ')') and T.m[i] then call = true; i = T.m[i] - 1 end
960
948
  if is(T, i, '>') and T.m[i] then i = T.m[i] - 1 end
961
- if not (T.k[i] == 'id' or (T.k[i] == 'kw' and (SELF[text_of(T, i)] or text_of(T, i) == 'crate' or text_of(T, i) == 'super'))) then
949
+ if not (T.k[i] == 'id' or (T.k[i] == 'kw' and (SELF[text_of(T, i)] or text_of(T, i) == 'Self' or text_of(T, i) == 'crate' or text_of(T, i) == 'super'))) then
962
950
  if call or #chain == 0 then return nil end
963
951
  break
964
952
  end
@@ -971,7 +959,7 @@ end
971
959
 
972
960
  local function item_for(entry, language, V, details)
973
961
  local node = entry.node
974
- local foreign = node and require('codeoutline.foreign').signature(node, language, entry.name)
962
+ local foreign = node and require('codeoutline.analysis.foreign').signature(node, language, entry.name)
975
963
  if details and node and entry.file and not foreign then node = navigation.detail(V, entry.file, node) end
976
964
  return { label = entry.name, kind = ITEM[entry.kind] or 6,
977
965
  detail = foreign and foreign.label or (node and (node.sig or (node.type and (node.type .. ' ' .. entry.name))) or entry.detail) }
@@ -1019,7 +1007,7 @@ function M.complete(req)
1019
1007
  return true
1020
1008
  end
1021
1009
  self.aliases = module_aliases(T, self.language)
1022
- if self.language == 'go' then self.aliases = require('codeoutline.go_modules').aliases(V, f, V.js_context) end
1010
+ if self.language == 'go' then self.aliases = require('codeoutline.analysis.go.go_modules').aliases(V, f, V.js_context) end
1023
1011
  local entries = {}
1024
1012
  local added = {}
1025
1013
  local function add(entry)
@@ -1044,14 +1032,14 @@ function M.complete(req)
1044
1032
  local chain = receiver_chain(T, op, member)
1045
1033
  local target
1046
1034
  if self.language == 'go' then
1047
- local methods = require('codeoutline.go_methods')
1035
+ local methods = require('codeoutline.analysis.go.go_methods')
1048
1036
  local expression = methods.expression(T, op - 1)
1049
1037
  if expression and expression.kind ~= 'binding_value' then
1050
1038
  local receiver = methods.context(V, V.js_context).expression_receiver(f, expression)
1051
1039
  target = receiver and { go_receiver = receiver } or { go_blocked = true }
1052
1040
  end
1053
1041
  elseif self.language == 'c' or self.language == 'cpp' then
1054
- local receivers = require('codeoutline.cpp_receivers')
1042
+ local receivers = require('codeoutline.analysis.cpp.cpp_receivers')
1055
1043
  local expression, _, _, call = receivers.expression(T, op - 1)
1056
1044
  if call then
1057
1045
  local source = self.fn and V.id_of[f][self.fn]
@@ -1075,7 +1063,7 @@ function M.complete(req)
1075
1063
  end
1076
1064
  for alias in pairs(self.aliases) do add({ name = alias, kind = 'namespace', detail = 'module' }) end
1077
1065
  if not narrow and self.language == 'csharp' then
1078
- local bindings = require('codeoutline.csharp_bindings')
1066
+ local bindings = require('codeoutline.analysis.csharp.csharp_bindings')
1079
1067
  for _, entry in ipairs(bindings.usings(V, f, self.offset, V.js_context)) do
1080
1068
  local d = entry.directive
1081
1069
  if d.alias then add({ name = d.alias:gsub('^@', ''), kind = 'class', detail = d.path })
@@ -1142,7 +1130,7 @@ function M.complete(req)
1142
1130
  if not narrow and self.language == 'cpp' and not self:expired() then
1143
1131
  local owner = self.fn and self.rec.nodes[self.fn] or self.owner and self.rec.nodes[self.owner]
1144
1132
  local scope = owner and (CALLABLE[owner.kind] and owner.qualified:match('^(.*)::[^:]+$') or owner.qualified)
1145
- for _, entry in ipairs(require('codeoutline.cpp_types').imported_members(V, f, scope, offset, V.js_context,
1133
+ for _, entry in ipairs(require('codeoutline.analysis.cpp.cpp_types').imported_members(V, f, scope, offset, V.js_context,
1146
1134
  function() return self:expired() end, prefix)) do add(entry) end
1147
1135
  end
1148
1136
  if self.owner or self.fn then
@@ -1174,7 +1162,7 @@ function M.complete(req)
1174
1162
  end
1175
1163
  return { items = items, incomplete = self.incomplete or V.js_context.include_incomplete
1176
1164
  or V.js_context.workspace_incomplete or V.js_context.go_incomplete or V.js_context.go_methods_incomplete
1177
- or V.js_context.cpp_receivers_incomplete or V.js_context.rust_incomplete }
1165
+ or V.js_context.cpp_receivers_incomplete or V.js_context.rust_incomplete or V.js_context.receiver_incomplete }
1178
1166
  end
1179
1167
 
1180
1168
  navigation.register('lsp_completion', function(req)
@@ -1,7 +1,7 @@
1
1
  -- Query-only navigation suggestions, never execution bindings or index data.
2
2
  local M = { MAX_SCAN = 256, MAX_RESULTS = 8, MAX_SITES = 4, MAX_FILES = 4, MAX_BYTES = 2 * 1048576 }
3
- local control = require('codeoutline.control')
4
- local graph = require('codeoutline.graph')
3
+ local control = require('codeoutline.shared.control')
4
+ local graph = require('codeoutline.analysis.graph')
5
5
  local callable = { ['function'] = true, prototype = true, method = true, constructor = true }
6
6
  local types = { class = true, struct = true, union = true, interface = true, record = true,
7
7
  enum = true, typedef = true }
@@ -29,24 +29,26 @@ function M.allowed(site)
29
29
  or site.kind == 'member_call' or site.kind == 'member_symbol'
30
30
  end
31
31
 
32
- function M.find(G, f, site, ctx)
32
+ function M.find(G, f, site, ctx, lua_self)
33
33
  local info = { truncated = site and site.macro_state == 'limited' or false,
34
34
  scanned = 0, reason = 'exact name; binding unconfirmed' }
35
- if not M.allowed(site) then return {}, info end
35
+ if not lua_self and not M.allowed(site) then return {}, info end
36
36
  local language = G.files[f].language
37
37
  -- These languages have package/project visibility that a name-only search
38
38
  -- cannot establish. Their existing resolvers retain authority.
39
39
  if language == 'go' or language == 'rust' or language == 'csharp' then return {}, info end
40
40
  local configured = (language == 'c' or language == 'cpp')
41
- and require('codeoutline.cpp_includes').policy(G, f, ctx).configured
41
+ and require('codeoutline.analysis.cpp.cpp_includes').policy(G, f, ctx).configured
42
42
  local qualified
43
43
  if site.evidence and site.evidence ~= '' then qualified = site.evidence:match('^cpp:name:(.-)%z') end
44
44
  qualified = qualified and normalized(qualified)
45
45
  if qualified and not qualified:find('.', 1, true) then qualified = nil end
46
- if site.recv then
47
- if site.recv == 'self' or site.recv == 'this' or site.recv == 'cls' then return {}, info end
48
- qualified = qualified or normalized(site.recv .. '.' .. site.name)
49
- elseif site.kind == 'member_call' or site.kind == 'member_symbol' then return {}, info end
46
+ if not lua_self then
47
+ if site.recv then
48
+ if site.recv == 'self' or site.recv == 'this' or site.recv == 'cls' then return {}, info end
49
+ qualified = qualified or normalized(site.recv .. '.' .. site.name)
50
+ elseif site.kind == 'member_call' or site.kind == 'member_symbol' then return {}, info end
51
+ end
50
52
  local list, hits, macro_hits = G.by_name[site.name] or {}, {}, {}
51
53
  local source_dir = G.files[f].path:match('^(.*)/') or ''
52
54
  for i = 1, math.min(#list, M.MAX_SCAN) do
@@ -56,7 +58,7 @@ function M.find(G, f, site, ctx)
56
58
  local node, g = G.nodes[id], G.node_file[id]
57
59
  local rec = G.files[g]
58
60
  local parent = node.parent and rec.nodes[node.parent]
59
- local published = language == 'lua' and require('codeoutline.lua_bindings').exported(node, site.name, G.lua_global_export_tables)
61
+ local published = language == 'lua' and require('codeoutline.analysis.lua.lua_bindings').exported(node, site.name, G.lua_global_export_tables)
60
62
  local kind = site.kind == 'new' and types[node.kind]
61
63
  or site.kind ~= 'new' and (callable[node.kind]
62
64
  or (site.kind == 'symbol' or site.kind == 'member_symbol') and (types[node.kind] or values[node.kind]))
@@ -72,14 +74,18 @@ function M.find(G, f, site, ctx)
72
74
  if qualified then
73
75
  name_matches = normalized(node.qualified) == qualified
74
76
  if not name_matches and language == 'lua' then
75
- for _, alias in ipairs(require('codeoutline.lua_bindings').aliases(node, G.lua_global_export_tables)) do
77
+ for _, alias in ipairs(require('codeoutline.analysis.lua.lua_bindings').aliases(node, G.lua_global_export_tables)) do
76
78
  if normalized(alias) == qualified then name_matches = true; break end
77
79
  end
78
80
  end
79
81
  end
80
82
  -- No call sites, private locals, nested functions or unrelated class methods.
81
83
  -- Even same-file locals require lexical evidence from the strict resolver.
82
- if kind and name_matches and graph.family(rec.language) == graph.family(language)
84
+ -- A lexical self can inherit through runtime metatables. The editor
85
+ -- can offer method definition tags even without a receiver binding.
86
+ local lua_method = lua_self and rec.language == 'lua' and node.name == site.name and not parent
87
+ and not graph.is_decl(node) and (node.kind == 'method' or node.kind == 'function' and graph.owner(node.qualified))
88
+ if lua_method or not lua_self and kind and name_matches and graph.family(rec.language) == graph.family(language)
83
89
  and (not node['local'] or published) and not (node.static and g ~= f)
84
90
  and (not parent or parent.kind == 'namespace' or qualified and (types[parent.kind]))
85
91
  and (qualified or node.kind ~= 'method' and node.kind ~= 'constructor') then
@@ -142,7 +148,7 @@ function M.suggest(G, report, ctx)
142
148
  macro_ctx = {}; for k, v in pairs(ctx) do macro_ctx[k] = v end
143
149
  macro_ctx.cpp_macro_context = nil
144
150
  end
145
- local _, sites = require('codeoutline.cpp_macros').resolve(G, f, site.name, entry.line, macro_ctx, true)
151
+ local _, sites = require('codeoutline.analysis.cpp.cpp_macros').resolve(G, f, site.name, entry.line, macro_ctx, true)
146
152
  ids = sites or {}
147
153
  info = { reason = 'possible macro declaration; binding unconfirmed',
148
154
  truncated = macro_ctx.cpp_macro_context and macro_ctx.cpp_macro_context.incomplete or false, scanned = 0 }
@@ -1,6 +1,6 @@
1
- local parse = require('codeoutline.parse')
2
- local paths = require('codeoutline.path')
3
- local text = require('codeoutline.text')
1
+ local parse = require('codeoutline.parsing.parse')
2
+ local paths = require('codeoutline.shared.path')
3
+ local text = require('codeoutline.shared.text')
4
4
  local M = { MAX_BYTES = 1500000 }
5
5
  local branch_scanners = {}
6
6
  local Doc = {}
@@ -144,7 +144,7 @@ function Doc:tokens(all_branches)
144
144
  local config = {}
145
145
  for k, v in pairs(require('codeoutline.lang.' .. language).config) do config[k] = v end
146
146
  config.pp_first_branch = false
147
- scanner = require('codeoutline.xscan').lang(config); branch_scanners[language] = scanner
147
+ scanner = require('codeoutline.parsing.xscan').lang(config); branch_scanners[language] = scanner
148
148
  end
149
149
  self.branch_tokens = scanner:tokenize(self.source)
150
150
  end