@codua/codeoutline-win32-x64 0.3.7 → 0.3.9

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.
@@ -10,7 +10,7 @@ function M.at(meta, name, offset)
10
10
  local best, index, future
11
11
  for _, i in ipairs(meta and meta.by_name[name] or {}) do
12
12
  local b = meta.bindings[i]
13
- if b.first <= offset and offset < b.last and b.at <= offset
13
+ if b.first <= offset and offset < b.last and b.at <= offset and (not b.branch_end or offset < b.branch_end)
14
14
  and (not best or b.first > best.first or b.first == best.first and b.at > best.at) then best, index = b, i end
15
15
  if b.hoisted and b.first <= offset and offset < b.last and b.at > offset
16
16
  and (not future or b.first > future.first) then future = b end
@@ -19,19 +19,131 @@ function M.at(meta, name, offset)
19
19
  return best, index
20
20
  end
21
21
 
22
+ -- Collect simple if/else joins using existing delimiter matches. Assignments in
23
+ -- compound bodies stay with the language's ordinary lexical analysis.
24
+ local function join_conditionals(T, language, assignments, meta, add)
25
+ local python = language == 'python'
26
+ local function text(i) return T:text(i) end
27
+ local function end_offset(close) return python and T.s[close] - 1 or T.e[close] end
28
+ local function arm_at(i)
29
+ if python then
30
+ local limit = i + 128
31
+ while i <= T.n and T.k[i] ~= 'nl' do
32
+ if i > limit then return nil end
33
+ i = (T.m[i] and T.m[i] > i and T.m[i] or i) + 1
34
+ end
35
+ i = i + 1
36
+ if T.k[i] ~= 'indent' then return nil end
37
+ else
38
+ if text(i) == '(' then i = T.m[i] and T.m[i] + 1 or i end
39
+ if text(i) ~= '{' then return nil end
40
+ end
41
+ local close = T.m[i]
42
+ if not close then return nil end
43
+ local first = i + 1
44
+ while T.k[first] == 'nl' do first = first + 1 end
45
+ if first == close or (python and text(first) == 'pass' and first + 2 == close) then return close end
46
+ local b = assignments[first]
47
+ if not b or text(first + 1) ~= '=' then return nil end
48
+ -- Check that the assignment occupies the arm. A second statement or
49
+ -- a nested block needs richer control-flow analysis.
50
+ local j = first + 2
51
+ while j < close and text(j) ~= ';' and T.k[j] ~= 'nl' do
52
+ if j > first + 128 then return nil end
53
+ if text(j) == '{' and not T.m[j] then return nil end
54
+ if not python and j > first + 2 and T.l[j] > T.el[j - 1] then return nil end
55
+ j = (T.m[j] and T.m[j] > j and T.m[j] or j) + 1
56
+ end
57
+ local last = j
58
+ if text(j) == ';' then j = j + 1 end
59
+ while T.k[j] == 'nl' do j = j + 1 end
60
+ if j ~= close then return nil end
61
+ local value = first + 2
62
+ if not python and text(value) == 'new' then value = value + 1 end
63
+ value = value + 1
64
+ while text(value) == '.' and T.k[value + 1] == 'id' do value = value + 2 end
65
+ if text(value) == '(' and T.m[value] then value = T.m[value] + 1 end
66
+ return close, b, value == last
67
+ end
68
+
69
+ local blocks = {}
70
+ for i = 1, T.n do
71
+ if i % 1024 == 0 then control.check() end
72
+ while blocks[#blocks] and blocks[#blocks] <= i do blocks[#blocks] = nil end
73
+ if (python and T.k[i] == 'indent' or not python and text(i) == '{') and T.m[i] and T.m[i] > i then
74
+ blocks[#blocks + 1] = T.m[i]
75
+ end
76
+ if T.k[i] == 'kw' and text(i) == 'if' and (python and (i == 1 or T.k[i - 1] == 'nl'
77
+ or T.k[i - 1] == 'indent' or T.k[i - 1] == 'dedent') or not python and text(i - 1) ~= 'else') then
78
+ local arms, next_arm, has_else = {}, i + 1, false
79
+ while next_arm and #arms < 8 do
80
+ local close, assignment, simple_value = arm_at(next_arm)
81
+ if not close then break end
82
+ arms[#arms + 1] = { close = close, assignment = assignment, simple_value = simple_value }
83
+ local after = close + (python and 0 or 1)
84
+ if python and T.k[after] == 'dedent' then after = after + 1 end
85
+ if python and text(after) == 'elif' then next_arm = after + 1
86
+ elseif text(after) == 'else' and not has_else then
87
+ has_else = python or text(after + 1) ~= 'if'
88
+ next_arm = after + (has_else and 1 or 2)
89
+ else next_arm = nil end
90
+ end
91
+ if not next_arm then
92
+ local writes, count = {}, {}
93
+ for _, arm in ipairs(arms) do
94
+ local b = arm.assignment
95
+ if b then writes[b.name] = b; count[b.name] = (count[b.name] or 0) + 1 end
96
+ end
97
+ for name, sample in pairs(writes) do
98
+ local before = M.at(meta, name, T.s[i] - 1)
99
+ if python and before and before.blocked and not before.name then before = nil end
100
+ if python or before and not before.blocked and before.first < sample.first then
101
+ local values, seen, unknown, empty = {}, {}, false, false
102
+ local function include(b)
103
+ if not b or b.empty then empty = true end
104
+ if not b then return end
105
+ for _, value in ipairs(b.alternatives or { b }) do
106
+ if value.type or value.owner then
107
+ local key = (value.type or '') .. '\0' .. tostring(value.owner) .. '\0' .. tostring(value.static)
108
+ if not seen[key] then seen[key] = true; values[#values + 1] = value end
109
+ elseif not value.empty then unknown = true end
110
+ end
111
+ end
112
+ if not has_else or count[name] < #arms then include(before) end
113
+ for _, arm in ipairs(arms) do
114
+ local b = arm.assignment
115
+ if b and b.name == name then
116
+ if arm.simple_value then include(b) else unknown = true end
117
+ if python then b.branch_end = end_offset(arm.close) end
118
+ end
119
+ end
120
+ local close = arms[#arms].close
121
+ local scope = python and sample or before
122
+ local parent_end = blocks[#blocks]
123
+ local last = parent_end and math.min(scope.last, end_offset(parent_end)) or scope.last
124
+ local value = not unknown and #values <= 8 and { alternatives = values, empty = empty } or { blocked = true }
125
+ add(name, close, scope.first, last, value, end_offset(close))
126
+ end
127
+ end
128
+ end
129
+ end
130
+ end
131
+ end
132
+
22
133
  function M.collect(r, T)
23
134
  local language = r.language
24
135
  if language ~= 'python' and language ~= 'kotlin' and not js(language) then return end
25
136
  local meta = { bindings = {}, by_name = {}, statics = {}, fields = {}, weight = 128 }
26
137
  r.receivers = meta
27
- local function add(name, token, first, last, value)
138
+ local function add(name, token, first, last, value, at)
28
139
  if #meta.bindings >= M.MAX_BINDINGS then meta.incomplete = true; return end
29
- local b = { name = name, at = token > 0 and T.s[token] - 1 or 0, first = first, last = last,
140
+ local b = { name = name, at = at or (token > 0 and T.s[token] - 1 or 0), first = first, last = last,
30
141
  owner = value and value.owner, type = value and value.type, static = value and value.static,
31
- super = value and value.super }
142
+ super = value and value.super, alternatives = value and value.alternatives,
143
+ empty = value and value.empty, blocked = value and value.blocked }
32
144
  local n = #meta.bindings + 1; meta.bindings[n] = b
33
145
  meta.by_name[name] = meta.by_name[name] or {}; table.insert(meta.by_name[name], n)
34
- meta.weight = meta.weight + 192 + #name + #(b.type or '')
146
+ meta.weight = meta.weight + 192 + #name + #(b.type or '') + 16 * #(b.alternatives or {})
35
147
  if name == 'this' and js(language) then
36
148
  add('super', token, first, last, { owner = b.owner, type = b.type, static = b.static, super = true })
37
149
  end
@@ -53,6 +165,7 @@ function M.collect(r, T)
53
165
  while text(j) == '.' and T.k[j + 1] == 'id' do parts[#parts + 1] = text(j + 1); j = j + 2 end
54
166
  return table.concat(parts, '.'), j
55
167
  end
168
+ local assignments = {}
56
169
  if language == 'kotlin' then
57
170
  local declarations = {}
58
171
  for _, node in ipairs(r.nodes) do
@@ -142,11 +255,12 @@ function M.collect(r, T)
142
255
  local value
143
256
  if next == '=' or next == ':=' then
144
257
  local name, after = written(i + 2)
145
- if name and text(after) == '(' then value = { type = name }
258
+ if text(i + 2) == 'None' and (T.k[i + 3] == 'nl' or text(i + 3) == ';') then value = { empty = true }
259
+ elseif name and text(after) == '(' then value = { type = name }
146
260
  elseif name then value = M.at(meta, name, T.s[i] - 1) end
147
261
  end
148
262
  local b = add(text(i), i, first, last, value)
149
- if b then b.hoisted = true end
263
+ if b then b.hoisted = true; if next == '=' then assignments[i] = b end end
150
264
  end
151
265
  if T.k[i] == 'id' and prev == 'for' and next == 'in' and depth > 0 then
152
266
  local open = brackets[#brackets]
@@ -212,6 +326,10 @@ function M.collect(r, T)
212
326
  local bindings = {}
213
327
  for _, list in pairs(T.js_bindings or {}) do for _, b in ipairs(list) do bindings[#bindings + 1] = b end end
214
328
  table.sort(bindings, function(a, b) return a.token < b.token end)
329
+ local function ends_statement(i)
330
+ return text(i) == ';' or text(i) == '}' or text(i) == ''
331
+ or (T.k[i] == 'id' or T.k[i] == 'kw') and T.l[i] > T.el[i - 1]
332
+ end
215
333
  for _, b in ipairs(bindings) do
216
334
  local first = b.a > 0 and T.s[b.a] - 1 or 0
217
335
  local last = b.b > 0 and T.e[b.b] + 1 or #T.src + 1
@@ -219,10 +337,25 @@ function M.collect(r, T)
219
337
  if text(b.token + 1) == '=' and (text(b.token + 2) == 'this' or T.k[b.token + 2] == 'id') then
220
338
  value = value or M.at(meta, text(b.token + 2), T.s[b.token] - 1)
221
339
  end
340
+ if not value then
341
+ local tail = b.token + 1
342
+ local _, after = written(b.token + 2)
343
+ if text(tail) == ':' and after and text(after) == '|'
344
+ and (text(after + 1) == 'undefined' or text(after + 1) == 'null') then tail = after + 2 end
345
+ local nil_value = text(tail + 1) == 'null' or text(tail + 1) == 'undefined'
346
+ and not M.at(meta, 'undefined', T.s[b.token] - 1)
347
+ if b.declaration and ends_statement(tail) or text(tail) == '=' and nil_value and ends_statement(tail + 2) then
348
+ value = { empty = true }
349
+ end
350
+ end
222
351
  local added = add(b.name, b.token, first, last, value)
223
- if added then added.hoisted = b.declaration end
352
+ if added then
353
+ added.hoisted = b.declaration
354
+ if not b.declaration then assignments[b.token] = added end
355
+ end
224
356
  end
225
357
  end
358
+ if next(assignments) then join_conditionals(T, language, assignments, meta, add) end
226
359
  for _, ref in ipairs(r.refs) do
227
360
  if ref.recv and text(ref.tok - 3) ~= '.' and text(ref.tok - 3) ~= '?.' then
228
361
  local name = ref.recv
@@ -291,6 +424,19 @@ end
291
424
 
292
425
  local function from_binding(G, f, b, ctx)
293
426
  if not b then return nil end
427
+ if b.alternatives then
428
+ local ids, seen, static = {}, {}, nil
429
+ for _, alternative in ipairs(b.alternatives) do
430
+ local target = from_binding(G, f, alternative, ctx)
431
+ local mode = target.static == true
432
+ if #target.ids == 0 or static ~= nil and static ~= mode then ids = {}; break end
433
+ static = mode
434
+ for _, id in ipairs(target.ids) do
435
+ if not seen[id] then seen[id] = true; ids[#ids + 1] = id end
436
+ end
437
+ end
438
+ return { kind = 'types', ids = ids, static = static, language = G.files[f].language, file = f }
439
+ end
294
440
  local ids = b.owner and { G.id_of[f][b.owner] } or M.types(G, f, b.type, ctx)
295
441
  if b.super then
296
442
  local bases = {}
@@ -357,7 +503,7 @@ local function field_visible(target, bound)
357
503
  end
358
504
 
359
505
  function M.member_ids(G, target, name, ctx, accept)
360
- local result = {}
506
+ local result, emitted = {}, {}
361
507
  for _, cls in ipairs(target.ids or {}) do
362
508
  local chain = ancestors(G, cls, ctx)
363
509
  for _, id in ipairs(chain or {}) do
@@ -381,7 +527,12 @@ function M.member_ids(G, target, name, ctx, accept)
381
527
  end
382
528
  end
383
529
  end
384
- if shadowed then for _, mid in ipairs(found) do result[#result + 1] = mid end; break end
530
+ if shadowed then
531
+ for _, mid in ipairs(found) do
532
+ if not emitted[mid] then emitted[mid] = true; result[#result + 1] = mid end
533
+ end
534
+ break
535
+ end
385
536
  end
386
537
  end
387
538
  return result
@@ -414,7 +565,9 @@ function M.binding(G, f, src, name, ctx, options)
414
565
  local index = options.evidence and tonumber(options.evidence:match('^receiver:(%d+)$'))
415
566
  local b = index == 0 and { blocked = true } or index and meta and meta.bindings[index]
416
567
  or options.offset and M.at(meta, name, options.offset)
417
- if b and (index or b.blocked or b.owner or b.type or language == 'python' or name == 'this') then return from_binding(G, f, b, ctx) end
568
+ if b and (index or b.blocked or b.empty or b.owner or b.type or b.alternatives or language == 'python' or name == 'this') then
569
+ return from_binding(G, f, b, ctx)
570
+ end
418
571
  if js(language) and (name == 'this' or name == 'super') or language == 'python' and (name == 'self' or name == 'cls') then
419
572
  return { kind = 'types', ids = {}, language = language, file = f }
420
573
  end
@@ -97,9 +97,9 @@ install starts the background service and registers it at login. uninstall
97
97
  stops it, removes its login entry, user-level MCP registrations and editor clients.
98
98
  --project also removes MCP entries from that project; --service-only keeps integrations.
99
99
  --purge additionally removes ~/.codeoutline data after cleanup succeeds.
100
- Run uninstall before npm uninstall -g codeoutline; npm has no uninstall hooks.
101
- For npm global installations, remove performs full cleanup with --purge, then
102
- removes the npm package after the runtime exits. Cleanup failures keep the package.
100
+ To fully uninstall a global npm installation, run codeoutline remove.
101
+ It deletes default user data and removes the npm package after cleanup succeeds.
102
+ To keep user data, run codeoutline uninstall, then npm uninstall -g codeoutline.
103
103
  daemon is the service itself.
104
104
  editors detects VS Code, Cursor and Zed and offers optional LSP client installation.
105
105
  Use --editors or CODEOUTLINE_EDITORS to select clients without a prompt.
@@ -38,7 +38,8 @@ local function block_matches(T)
38
38
  for i = 1, T.n do
39
39
  if T.k[i] == 'kw' then
40
40
  local t = T:text(i)
41
- if OPENS[t] then
41
+ -- Lua dialect annotations can use the keyword as a type (`cb:function`).
42
+ if OPENS[t] and (t ~= 'function' or not is(T, i - 1, ':')) then
42
43
  stack[#stack + 1] = i
43
44
  elseif t == 'end' or t == 'until' then
44
45
  local top = stack[#stack]
@@ -119,7 +120,7 @@ function M.parse(path, src, language, opts)
119
120
 
120
121
  for i = 1, T.n do
121
122
  local k = T.k[i]
122
- if k == 'kw' and T:text(i) == 'function' then
123
+ if k == 'kw' and T:text(i) == 'function' and not is(T, i - 1, ':') then
123
124
  local close = bm[i] or T.n
124
125
  local parent = parent_at(i)
125
126
  local name, qualified, kind, start, name_tok
@@ -681,7 +681,9 @@ function Completion:module_members(files, module_name)
681
681
  local ids = self.V.id_of[g]
682
682
  for n, node in ipairs(rec.nodes) do
683
683
  if node.name == exported and not node.parent then
684
- for _, entry in ipairs(self:members({ ids[n] })) do out[#out + 1] = entry end
684
+ for _, entry in ipairs(self:members({ ids[n] })) do
685
+ if entry.file == g or not node['local'] then out[#out + 1] = entry end
686
+ end
685
687
  break
686
688
  end
687
689
  end
@@ -865,6 +867,14 @@ function Completion:entries(target)
865
867
  if target.csharp_namespace ~= nil then
866
868
  return require('codeoutline.analysis.csharp.csharp_bindings').namespace_members(self.V, self.f, target.csharp_namespace, self.V.js_context)
867
869
  end
870
+ if target.alternatives then
871
+ local out = {}
872
+ for _, alternative in ipairs(target.alternatives) do
873
+ if self:expired() then break end
874
+ for _, entry in ipairs(self:module_members(alternative.modules, alternative.module_name)) do out[#out + 1] = entry end
875
+ end
876
+ return out
877
+ end
868
878
  if target.modules then return self:module_members(target.modules, target.module_name) end
869
879
  if target.owner then
870
880
  local out = target.local_only and {} or self:owned(target.owner, graph.family(self.language))
@@ -6,95 +6,115 @@ local callable = { ['function'] = true, prototype = true, method = true, constru
6
6
  local types = { class = true, struct = true, union = true, interface = true, record = true,
7
7
  enum = true, typedef = true }
8
8
  local values = { variable = true, constant = true, field = true, enum_member = true }
9
- local reasons = { ['no indexed target'] = true, ['no eligible target'] = true,
10
- ['unresolved c++ name'] = true, ['name/locality match'] = true,
11
- ['multiple name/locality candidates'] = true }
12
9
  local function normalized(name) return (name:gsub('::', '.'):gsub(':', '.'):gsub('^%.', '')) end
13
10
 
11
+ -- An empty answer leaves the editor and the agent nothing to inspect, so a
12
+ -- failed binding still gets name-based suggestions. They remain unconfirmed
13
+ -- candidates: never call edges, references or index data.
14
14
  function M.allowed(site)
15
15
  if not site or site.decl or not site.name or not site.name:match('^[%a_$][%w_$]*$') then return false end
16
- -- Uncertain preprocessing may hide an ordinary function even when the only
17
- -- same-name macro is in an unrelated header. Definition suggestions can
18
- -- inspect ordinary tags after the macro declaration pass found nothing.
19
- -- This does not establish a call edge or permit guessing macro definitions.
20
- local macro_unknown = site.kind == 'call' and site.reason == 'unknown or unsupported macro visibility'
21
- and (site.macro_state == 'uncertain' or site.macro_state == 'limited')
22
- if not macro_unknown and not reasons[site.reason]
23
- and not (site.reason or ''):match('^ambiguous name candidates') then return false end
24
- -- A known binding that failed is a barrier, not permission to guess another
25
- -- imported value, local, receiver type, package, or constructor.
26
- if site.evidence ~= nil and site.evidence ~= ''
27
- and not (type(site.evidence) == 'string' and site.evidence:match('^cpp:name:')) then return false end
16
+ -- A table literal declared in this file is a bound receiver, not a failed
17
+ -- one: its whole contents are visible, so another file's member is a
18
+ -- different object. A module binding stays eligible because members can be
19
+ -- attached to it from other files.
20
+ if type(site.evidence) == 'string' and site.evidence:match('^lua%-local:') then return false end
28
21
  return site.kind == 'call' or site.kind == 'ref' or site.kind == 'symbol' or site.kind == 'new'
29
22
  or site.kind == 'member_call' or site.kind == 'member_symbol'
30
23
  end
31
24
 
32
- function M.find(G, f, site, ctx, lua_self)
25
+ function M.find(G, f, site, ctx, lua_self, lua_initializers)
33
26
  local info = { truncated = site and site.macro_state == 'limited' or false,
34
27
  scanned = 0, reason = 'exact name; binding unconfirmed' }
35
28
  if not lua_self and not M.allowed(site) then return {}, info end
36
29
  local language = G.files[f].language
37
30
  -- These languages have package/project visibility that a name-only search
38
31
  -- cannot establish. Their existing resolvers retain authority.
39
- if language == 'go' or language == 'rust' or language == 'csharp' then return {}, info end
32
+ local unresolved_receiver = site.reason == 'receiver binding unresolved'
33
+ if not unresolved_receiver and (language == 'go' or language == 'rust' or language == 'csharp') then return {}, info end
34
+ if unresolved_receiver then info.reason = 'matching member name; receiver binding unconfirmed' end
40
35
  local configured = (language == 'c' or language == 'cpp')
41
36
  and require('codeoutline.analysis.cpp.cpp_includes').policy(G, f, ctx).configured
42
37
  local qualified
43
- if site.evidence and site.evidence ~= '' then qualified = site.evidence:match('^cpp:name:(.-)%z') end
38
+ if type(site.evidence) == 'string' then qualified = site.evidence:match('^cpp:name:(.-)%z%d+$') end
44
39
  qualified = qualified and normalized(qualified)
45
40
  if qualified and not qualified:find('.', 1, true) then qualified = nil end
46
41
  if not lua_self then
47
42
  if site.recv then
48
43
  if site.recv == 'self' or site.recv == 'this' or site.recv == 'cls' then return {}, info end
49
44
  qualified = qualified or normalized(site.recv .. '.' .. site.name)
50
- elseif site.kind == 'member_call' or site.kind == 'member_symbol' then return {}, info end
45
+ elseif not unresolved_receiver and (site.kind == 'member_call' or site.kind == 'member_symbol') then return {}, info end
51
46
  end
52
- local list, hits, macro_hits = G.by_name[site.name] or {}, {}, {}
53
- local source_dir = G.files[f].path:match('^(.*)/') or ''
54
- for i = 1, math.min(#list, M.MAX_SCAN) do
55
- if i % 16 == 0 then control.check() end
56
- info.scanned = i
57
- local id = list[i]
58
- local node, g = G.nodes[id], G.node_file[id]
59
- local rec = G.files[g]
60
- local parent = node.parent and rec.nodes[node.parent]
61
- local published = language == 'lua' and require('codeoutline.analysis.lua.lua_bindings').exported(node, site.name, G.lua_global_export_tables)
62
- local kind = site.kind == 'new' and types[node.kind]
63
- or site.kind ~= 'new' and (callable[node.kind]
64
- or (site.kind == 'symbol' or site.kind == 'member_symbol') and (types[node.kind] or values[node.kind]))
65
- -- Unresolved macro visibility can still offer unconfirmed definition
66
- -- tags for navigation, including when include paths are configured.
67
- -- An explicit undef remains a barrier.
68
- if node.kind == 'macro' then
69
- kind = site.kind == 'call' and (site.macro_state == 'unseen'
70
- or site.macro_state == 'uncertain' or site.macro_state == 'limited')
71
- and (g ~= f or site.line and node.line < site.line)
47
+ local list = G.by_name[site.name] or {}
48
+ -- A Lua member alias is only reachable through its dotted name; its bare
49
+ -- key stays unpublished unless the owner is a configured export table.
50
+ local dotted = language == 'lua' and qualified and G.by_name[qualified]
51
+ if dotted and dotted ~= list then
52
+ local merged, seen = {}, {}
53
+ for _, id in ipairs(list) do merged[#merged + 1], seen[id] = id, true end
54
+ for _, id in ipairs(dotted) do
55
+ if not seen[id] then merged[#merged + 1], seen[id] = id, true end
72
56
  end
73
- local name_matches = (node.name == site.name or published) and (normalized(node.qualified) == site.name or published)
74
- if qualified then
75
- name_matches = normalized(node.qualified) == qualified
76
- if not name_matches and language == 'lua' then
77
- for _, alias in ipairs(require('codeoutline.analysis.lua.lua_bindings').aliases(node, G.lua_global_export_tables)) do
78
- if normalized(alias) == qualified then name_matches = true; break end
79
- end
57
+ list = merged
58
+ end
59
+ local source_dir = G.files[f].path:match('^(.*)/') or ''
60
+ -- `bare` drops the receiver qualifier: the member name alone still names a
61
+ -- definition worth offering, including top-level method definitions.
62
+ local function scan(qualifier, bare)
63
+ local hits, macro_hits, scanned = {}, {}, 0
64
+ for i = 1, math.min(#list, M.MAX_SCAN) do
65
+ if i % 16 == 0 then control.check() end
66
+ scanned = i
67
+ local id = list[i]
68
+ local node, g = G.nodes[id], G.node_file[id]
69
+ local rec = G.files[g]
70
+ local parent = node.parent and rec.nodes[node.parent]
71
+ local published = language == 'lua' and require('codeoutline.analysis.lua.lua_bindings').exported(node, site.name, G.lua_global_export_tables)
72
+ local kind = site.kind == 'new' and types[node.kind]
73
+ or site.kind ~= 'new' and (callable[node.kind]
74
+ or (site.kind == 'symbol' or site.kind == 'member_symbol') and (types[node.kind] or values[node.kind]))
75
+ -- Unresolved macro visibility can still offer unconfirmed definition
76
+ -- tags for navigation, including when include paths are configured.
77
+ -- An explicit undef remains a barrier.
78
+ if node.kind == 'macro' then
79
+ kind = site.kind == 'call' and (site.macro_state == 'unseen'
80
+ or site.macro_state == 'uncertain' or site.macro_state == 'limited')
81
+ and (g ~= f or site.line and node.line < site.line)
82
+ end
83
+ local name_matches = node.name == site.name or published
84
+ if not bare then name_matches = name_matches and (normalized(node.qualified) == site.name or published) end
85
+ local aliased = language == 'lua' and require('codeoutline.analysis.lua.lua_bindings').member_alias(node, qualifier)
86
+ if qualifier then name_matches = normalized(node.qualified) == qualifier or aliased end
87
+ if bare and unresolved_receiver then name_matches = name_matches and graph.owner(node.qualified) ~= nil end
88
+ -- Restrict receiver candidates to members and exclude nested
89
+ -- functions unless they are recognized Lua initializer members.
90
+ -- A lexical self can inherit through runtime metatables. The editor
91
+ -- can offer method definition tags even without a receiver binding.
92
+ local lua_method = lua_self and rec.language == 'lua' and node.name == site.name and not parent
93
+ and not graph.is_decl(node) and (node.kind == 'method' or node.kind == 'function' and graph.owner(node.qualified))
94
+ local initialized_member = lua_initializers and language == 'lua' and rec.language == 'lua' and site.recv and parent
95
+ and callable[parent.kind] and (node.kind == 'function' or node.kind == 'method')
96
+ and graph.owner(parent.qualified) == site.recv and normalized(node.qualified) == qualifier
97
+ if lua_method or not lua_self and kind and name_matches and graph.family(rec.language) == graph.family(language)
98
+ and (not node['local'] or published or aliased) and not (node.static and g ~= f)
99
+ and (not parent or parent.kind == 'namespace'
100
+ or (qualifier or unresolved_receiver) and (types[parent.kind] or parent.kind == 'impl')
101
+ or initialized_member)
102
+ and (qualifier or bare or node.kind ~= 'method' and node.kind ~= 'constructor') then
103
+ local score = g == f and 100 or (rec.path:match('^(.*)/') or '') == source_dir and 20 or 0
104
+ if node.kind ~= 'prototype' and not node.decl then score = score + 1 end
105
+ local bucket = node.kind == 'macro' and macro_hits or hits
106
+ bucket[#bucket + 1] = { id = id, score = score }
80
107
  end
81
108
  end
82
- -- No call sites, private locals, nested functions or unrelated class methods.
83
- -- Even same-file locals require lexical evidence from the strict resolver.
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)
89
- and (not node['local'] or published) and not (node.static and g ~= f)
90
- and (not parent or parent.kind == 'namespace' or qualified and (types[parent.kind]))
91
- and (qualified or node.kind ~= 'method' and node.kind ~= 'constructor') then
92
- local score = g == f and 100 or (rec.path:match('^(.*)/') or '') == source_dir and 20 or 0
93
- if node.kind ~= 'prototype' and not node.decl then score = score + 1 end
94
- local bucket = node.kind == 'macro' and macro_hits or hits
95
- bucket[#bucket + 1] = { id = id, score = score }
96
- end
109
+ return hits, macro_hits, scanned
110
+ end
111
+ local hits, macro_hits, scanned = scan(qualified, false)
112
+ -- An unbound receiver still names a member. Offer the bare name instead of
113
+ -- an empty answer, keeping the qualified match authoritative when it hits.
114
+ if #hits == 0 and #macro_hits == 0 and (qualified or unresolved_receiver) and not lua_self then
115
+ hits, macro_hits, scanned = scan(nil, true)
97
116
  end
117
+ info.scanned = scanned
98
118
  -- Ordinary definitions are more useful than unrelated proxy macros.
99
119
  if #hits == 0 then hits = macro_hits
100
120
  elseif configured then hits = {} end