@codua/codeoutline-win32-x64 0.2.4 → 0.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,58 @@
1
1
  -- Language-neutral native exports. Adapters supply registration evidence and
2
2
  -- guest parameters; implementation nodes retain their original host signature.
3
3
  local M = {}
4
+ -- Side caches never mutate index records or nodes. Entries follow record identity
5
+ -- (including overlays) and share navigation's bounded full-parse cache.
6
+ local records, contracts, order = setmetatable({}, { __mode = 'k' }), setmetatable({}, { __mode = 'k' }), {}
7
+ local function load(G, f)
8
+ local rec = G.files[f]
9
+ if records[rec] ~= nil then return records[rec] or nil end
10
+ local full = require('codeoutline.navigation').full(G, f, true)
11
+ if not full then return nil end
12
+ -- Node indices are stable only while the source still matches the index.
13
+ for n, node in ipairs(rec.nodes) do
14
+ local current = full.nodes[n]
15
+ if not current or current.name ~= node.name or current.line ~= node.line then return nil end
16
+ end
17
+ if #full.nodes ~= #rec.nodes then return nil end
18
+ local entry = full.foreign_exports or false
19
+ records[rec] = entry
20
+ if entry then
21
+ for n, node in ipairs(rec.nodes) do contracts[node] = full.nodes[n].foreign_signatures end
22
+ end
23
+ order[#order + 1] = rec
24
+ if #order > 64 then
25
+ local old = table.remove(order, 1)
26
+ records[old] = nil
27
+ for _, node in ipairs(old.nodes) do contracts[node] = nil end
28
+ end
29
+ return entry or nil
30
+ end
31
+
32
+ -- Find candidate files from existing symbols without reading their sources.
33
+ local function candidates(G, ctx)
34
+ if ctx.foreign_candidates then return ctx.foreign_candidates end
35
+ local result, seen = {}, {}
36
+ local function add(f)
37
+ if seen[f] then return end
38
+ seen[f] = true
39
+ local rec = G.files[f]
40
+ if rec.language ~= 'c' and rec.language ~= 'cpp' then return end
41
+ for _, node in ipairs(rec.nodes) do
42
+ local name = node.name:match('^luaopen_(.+)$')
43
+ if name then
44
+ result[name] = result[name] or {}
45
+ result[name][#result[name] + 1] = f
46
+ end
47
+ end
48
+ end
49
+ for _, f in ipairs(G.file_order or {}) do add(f) end
50
+ for _, f in ipairs(G.new_files or {}) do add(f) end
51
+ ctx.foreign_candidates = result
52
+ return result
53
+ end
54
+
55
+ function M.has_candidates(G, ctx) return next(candidates(G, ctx)) ~= nil end
4
56
 
5
57
  function M.register(rec, language, module, exports)
6
58
  rec.foreign_exports = rec.foreign_exports or {}
@@ -9,7 +61,8 @@ function M.register(rec, language, module, exports)
9
61
  end
10
62
 
11
63
  function M.exports(rec, language, module)
12
- return rec.foreign_exports and rec.foreign_exports[language] and rec.foreign_exports[language][module]
64
+ local exports = records[rec] or rec.foreign_exports
65
+ return exports and exports[language] and exports[language][module]
13
66
  end
14
67
 
15
68
  function M.collect(rec, T)
@@ -18,30 +71,34 @@ end
18
71
 
19
72
  function M.modules(G, language, name, ctx)
20
73
  ctx = ctx or {}
21
- if not ctx.foreign then
22
- ctx.foreign = {}
23
- local seen = {}
24
- local function add(f)
25
- if seen[f] then return end
26
- seen[f] = true
27
- for lang, modules in pairs(G.files[f].foreign_exports or {}) do
74
+ ctx.foreign = ctx.foreign or {}
75
+ ctx.foreign_loaded = ctx.foreign_loaded or {}
76
+ for _, f in ipairs(candidates(G, ctx)[name] or {}) do
77
+ if not ctx.foreign_loaded[f] then
78
+ local exports = load(G, f)
79
+ -- Failed reads can be skipped within this query, but are never
80
+ -- retained on the record across later query contexts.
81
+ ctx.foreign_loaded[f] = true
82
+ for lang, modules in pairs(exports or {}) do
28
83
  ctx.foreign[lang] = ctx.foreign[lang] or {}
29
84
  for module in pairs(modules) do
30
85
  local names = ctx.foreign[lang]
31
86
  names[module] = names[module] or {}
32
- table.insert(names[module], f)
87
+ names[module][#names[module] + 1] = f
33
88
  end
34
89
  end
35
90
  end
36
- for _, f in ipairs(G.file_order or {}) do add(f) end
37
- for _, f in ipairs(G.new_files or {}) do add(f) end
38
91
  end
39
- return (ctx.foreign[language] or {})[name] or {}
92
+ local files = (ctx.foreign[language] or {})[name] or {}
93
+ -- A long query may have evicted a previously used record.
94
+ for _, f in ipairs(files) do load(G, f) end
95
+ return files
40
96
  end
41
97
 
42
98
  -- Parameter labels are structured data, never reparsed as host-language code.
43
99
  function M.signature(node, language, name)
44
- local contract = node.foreign_signatures and node.foreign_signatures[language]
100
+ local signatures = contracts[node] or node.foreign_signatures
101
+ local contract = signatures and signatures[language]
45
102
  if not contract then return nil end
46
103
  local labels, parameters = {}, {}
47
104
  for i, p in ipairs(contract.parameters) do
@@ -54,7 +111,15 @@ function M.signature(node, language, name)
54
111
  labels[#labels + 1] = '...:unknown'
55
112
  parameters[#parameters + 1] = { label = '...:unknown' }
56
113
  end
57
- return { label = (name or node.name) .. '(' .. table.concat(labels, ', ') .. ')', parameters = parameters }
114
+ return { label = (name or node.name) .. '(' .. table.concat(labels, ', ') .. ')'
115
+ .. (contract.returns and ' -> ' .. contract.returns or ''), parameters = parameters }
116
+ end
117
+
118
+ -- Guest-facing result type: the native metatable the implementation returns.
119
+ function M.returns(node, language)
120
+ local signatures = contracts[node] or node.foreign_signatures
121
+ local contract = signatures and signatures[language]
122
+ return contract and contract.returns or nil
58
123
  end
59
124
 
60
125
  return M
@@ -21,7 +21,8 @@ local TYPES = { LUA_TNUMBER = 'number', LUA_TSTRING = 'string', LUA_TBOOLEAN = '
21
21
  LUA_TTABLE = 'table', LUA_TFUNCTION = 'function', LUA_TTHREAD = 'thread',
22
22
  LUA_TUSERDATA = 'userdata', LUA_TLIGHTUSERDATA = 'lightuserdata', LUA_TNIL = 'nil' }
23
23
 
24
- local function parameters(T, node)
24
+ -- offset: leading C arguments the guest never passes (a method's self).
25
+ local function parameters(T, node, macros, offset)
25
26
  local state
26
27
  for i = node.ti, node.tj - 2 do
27
28
  if T:text(i) == 'lua_State' and T:text(i + 1) == '*' and T.k[i + 2] == 'id' then
@@ -42,7 +43,9 @@ local function parameters(T, node)
42
43
  slots[position] = p
43
44
  local kind = READ[api]
44
45
  if api == 'luaL_checktype' then kind = TYPES[T:text(i + 6)] or 'unknown' end
45
- if api == 'luaL_checkudata' or api == 'luaL_testudata' then kind = literal(T, i + 6) or kind end
46
+ if api == 'luaL_checkudata' or api == 'luaL_testudata' then
47
+ kind = literal(T, i + 6) or (macros and T.k[i + 6] == 'id' and macros[T:text(i + 6)]) or kind
48
+ end
46
49
  p.types[kind] = true
47
50
  local optional = api:match('^luaL_opt') ~= nil
48
51
  if p.optional == nil then p.optional = optional else p.optional = p.optional and optional end
@@ -77,7 +80,8 @@ local function parameters(T, node)
77
80
  end
78
81
  end
79
82
  local result, used = { parameters = {}, unknown_tail = unknown }, {}
80
- for i = 1, highest do
83
+ offset = offset or 0
84
+ for i = 1 + offset, highest do
81
85
  local p = slots[i] or { types = {} }
82
86
  p.types.unknown = nil
83
87
  local types = {}
@@ -86,15 +90,110 @@ local function parameters(T, node)
86
90
  local name = not p.ambiguous and p.name or nil
87
91
  if name and used[name] then name = nil end
88
92
  if name then used[name] = true end
89
- result.parameters[i] = { name = name, type = #types > 0 and table.concat(types, '|') or 'unknown',
93
+ result.parameters[i - offset] = { name = name, type = #types > 0 and table.concat(types, '|') or 'unknown',
90
94
  optional = p.optional or nil, default = p.optional and p.default or nil }
91
95
  end
92
96
  return result
93
97
  end
94
98
 
95
- -- Only explicit registration tables wired inside luaopen_* are exports.
96
- -- Keep the original C nodes, including their source ranges and signatures.
99
+ -- `#define NAME "value"`: metatable names are usually macros, not literals.
100
+ local function string_macros(T)
101
+ local map = {}
102
+ for i = 1, T.n do
103
+ if T.k[i] == 'dir' then
104
+ local name, value = T:text(i):match('^#%s*define%s+([%a_][%w_]*)%s+"([^"]*)"%s*$')
105
+ if name then map[name] = value end
106
+ end
107
+ end
108
+ return map
109
+ end
110
+
111
+ -- Metatable name at argument token i.
112
+ local function meta_name(T, i, macros)
113
+ if T.k[i] == 'str' then return literal(T, i) end
114
+ if T.k[i] == 'id' then return macros[T:text(i)] end
115
+ end
116
+
117
+ -- Recognize constructor tails with a small symbolic stack, not C dataflow.
118
+ -- Unknown stack mutations invalidate the tail. All normal returns must agree;
119
+ -- luaL_error paths do not return to the guest. Void push helpers are supported.
120
+ local function returned_meta(T, r, functions, macros, cache, index, depth)
121
+ local node = r.nodes[index]
122
+ if not node or not node.ti then return nil end
123
+ depth = depth or 6
124
+ if depth <= 0 then return nil end
125
+ if cache[index] ~= nil then return cache[index] or nil end
126
+ cache[index] = false
127
+ local stack, result, returns, invalid = {}, nil, 0, false
128
+ local function accept(meta)
129
+ returns = returns + 1
130
+ if not meta or result and result ~= meta then invalid = true end
131
+ result = result or meta
132
+ end
133
+ local i, block_depth = node.ti, 0
134
+ while i <= node.tj do
135
+ if i % 4096 == 0 then control.check() end
136
+ local word = T:text(i)
137
+ if word == '{' then block_depth = block_depth + 1 end
138
+ if word == '}' then block_depth = block_depth - 1 end
139
+ if word == 'return' then
140
+ local value = T:text(i + 1)
141
+ if value == '1' and T:text(i + 2) == ';' then
142
+ accept(stack[#stack])
143
+ elseif value == 'luaL_error' then
144
+ -- This API raises, so it is not a competing normal return.
145
+ elseif functions[value] and T:text(i + 2) == '(' and T.m[i + 2]
146
+ and T:text(T.m[i + 2] + 1) == ';' then
147
+ accept(returned_meta(T, r, functions, macros, cache, functions[value], depth - 1))
148
+ else accept(nil) end
149
+ elseif T:text(i + 1) == '(' and T.m[i + 1] and i > node.ti
150
+ and T:text(i - 1) ~= 'return' then
151
+ local close = T.m[i + 1]
152
+ local conditional = block_depth > 1 or T:text(i - 1) == ')' and T.m[i - 1]
153
+ and T:text(T.m[i - 1] - 1) == 'if'
154
+ if word == 'lua_newuserdata' or word == 'lua_newuserdatauv' then
155
+ stack[#stack + 1] = false
156
+ elseif word == 'luaL_setmetatable' then
157
+ if conditional then invalid = true end
158
+ if #stack > 0 then stack[#stack] = meta_name(T, i + 4, macros) or false end
159
+ elseif word == 'lua_pushvalue' then
160
+ stack[#stack + 1] = false
161
+ elseif word == 'luaL_ref' then
162
+ stack[#stack] = nil
163
+ elseif word == 'lua_pop' or word == 'lua_settop' or word == 'lua_remove'
164
+ or word == 'lua_replace' or word == 'lua_insert' or word == 'lua_rotate' then
165
+ stack = {}
166
+ elseif word:match('^lua_push') or word:match('^lua_get') and word ~= 'lua_gettop'
167
+ or word == 'lua_newtable' or word == 'lua_createtable' then
168
+ stack[#stack + 1] = false
169
+ elseif functions[word] and functions[word] ~= index then
170
+ local meta = returned_meta(T, r, functions, macros, cache, functions[word], depth - 1)
171
+ if meta then
172
+ if conditional then invalid = true end
173
+ stack[#stack + 1] = meta
174
+ elseif #stack > 0 then stack = {} end
175
+ elseif word:match('^lua_') and word ~= 'lua_gettop'
176
+ and not word:match('^lua_to') and not word:match('^lua_is')
177
+ and word ~= 'lua_type' then
178
+ stack = {}
179
+ end
180
+ -- Arguments are not independent statements or constructor results.
181
+ i = close
182
+ end
183
+ i = i + 1
184
+ end
185
+ if returns == 0 and (node.sig or ''):match('^%s*static%s+void%s') then result = stack[#stack] end
186
+ if invalid then result = nil end
187
+ cache[index] = result or false
188
+ return result
189
+ end
190
+
191
+ -- Only explicit registration tables wired inside luaopen_* are exports. A
192
+ -- metatable's methods are exported under the metatable name, which is the type
193
+ -- guests see, so `handle:get(...)` completes and tips without hand-written
194
+ -- metadata. Keep the original C nodes, ranges and signatures.
97
195
  function M.collect(r, T)
196
+ local macros = string_macros(T)
98
197
  local tables, functions = {}, {}
99
198
  for n, node in ipairs(r.nodes) do
100
199
  if node.kind == 'function' then functions[node.name] = n end
@@ -116,28 +215,56 @@ function M.collect(r, T)
116
215
  end
117
216
  end
118
217
  end
218
+ local cache = {}
219
+ local function signature(n, method_of)
220
+ local target = r.nodes[n]
221
+ target.foreign_signatures = target.foreign_signatures or {}
222
+ if target.foreign_signatures.lua then return end
223
+ local contract = parameters(T, target, macros, method_of and 1 or 0)
224
+ contract.returns = returned_meta(T, r, functions, macros, cache, n)
225
+ target.foreign_signatures.lua = contract
226
+ end
119
227
  for _, node in ipairs(r.nodes) do
120
228
  local module = node.kind == 'function' and node.name:match('^luaopen_(.+)$')
121
229
  if module then
122
- local exports = {}
230
+ local exports, metas, meta, discard = {}, {}, nil, {}
123
231
  for i = node.ti, node.tj do
124
232
  local call = T:text(i)
125
- -- A fresh table replaces registrations for earlier metatables.
126
- if T:text(i + 1) == '(' and (call == 'luaL_newlib' or call == 'lua_newtable'
127
- or call == 'lua_createtable' or call == 'luaL_newmetatable') then exports = {} end
128
- if T:text(i + 1) == '(' and T:text(i + 3) == ',' then
129
- local arg = (call == 'luaL_newlib' or call == 'luaL_setfuncs') and i + 4
130
- if call == 'luaL_register' and T:text(i + 5) == ',' then arg = i + 6 end
131
- for name, n in pairs(tables[arg and T:text(arg)] or {}) do exports[name] = n end
233
+ if T:text(i + 1) == '(' then
234
+ local into
235
+ if call == 'luaL_newmetatable' then
236
+ meta = meta_name(T, i + 4, macros)
237
+ if meta then metas[meta] = metas[meta] or {} end
238
+ into = meta and metas[meta] or discard
239
+ else
240
+ -- `lua_pop` finishes a metatable; a fresh library table
241
+ -- starts the module. A plain table inside a metatable
242
+ -- block is that metatable's `__index`, not the module.
243
+ if call == 'luaL_newlib' then
244
+ meta, exports = nil, {}
245
+ elseif call == 'lua_pop' then
246
+ meta = nil
247
+ elseif not meta and (call == 'lua_newtable' or call == 'lua_createtable') then
248
+ exports = {}
249
+ end
250
+ into = meta and metas[meta] or exports
251
+ end
252
+ if T:text(i + 3) == ',' then
253
+ local arg = (call == 'luaL_newlib' or call == 'luaL_setfuncs') and i + 4
254
+ if call == 'luaL_register' and T:text(i + 5) == ',' then arg = i + 6 end
255
+ for name, n in pairs(tables[arg and T:text(arg)] or {}) do into[name] = n end
256
+ end
257
+ end
258
+ end
259
+ for name, entries in pairs(metas) do
260
+ if next(entries) then
261
+ require('codeoutline.foreign').register(r, 'lua', name, entries)
262
+ for _, n in pairs(entries) do signature(n, name) end
132
263
  end
133
264
  end
134
265
  if next(exports) then
135
266
  require('codeoutline.foreign').register(r, 'lua', module, exports)
136
- for _, n in pairs(exports) do
137
- local target = r.nodes[n]
138
- target.foreign_signatures = target.foreign_signatures or {}
139
- target.foreign_signatures.lua = target.foreign_signatures.lua or parameters(T, target)
140
- end
267
+ for _, n in pairs(exports) do signature(n, nil) end
141
268
  end
142
269
  end
143
270
  end
@@ -285,10 +285,23 @@ local scored_ids, scored_vals = {}, {}
285
285
  -- accept overrides the node kinds the ref kind may bind to (navigation only).
286
286
  local function resolve_ref(G, f, src_id, name, kind, recv, deps, paired, accept, evidence, js_context)
287
287
  if kind == 'annotation' then return nil end
288
+ if evidence and evidence:sub(1, 7) == 'cs:new:' then kind = 'new' end
288
289
  accept = accept or (kind == 'new' and NEWABLE) or (kind == 'ref' and VALUE) or CALLABLE
289
290
  if evidence == '' then evidence = nil end
290
291
  local strategy = 'js/ts binding'
291
292
  local exact = js_resolution.resolve(G, f, name, kind, recv, evidence, js_context)
293
+ if exact == nil and G.files[f].language == 'python' then
294
+ strategy = 'python binding'
295
+ exact = require('codeoutline.python_bindings').resolve(G, f, evidence, js_context)
296
+ end
297
+ if exact == nil and G.files[f].language == 'cpp' then
298
+ strategy = 'c++ declared receiver'
299
+ exact = require('codeoutline.cpp_bindings').resolve(G, f, src_id, name, evidence, deps, js_context)
300
+ end
301
+ if exact == nil and G.files[f].language == 'csharp' then
302
+ strategy = 'c# binding'
303
+ exact = require('codeoutline.csharp_bindings').resolve(G, f, src_id, name, kind, recv, evidence, js_context)
304
+ end
292
305
  if exact == nil then
293
306
  strategy = 'lua binding'
294
307
  exact = lua_bindings.resolve(G, f, name, evidence, js_context and js_context.lua, recv)
@@ -526,9 +539,12 @@ function M.query(symbols, opts)
526
539
  local dependencies, references = {}, {}
527
540
  local js_context = js_resolution.context(symbols)
528
541
  js_context.lua = lua_bindings.context(symbols)
542
+ js_context.ordinary = require('codeoutline.ordinary_bindings').context(symbols, js_context)
543
+ Q.stats.ordinary = js_context.ordinary.stats
529
544
  local report = opts.explain and require('codeoutline.query_report').new() or nil
530
545
  Q.report = report
531
546
  local indirect = require('codeoutline.indirect').query(symbols, opts.dispatch_rules, report)
547
+ local static_dispatch = require('codeoutline.static_dispatch').query(symbols, report)
532
548
  local function deps(f)
533
549
  local entry = dependencies[f]
534
550
  if not entry then
@@ -538,12 +554,13 @@ function M.query(symbols, opts)
538
554
  return entry[1], entry[2]
539
555
  end
540
556
  local function targets(f, i, explain)
557
+ if static_dispatch.handles(f, i) then return {} end
541
558
  local rec, ids = symbols.files[f], symbols.id_of[f]
542
559
  local refs = rec.refs
543
560
  local direct, paired = deps(f)
544
561
  Q.stats.resolved_refs = Q.stats.resolved_refs + 1
545
562
  local found, reason = resolve_ref(symbols, f, ids[refs.from[i]], refs.name[i], refs.kind[i],
546
- refs.recv[i] or nil, direct, paired, nil, refs.lua_binding and refs.lua_binding[i] or refs.js_receiver and refs.js_receiver[i], js_context)
563
+ refs.recv[i] or nil, direct, paired, nil, js_context.ordinary.evidence(f, i), js_context)
547
564
  if report and explain and (refs.kind[i] == 'call' or refs.kind[i] == 'member_call') then
548
565
  if (not found or #found == 0) and explain == true then
549
566
  report:add({ source = ids[refs.from[i]], line = refs.line[i], call = refs.name[i], reason = reason or 'unresolved reference' })
@@ -578,6 +595,11 @@ function M.query(symbols, opts)
578
595
  edges[#edges + 1] = edge.line
579
596
  edges[#edges + 1] = edge.kind
580
597
  end
598
+ for _, edge in ipairs(static_dispatch.outgoing(id)) do
599
+ edges[#edges + 1] = edge.target
600
+ edges[#edges + 1] = edge.line
601
+ edges[#edges + 1] = edge.kind
602
+ end
581
603
  for _, i in ipairs(grouped[id] or {}) do
582
604
  control.check()
583
605
  for _, dst in ipairs(targets(f, i, true) or {}) do
@@ -602,6 +624,9 @@ function M.query(symbols, opts)
602
624
  local incoming = {}
603
625
  for id in pairs(wanted) do incoming[id] = {} end
604
626
  local indirect_incoming = indirect.incoming(wanted)
627
+ for src, edges in pairs(static_dispatch.incoming(wanted)) do
628
+ for _, edge in ipairs(edges) do push3(incoming, edge.target, src, edge.line, edge.kind) end
629
+ end
605
630
  for _, f in ipairs(symbols.file_order) do
606
631
  for _, src in ipairs(symbols.id_of[f]) do
607
632
  for _, edge in ipairs(indirect_incoming[src] or {}) do
@@ -613,10 +638,11 @@ function M.query(symbols, opts)
613
638
  -- Hot loop over every reference: numeric loops, hoisted fields, and the
614
639
  -- selective name test first. Checkpoints run per file and per chunk.
615
640
  local files = symbols.files
641
+ local candidates = js_context.ordinary.candidates(wanted)
616
642
  for _, f in ipairs(symbols.file_order) do
617
643
  control.check()
644
+ local alias_refs = js_context.ordinary.aliases(f, wanted, candidates)
618
645
  local aliases = {}
619
- for _, binding in ipairs(files[f].js_imports or {}) do aliases[binding.local_name] = true end
620
646
  if files[f].language == 'kotlin' then
621
647
  for _, imp in ipairs(files[f].imports) do
622
648
  if imp.alias and names[imp.path:match('([^.]+)$')] then aliases[imp.alias] = true end
@@ -628,7 +654,9 @@ function M.query(symbols, opts)
628
654
  for first = 1, count, 4096 do
629
655
  if first > 1 then control.check() end
630
656
  for i = first, math.min(count, first + 4095) do
631
- if (names[ref_names[i]] or aliases[ref_names[i]] or aliases[refs.recv[i]] or (refs.lua_binding and refs.lua_binding[i] ~= '')) and froms[i] > 0 then
657
+ if (names[ref_names[i]] or aliases[ref_names[i]] or aliases[refs.recv[i]]
658
+ or alias_refs[i]
659
+ or (refs.lua_binding and refs.lua_binding[i] ~= '')) and froms[i] > 0 then
632
660
  for _, dst in ipairs(targets(f, i, wanted) or {}) do
633
661
  if wanted[dst] then
634
662
  push3(incoming, dst, symbols.id_of[f][froms[i]], refs.line[i], refs.kind[i])
@@ -21,13 +21,18 @@ local graph = require('codeoutline.graph')
21
21
  local pool = require('codeoutline.parse_pool')
22
22
 
23
23
  local M = {}
24
- local INDEX_PARSE = { ranges = false }
24
+ local INDEX_PARSE = { ranges = false, omit_signatures = true }
25
+ local LARGE_PARSE = { ranges = false }
26
+ -- Keep signatures for files beyond the shared query parser's 1 MiB limit.
27
+ local function parse_options(source)
28
+ return #source <= 1048576 and INDEX_PARSE or LARGE_PARSE
29
+ end
25
30
 
26
31
  -- Cache version: a checksum of the parser sources, so any parser change
27
32
  -- rebuilds stale caches instead of silently reusing old parse results.
28
33
  M.VERSION = (function()
29
34
  local parts = {}
30
- for _, m in ipairs({ 'xscan', 'text', 'common', 'indirect', 'js_evidence', 'lua_bindings', 'foreign', 'foreign_lua', 'parse', 'lang.c', 'lang.cpp', 'lang.lua', 'lang.python',
35
+ for _, m in ipairs({ 'xscan', 'text', 'common', 'indirect', 'dispatch_aliases', 'static_dispatch', 'js_evidence', 'python_bindings', 'cpp_bindings', 'cpp_types', 'csharp_bindings', 'lua_bindings', 'foreign', 'foreign_lua', 'parse', 'lang.c', 'lang.cpp', 'lang.lua', 'lang.python',
31
36
  'lang.java', 'lang.kotlin', 'lang.go', 'lang.js', 'lang.csharp', 'lang.rust' }) do
32
37
  local file = package.searchpath and package.searchpath('codeoutline.' .. m, package.path)
33
38
  local h = file and io.open(file, 'rb')
@@ -266,7 +271,7 @@ function Index:query_source(rel)
266
271
  local changed = false
267
272
  if not rec.encoding then
268
273
  if encoding == 'gbk' then
269
- local parsed = assert(ci.parse(rel, src, INDEX_PARSE), 'cannot parse decoded source: ' .. rel)
274
+ local parsed = assert(ci.parse(rel, src, parse_options(src)), 'cannot parse decoded source: ' .. rel)
270
275
  parsed.size, parsed.crc, parsed.mtime, parsed.checked = rec.size, rec.crc, rec.mtime, rec.checked
271
276
  parsed.encoding = encoding
272
277
  self:commit(rel, parsed)
@@ -447,7 +452,7 @@ function M.load_file(abs, rel, max_bytes, old_size, old_crc)
447
452
  if old_size == #src and old_crc == crc then
448
453
  return { status = 'unchanged', checked = checked }
449
454
  end
450
- local ok, r = pcall(ci.parse, rel, src, INDEX_PARSE)
455
+ local ok, r = pcall(ci.parse, rel, src, parse_options(src))
451
456
  if not ok and control.is_interrupted(r) then error(r, 0) end
452
457
  -- A parser exception must not permanently hide a GBK file.
453
458
  -- Successful speculative parsing does not scan encoding here.
@@ -455,7 +460,7 @@ function M.load_file(abs, rel, max_bytes, old_size, old_crc)
455
460
  if xutils.to_utf8 then
456
461
  local decoded, encoding = xutils.to_utf8(src)
457
462
  if decoded then
458
- ok, r = pcall(ci.parse, rel, decoded, INDEX_PARSE)
463
+ ok, r = pcall(ci.parse, rel, decoded, parse_options(src))
459
464
  if not ok and control.is_interrupted(r) then error(r, 0) end
460
465
  if ok and r then r.encoding = encoding end
461
466
  end