@codua/codeoutline-win32-x64 0.2.6 → 0.2.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.
Files changed (72) hide show
  1. package/README.md +205 -3
  2. package/README.zh-CN.md +40 -2
  3. package/bin/xnet.exe +0 -0
  4. package/build-info.json +1 -1
  5. package/package.json +1 -1
  6. package/scripts/codeoutline/affected.lua +145 -0
  7. package/scripts/codeoutline/automatic_events.lua +202 -0
  8. package/scripts/codeoutline/cache_repairs.lua +47 -0
  9. package/scripts/codeoutline/callers.lua +56 -16
  10. package/scripts/codeoutline/cargo_toml.lua +125 -0
  11. package/scripts/codeoutline/command.lua +26 -4
  12. package/scripts/codeoutline/common.lua +48 -7
  13. package/scripts/codeoutline/completion.lua +126 -22
  14. package/scripts/codeoutline/coverage.lua +63 -0
  15. package/scripts/codeoutline/cpp_bindings.lua +46 -11
  16. package/scripts/codeoutline/cpp_fragments.lua +143 -0
  17. package/scripts/codeoutline/cpp_implementations.lua +340 -0
  18. package/scripts/codeoutline/cpp_includes.lua +156 -0
  19. package/scripts/codeoutline/cpp_macros.lua +279 -0
  20. package/scripts/codeoutline/cpp_receivers.lua +342 -0
  21. package/scripts/codeoutline/cpp_types.lua +275 -28
  22. package/scripts/codeoutline/definition_candidates.lua +180 -0
  23. package/scripts/codeoutline/dispatch_aliases.lua +10 -5
  24. package/scripts/codeoutline/documents.lua +22 -9
  25. package/scripts/codeoutline/explore.lua +243 -122
  26. package/scripts/codeoutline/external_headers.lua +171 -0
  27. package/scripts/codeoutline/function_values.lua +69 -0
  28. package/scripts/codeoutline/go_methods.lua +931 -0
  29. package/scripts/codeoutline/go_modules.lua +329 -0
  30. package/scripts/codeoutline/graph.lua +322 -67
  31. package/scripts/codeoutline/implementations.lua +403 -0
  32. package/scripts/codeoutline/index.lua +161 -28
  33. package/scripts/codeoutline/index_worker.lua +11 -4
  34. package/scripts/codeoutline/indirect.lua +4 -2
  35. package/scripts/codeoutline/js_evidence.lua +2 -1
  36. package/scripts/codeoutline/js_resolution.lua +40 -12
  37. package/scripts/codeoutline/js_workspace.lua +325 -0
  38. package/scripts/codeoutline/lang/c.lua +15 -2
  39. package/scripts/codeoutline/lang/cpp.lua +7 -4
  40. package/scripts/codeoutline/lang/csharp.lua +1 -1
  41. package/scripts/codeoutline/lang/js.lua +56 -20
  42. package/scripts/codeoutline/lang/rust.lua +9 -1
  43. package/scripts/codeoutline/language_detect.lua +100 -0
  44. package/scripts/codeoutline/lsp.lua +173 -23
  45. package/scripts/codeoutline/lua_bindings.lua +151 -47
  46. package/scripts/codeoutline/lua_callback_loops.lua +210 -0
  47. package/scripts/codeoutline/main.lua +32 -7
  48. package/scripts/codeoutline/mcp.lua +52 -9
  49. package/scripts/codeoutline/navigation.lua +284 -64
  50. package/scripts/codeoutline/on_demand.lua +93 -0
  51. package/scripts/codeoutline/ordinary_bindings.lua +210 -34
  52. package/scripts/codeoutline/parse.lua +18 -2
  53. package/scripts/codeoutline/parse_pool.lua +1 -1
  54. package/scripts/codeoutline/parse_worker.lua +1 -1
  55. package/scripts/codeoutline/python_bindings.lua +2 -2
  56. package/scripts/codeoutline/query_filters.lua +65 -0
  57. package/scripts/codeoutline/query_report.lua +56 -19
  58. package/scripts/codeoutline/resolution.lua +23 -0
  59. package/scripts/codeoutline/rust_packages.lua +203 -0
  60. package/scripts/codeoutline/rust_resolution.lua +301 -0
  61. package/scripts/codeoutline/search_ranking.lua +70 -0
  62. package/scripts/codeoutline/service.lua +47 -7
  63. package/scripts/codeoutline/shared_events.lua +369 -0
  64. package/scripts/codeoutline/static_dispatch.lua +46 -11
  65. package/scripts/codeoutline/text.lua +3 -2
  66. package/scripts/codeoutline/ts_implementations.lua +81 -0
  67. package/scripts/codeoutline/type_bases.lua +61 -0
  68. package/scripts/codeoutline/type_hierarchy.lua +324 -0
  69. package/scripts/codeoutline/type_references.lua +290 -0
  70. package/scripts/codeoutline/type_uses.lua +260 -0
  71. package/scripts/codeoutline/update_sequence.lua +1 -1
  72. package/scripts/codeoutline/version.lua +1 -1
@@ -0,0 +1,403 @@
1
+ -- Query-owned interface/virtual relationships over existing names and bases.
2
+ -- These are possible implementations, not evidence of a particular runtime type.
3
+ local M = { MAX_CANDIDATES = 512, MAX_TARGETS = 64, MAX_DEPTH = 16, MAX_HIERARCHY = 1024 }
4
+ local control = require('codeoutline.control')
5
+ local languages = { csharp = true, java = true, kotlin = true, typescript = true }
6
+ local types = { class = true, interface = true, struct = true, record = true, enum = true }
7
+ local callable = { method = true, ['function'] = true, constructor = true }
8
+ local function base_names(n)
9
+ if n.bases then return n.bases end
10
+ local result = {}
11
+ for _, base in ipairs(n.extends or {}) do result[#result + 1] = base end
12
+ for _, base in ipairs(n.implements or {}) do result[#result + 1] = base end
13
+ return result
14
+ end
15
+ local function name(s)
16
+ if not s then return nil end
17
+ s = s:gsub('%s+', ''):gsub('^@', '')
18
+ return s:match('^[%a_$][%w_$.]*$') and s or nil
19
+ end
20
+ local function owner(G, id)
21
+ local f, n = G.node_file[id], G.nodes[id]
22
+ return n.parent and types[G.files[f].nodes[n.parent].kind] and G.id_of[f][n.parent] or nil
23
+ end
24
+
25
+ -- Only ordinary named parameter types are accepted. Unsupported syntax is a
26
+ -- barrier; it must not degrade into matching by method name or argument count.
27
+ local function parameters(T, first, last, language)
28
+ local result, a, i = {}, first, first
29
+ while i <= last + 1 do
30
+ local s = T:text(i)
31
+ if i == last + 1 or s == ',' then
32
+ if a < i then
33
+ local b = i - 1
34
+ for j = a, b do if T:text(j) == '=' then b = j - 1; break end end
35
+ local text
36
+ if language == 'kotlin' then
37
+ if T:text(a + 1) ~= ':' then return nil end
38
+ text = T.src:sub(T.s[a + 2], T.e[b])
39
+ else
40
+ if T.k[b] ~= 'id' then return nil end
41
+ text = b > a and T.src:sub(T.s[a], T.e[b - 1]) or ''
42
+ text = text:gsub('^final%s+', '')
43
+ end
44
+ local mode = text:match('^(%w+)%s+')
45
+ if mode == 'ref' or mode == 'out' or mode == 'in' then text = mode .. '|' .. text:sub(#mode + 1) end
46
+ text = text:gsub('%s+', '')
47
+ if text == '' or text:find('[<>()@]') then return nil end
48
+ result[#result + 1] = text
49
+ end
50
+ a = i + 1
51
+ elseif T.m[i] and T.m[i] > i then i = T.m[i] end
52
+ i = i + 1
53
+ end
54
+ return result
55
+ end
56
+
57
+ function M.collect(r, T)
58
+ if r.language == 'go' then return require('codeoutline.go_methods').collect(r, T) end
59
+ if r.language == 'cpp' then return require('codeoutline.cpp_implementations').collect(r, T) end
60
+ if r.language == 'typescript' then return require('codeoutline.ts_implementations').collect(r, T) end
61
+ if not languages[r.language] then return end
62
+ local evidence = {}
63
+ for index, n in ipairs(r.nodes) do
64
+ if index % 128 == 0 then control.check() end
65
+ if types[n.kind] or n.kind == 'method' then
66
+ local d = { at = T.s[n.ti] - 1 }
67
+ if types[n.kind] then d.hierarchy_bases = require('codeoutline.type_bases').collect(T, n, r.language) end
68
+ local opening, ni
69
+ for i = n.ti, n.tj do
70
+ local s = T:text(i)
71
+ if s == '{' then break end
72
+ if s == '<' then d.generic = true end
73
+ if s == 'static' or s == 'private' or s == 'public' or s == 'protected' or s == 'internal'
74
+ or s == 'virtual' or s == 'abstract' or s == 'override' or s == 'open'
75
+ or s == 'final' or s == 'sealed' or s == 'new' then d[s] = true end
76
+ if s == n.name and T:text(i + 1) == '(' and n.kind == 'method' then ni, opening = i, i + 1; break end
77
+ end
78
+ if opening and T.m[opening] then
79
+ d.params = parameters(T, opening + 1, T.m[opening] - 1, r.language)
80
+ if r.language == 'csharp' and T:text(ni - 1) == '.' then
81
+ local first = ni - 2
82
+ while T:text(first - 1) == '.' and T.k[first - 2] == 'id' do first = first - 2 end
83
+ d.explicit = name(T.src:sub(T.s[first], T.e[ni - 2]))
84
+ end
85
+ end
86
+ evidence[index] = d
87
+ end
88
+ end
89
+ r.implementation_evidence = evidence
90
+ if r.language == 'csharp' then return end
91
+ -- Java and Kotlin receiver declarations use the same lexical barriers as
92
+ -- C#/C++ bindings. No assignment flow or factory-return inference is done.
93
+ local wanted, stack, scopes, bindings = {}, {}, {}, {}
94
+ for _, ref in ipairs(r.refs) do if (ref.kind == 'member_call' or ref.kind == 'ref') and ref.recv then wanted[ref.recv] = true end end
95
+ if not next(wanted) then return end
96
+ for i = 1, T.n do
97
+ if T:text(i) == '{' and T.m[i] then stack[#stack + 1] = i end
98
+ scopes[i] = stack[#stack] or 0
99
+ if stack[#stack] and T.m[stack[#stack]] == i then stack[#stack] = nil end
100
+ end
101
+ local endings = { [')'] = true, [','] = true, [';'] = true, ['='] = true, ['{'] = true }
102
+ local forbidden = { ['return'] = true, ['new'] = true, ['throw'] = true, ['package'] = true, ['import'] = true }
103
+ for i = 1, T.n do
104
+ if i % 4096 == 0 then control.check() end
105
+ if T.k[i] == 'id' and wanted[T:text(i)] then
106
+ local ty, declared
107
+ if r.language == 'kotlin' then
108
+ if T:text(i + 1) == ':' then
109
+ local last = i + 2
110
+ while T:text(last + 1) == '.' and T.k[last + 2] == 'id' do last = last + 2 end
111
+ if T:text(last + 1) == '?' then last = last + 1 end
112
+ ty = name(T.src:sub(T.s[i + 2], T.e[last]):gsub('%?$', ''))
113
+ if T:text(last + 1) == '<' then ty = nil end
114
+ declared = true
115
+ elseif T:text(i - 1) == 'val' or T:text(i - 1) == 'var' then
116
+ declared = true
117
+ if T:text(i + 1) == '=' and T.k[i + 2] == 'id' and T:text(i + 3) == '(' then ty = T:text(i + 2) end
118
+ end
119
+ elseif endings[T:text(i + 1)] and not forbidden[T:text(i - 1)]
120
+ and (T.k[i - 1] == 'id' or T.k[i - 1] == 'kw' or T:text(i - 1) == '>' or T:text(i - 1) == ']') then
121
+ local first = i - 1
122
+ while T:text(first - 1) == '.' and T.k[first - 2] == 'id' do first = first - 2 end
123
+ ty, declared = name(T.src:sub(T.s[first], T.e[i - 1])), true
124
+ if ty == 'var' then ty = T:text(i + 1) == '=' and T:text(i + 2) == 'new' and name(T:text(i + 3)) or nil end
125
+ end
126
+ if declared then
127
+ local a, b = scopes[i], scopes[i] > 0 and T.m[scopes[i]] or T.n
128
+ for _, n in ipairs(r.nodes) do
129
+ if (callable[n.kind] or types[n.kind]) and n.ti <= i and i <= n.tj and n.ti > a then a, b = n.ti, n.tj end
130
+ end
131
+ local key = T:text(i)
132
+ bindings[key] = bindings[key] or {}
133
+ bindings[key][#bindings[key] + 1] = { type = ty or false, token = i, first = a, last = b }
134
+ end
135
+ end
136
+ end
137
+ for _, ref in ipairs(r.refs) do
138
+ if (ref.kind == 'member_call' or ref.kind == 'ref') and ref.recv then
139
+ local best
140
+ for _, b in ipairs(bindings[ref.recv] or {}) do
141
+ if b.first <= ref.tok and ref.tok <= b.last and b.token < ref.tok
142
+ and (not best or b.first > best.first or b.first == best.first and b.token > best.token) then best = b end
143
+ end
144
+ if best then
145
+ ref.binding = best.type and 'jvm:type:' .. best.type .. '\0' .. (T.s[best.token] - 1) or 'jvm:?'
146
+ if T:text(ref.tok - 3) == '.' or T:text(ref.tok - 3) == '?.' then ref.binding = 'jvm:?' end
147
+ elseif ref.recv == 'this' or ref.recv == 'super' then ref.binding = 'jvm:self:' .. ref.recv end
148
+ r.has_bindings = true
149
+ end
150
+ end
151
+ end
152
+
153
+ function M.types(G, f, written, ctx, scope, at)
154
+ if G.files[f].language == 'typescript' then
155
+ return require('codeoutline.ts_implementations').types(G, f, written, ctx)
156
+ end
157
+ if G.files[f].language == 'csharp' then
158
+ return require('codeoutline.csharp_bindings').types(G, f, written, at or 0, ctx, { scope = scope })
159
+ end
160
+ written = name(written)
161
+ if not written then return {} end
162
+ local rec = G.files[f]
163
+ local function exact(q)
164
+ local ids = {}
165
+ for _, id in ipairs(G.by_name[q:match('([^.]+)$')] or {}) do
166
+ local n = G.nodes[id]
167
+ if types[n.kind] and n.qualified == q and G.files[G.node_file[id]].language == rec.language then ids[#ids + 1] = id end
168
+ end
169
+ return ids
170
+ end
171
+ local current = scope
172
+ while current and current ~= '' and current ~= rec.package do
173
+ local found = exact(current .. '.' .. written)
174
+ if #found > 0 then return found end
175
+ current = current:match('^(.*)%.[^.]+$')
176
+ end
177
+ local imported, wildcard, seen, seen_wildcard = {}, {}, {}, {}
178
+ for _, imp in ipairs(rec.imports) do
179
+ local alias = imp.alias or imp.path:match('([^.]+)$')
180
+ local q
181
+ if alias == written:match('^([^.]+)') then q = imp.path .. written:sub(#alias + 1)
182
+ elseif imp.path:sub(-2) == '.*' then
183
+ for _, id in ipairs(exact(imp.path:sub(1, -2) .. written)) do
184
+ if not seen_wildcard[id] then seen_wildcard[id] = true; wildcard[#wildcard + 1] = id end
185
+ end
186
+ end
187
+ if q then
188
+ for _, id in ipairs(exact(q)) do
189
+ if not seen[id] then seen[id] = true; imported[#imported + 1] = id end
190
+ end
191
+ end
192
+ end
193
+ if #imported > 0 then return imported end
194
+ local found = exact((rec.package and rec.package ~= '' and rec.package .. '.' or '') .. written)
195
+ if #found > 0 then return found end
196
+ if written:find('.', 1, true) then
197
+ found = exact(written)
198
+ if #found > 0 then return found end
199
+ end
200
+ return wildcard
201
+ end
202
+
203
+ function M.resolve(G, f, src, method, evidence, ctx)
204
+ if not evidence or evidence:sub(1, 4) ~= 'jvm:' then return nil end
205
+ local ty, at = evidence:match('^jvm:type:(.-)%z(%d+)$')
206
+ local cls = src and owner(G, src)
207
+ local ids
208
+ if ty then ids = M.types(G, f, ty, ctx, cls and G.nodes[cls].qualified or G.files[f].package, tonumber(at))
209
+ elseif evidence == 'jvm:self:this' and cls then ids = { cls }
210
+ elseif evidence == 'jvm:self:super' and cls then
211
+ ids = {}
212
+ for _, base in ipairs(base_names(G.nodes[cls])) do
213
+ for _, id in ipairs(M.types(G, f, base, ctx, G.nodes[cls].qualified)) do ids[#ids + 1] = id end
214
+ end
215
+ else return {} end
216
+ if #ids ~= 1 then return {} end
217
+ local result, visited = {}, {}
218
+ local function members(id, depth)
219
+ if visited[id] or depth > M.MAX_DEPTH then return end
220
+ visited[id] = true
221
+ local found = false
222
+ for _, mid in ipairs(G.by_name[method] or {}) do
223
+ if owner(G, mid) == id and G.nodes[mid].kind == 'method' then result[#result + 1] = mid; found = true end
224
+ end
225
+ if not found then
226
+ for _, base in ipairs(base_names(G.nodes[id])) do
227
+ for _, bid in ipairs(M.types(G, G.node_file[id], base, ctx, G.nodes[id].qualified)) do members(bid, depth + 1) end
228
+ end
229
+ end
230
+ end
231
+ members(ids[1], 0)
232
+ return result
233
+ end
234
+
235
+ function M.context(G, ctx, report)
236
+ local C = { incomplete = false, stats = { candidates = 0, links = 0, hierarchy = 0 } }
237
+ local cpp
238
+ local go
239
+ local function go_context()
240
+ if not go then go = require('codeoutline.go_methods').context(G, ctx, report); C.stats.go = go.stats end
241
+ return go
242
+ end
243
+ local function cpp_context()
244
+ if not cpp then cpp = require('codeoutline.cpp_implementations').context(G, ctx, report, M, C) end
245
+ return cpp
246
+ end
247
+ local details, ancestors, outgoing, incoming = {}, {}, {}, {}
248
+ local function info(id)
249
+ if details[id] then return details[id] end
250
+ local f = G.node_file[id]
251
+ local data = ctx.ordinary and ctx.ordinary.data(f) or G.files[f]
252
+ local d = (data.implementation_evidence or {})[id - G.id_of[f][1] + 1] or {}
253
+ details[id] = d; return d
254
+ end
255
+ local function bases(id, seen, depth, path)
256
+ control.check()
257
+ if path[id] then C.incomplete = true; return false end
258
+ if seen[id] then return true end
259
+ if depth > M.MAX_DEPTH or C.stats.hierarchy >= M.MAX_HIERARCHY then C.incomplete = true; return false end
260
+ C.stats.hierarchy = C.stats.hierarchy + 1
261
+ seen[id], path[id] = true, true
262
+ local n, f = G.nodes[id], G.node_file[id]
263
+ if G.files[f].language == 'typescript' and (n.parent or info(id).generic or info(id).declare) then path[id] = nil; return false end
264
+ local valid = true
265
+ for _, base in ipairs(base_names(n)) do
266
+ local at = G.files[f].language == 'csharp' and info(id).at or nil
267
+ local ids = M.types(G, f, base, ctx, n.qualified, at)
268
+ if G.files[f].language == 'typescript' and #ids ~= 1 then valid = false end
269
+ if #ids == 1 and not bases(ids[1], seen, depth + 1, path) then valid = false end
270
+ end
271
+ path[id] = nil
272
+ return valid
273
+ end
274
+ local function ancestry(id)
275
+ if not ancestors[id] then
276
+ local found = {}
277
+ if not bases(id, found, 0, {}) then found = {} end
278
+ found[id] = nil; ancestors[id] = found
279
+ end
280
+ return ancestors[id]
281
+ end
282
+ local primitive = { csharp = { int = 'System.Int32', string = 'System.String', bool = 'System.Boolean',
283
+ long = 'System.Int64', void = 'System.Void', object = 'System.Object', byte = 'System.Byte',
284
+ sbyte = 'System.SByte', short = 'System.Int16', ushort = 'System.UInt16', uint = 'System.UInt32',
285
+ ulong = 'System.UInt64', char = 'System.Char', double = 'System.Double', float = 'System.Single', decimal = 'System.Decimal' },
286
+ java = { String = 'java.lang.String', int = 'int', boolean = 'boolean', long = 'long', Object = 'java.lang.Object',
287
+ byte = 'byte', short = 'short', char = 'char', double = 'double', float = 'float' },
288
+ typescript = { string = 'string', number = 'number', boolean = 'boolean', void = 'void', bigint = 'bigint', symbol = 'symbol', never = 'never' },
289
+ kotlin = { Int = 'kotlin.Int', String = 'kotlin.String', Boolean = 'kotlin.Boolean', Long = 'kotlin.Long',
290
+ Any = 'kotlin.Any', Unit = 'kotlin.Unit', Byte = 'kotlin.Byte', Short = 'kotlin.Short', Char = 'kotlin.Char',
291
+ Double = 'kotlin.Double', Float = 'kotlin.Float' } }
292
+ local function signature(id)
293
+ local d, cls = info(id), owner(G, id)
294
+ if not cls or not d.params or d.generic or info(cls).generic then return nil end
295
+ local out, f = {}, G.node_file[id]
296
+ local lang = G.files[f].language
297
+ local written_types = d.params
298
+ if lang == 'typescript' then
299
+ if not d.returns or d.declare or d.accessor or G.nodes[cls].parent then return nil end
300
+ written_types = {}; for _, p in ipairs(d.params) do written_types[#written_types + 1] = p end
301
+ written_types[#written_types + 1] = d.returns
302
+ end
303
+ for _, written in ipairs(written_types) do
304
+ local mode, rest = written:match('^(%w+)|(.+)$')
305
+ mode, written = mode or '', rest or written
306
+ local raw, suffix = written:match('^(.-)([%[%]%?]*)$')
307
+ local canonical = primitive[lang][raw]
308
+ if canonical and lang ~= 'csharp' and raw:match('^%u') then
309
+ local ids = M.types(G, f, raw, ctx, G.nodes[cls].qualified, d.at)
310
+ if #ids > 1 then return nil end
311
+ if #ids == 1 then canonical = G.nodes[ids[1]].qualified end
312
+ end
313
+ if not canonical and lang ~= 'typescript' and (raw:match('^System%.') or raw:match('^java%.lang%.') or raw:match('^kotlin%.')) then canonical = raw end
314
+ if not canonical then
315
+ local ids = M.types(G, f, raw, ctx, G.nodes[cls].qualified, d.at)
316
+ if #ids ~= 1 then return nil end
317
+ if lang == 'typescript' and info(ids[1]).generic then return nil end
318
+ canonical = lang == 'typescript' and ('node:' .. ids[1]) or G.nodes[ids[1]].qualified
319
+ end
320
+ out[#out + 1] = mode .. ':' .. canonical .. suffix
321
+ end
322
+ return table.concat(out, ',')
323
+ end
324
+ local function contract(id)
325
+ local cls = owner(G, id)
326
+ if not cls or G.nodes[id].kind ~= 'method' or not languages[G.files[G.node_file[id]].language] then return false end
327
+ local d, lang = info(id), G.files[G.node_file[id]].language
328
+ if d.static or d.private or d.final or d.sealed or d.new or d.explicit or d.declare or d.accessor then return false end
329
+ if lang == 'typescript' then return G.nodes[cls].kind == 'interface' or d.abstract end
330
+ return G.nodes[cls].kind == 'interface' or G.nodes[id].abstract or d.virtual or d.abstract or d.open or d.override or lang == 'java'
331
+ end
332
+ local function matches(base, candidate)
333
+ local cls, parent = owner(G, candidate), owner(G, base)
334
+ if not cls or not parent or not ancestry(cls)[parent] then return false end
335
+ local d, language = info(candidate), G.files[G.node_file[candidate]].language
336
+ if G.nodes[candidate].abstract or d.abstract or d.static or d.private and not d.explicit or d.new then return false end
337
+ if language == 'typescript' and (not d.body or d.protected and G.nodes[parent].kind == 'interface') then return false end
338
+ if language == 'kotlin' and not d.override then return false end
339
+ if language == 'csharp' then
340
+ if d.explicit then
341
+ local ids = M.types(G, G.node_file[candidate], d.explicit, ctx, G.nodes[cls].qualified, d.at)
342
+ if #ids ~= 1 or ids[1] ~= parent then return false end
343
+ elseif G.nodes[parent].kind == 'interface' then if not d.public then return false end
344
+ elseif not d.override then return false end
345
+ end
346
+ if language == 'java' and G.nodes[parent].kind == 'interface' and not d.public and G.nodes[cls].kind ~= 'interface' then return false end
347
+ if language == 'java' and G.nodes[parent].kind ~= 'interface' and not info(base).public and not info(base).protected
348
+ and G.files[G.node_file[base]].package ~= G.files[G.node_file[candidate]].package then return false end
349
+ local a, b = signature(base), signature(candidate)
350
+ return a ~= nil and a == b
351
+ end
352
+ function C.outgoing(id)
353
+ if G.files[G.node_file[id]].language == 'go' then
354
+ local result = go_context().outgoing(id); C.incomplete = C.incomplete or go.incomplete; return result
355
+ end
356
+ if G.files[G.node_file[id]].language == 'cpp' and G.nodes[id].kind == 'method' then return cpp_context().outgoing(id) end
357
+ if outgoing[id] then return outgoing[id] end
358
+ local result = {}
359
+ if contract(id) then
360
+ local checked, language = 0, G.files[G.node_file[id]].language
361
+ for _, candidate in ipairs(G.by_name[G.nodes[id].name] or {}) do
362
+ control.check()
363
+ local cls = owner(G, candidate)
364
+ if candidate ~= id and cls and G.nodes[candidate].kind == 'method'
365
+ and G.files[G.node_file[candidate]].language == language and #base_names(G.nodes[cls]) > 0 then
366
+ if checked >= M.MAX_CANDIDATES or #result >= M.MAX_TARGETS then C.incomplete = true; break end
367
+ checked = checked + 1; C.stats.candidates = C.stats.candidates + 1
368
+ if matches(id, candidate) then
369
+ result[#result + 1] = candidate; C.stats.links = C.stats.links + 1
370
+ if report then report:add({ source = id, target = candidate, line = G.nodes[id].line, kind = 'possible implementation (declared inheritance and parameter types)' }) end
371
+ end
372
+ end
373
+ end
374
+ end
375
+ outgoing[id] = result; return result
376
+ end
377
+ function C.incoming(id)
378
+ if G.files[G.node_file[id]].language == 'go' then
379
+ local result = go_context().incoming(id); C.incomplete = C.incomplete or go.incomplete; return result
380
+ end
381
+ if G.files[G.node_file[id]].language == 'cpp' and G.nodes[id].kind == 'method' then return cpp_context().incoming(id) end
382
+ if incoming[id] then return incoming[id] end
383
+ local result, cls = {}, owner(G, id)
384
+ if cls and languages[G.files[G.node_file[id]].language] then
385
+ local parents, checked = ancestry(cls), 0
386
+ for _, base in ipairs(G.by_name[G.nodes[id].name] or {}) do
387
+ control.check()
388
+ if parents[owner(G, base)] then
389
+ if checked >= M.MAX_CANDIDATES or #result >= M.MAX_TARGETS then C.incomplete = true; break end
390
+ checked = checked + 1
391
+ if contract(base) and matches(base, id) then
392
+ result[#result + 1] = base
393
+ if report then report:add({ source = base, target = id, line = G.nodes[base].line, kind = 'possible implementation (declared inheritance and parameter types)' }) end
394
+ end
395
+ end
396
+ end
397
+ end
398
+ incoming[id] = result; return result
399
+ end
400
+ return C
401
+ end
402
+
403
+ return M