circle-ir 4.20.0 → 4.21.1
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.
- package/dist/analysis/config-loader.d.ts.map +1 -1
- package/dist/analysis/config-loader.js +17 -2
- package/dist/analysis/config-loader.js.map +1 -1
- package/dist/analysis/constant-propagation/patterns.d.ts.map +1 -1
- package/dist/analysis/constant-propagation/patterns.js +3 -0
- package/dist/analysis/constant-propagation/patterns.js.map +1 -1
- package/dist/analysis/constant-propagation/propagator.d.ts +46 -1
- package/dist/analysis/constant-propagation/propagator.d.ts.map +1 -1
- package/dist/analysis/constant-propagation/propagator.js +407 -56
- package/dist/analysis/constant-propagation/propagator.js.map +1 -1
- package/dist/analysis/findings.d.ts.map +1 -1
- package/dist/analysis/findings.js +7 -5
- package/dist/analysis/findings.js.map +1 -1
- package/dist/analysis/interprocedural.d.ts +16 -0
- package/dist/analysis/interprocedural.d.ts.map +1 -1
- package/dist/analysis/interprocedural.js +545 -197
- package/dist/analysis/interprocedural.js.map +1 -1
- package/dist/analysis/passes/csrf-samesite-none-session-pass.d.ts +58 -0
- package/dist/analysis/passes/csrf-samesite-none-session-pass.d.ts.map +1 -0
- package/dist/analysis/passes/csrf-samesite-none-session-pass.js +159 -0
- package/dist/analysis/passes/csrf-samesite-none-session-pass.js.map +1 -0
- package/dist/analysis/passes/interprocedural-pass.d.ts.map +1 -1
- package/dist/analysis/passes/interprocedural-pass.js +83 -10
- package/dist/analysis/passes/interprocedural-pass.js.map +1 -1
- package/dist/analysis/passes/language-sources-pass.d.ts +21 -19
- package/dist/analysis/passes/language-sources-pass.d.ts.map +1 -1
- package/dist/analysis/passes/language-sources-pass.js +703 -25
- package/dist/analysis/passes/language-sources-pass.js.map +1 -1
- package/dist/analysis/passes/param-source-flow-gate-pass.d.ts.map +1 -1
- package/dist/analysis/passes/param-source-flow-gate-pass.js +71 -1
- package/dist/analysis/passes/param-source-flow-gate-pass.js.map +1 -1
- package/dist/analysis/passes/prompt-injection-safety-gate-pass.js +1 -1
- package/dist/analysis/passes/prompt-injection-safety-gate-pass.js.map +1 -1
- package/dist/analysis/passes/scan-secrets-pass.js +2 -2
- package/dist/analysis/passes/scan-secrets-pass.js.map +1 -1
- package/dist/analysis/passes/sensitive-data-in-log-pass.d.ts +66 -0
- package/dist/analysis/passes/sensitive-data-in-log-pass.d.ts.map +1 -0
- package/dist/analysis/passes/sensitive-data-in-log-pass.js +462 -0
- package/dist/analysis/passes/sensitive-data-in-log-pass.js.map +1 -0
- package/dist/analysis/passes/sink-filter-pass.d.ts +7 -1
- package/dist/analysis/passes/sink-filter-pass.d.ts.map +1 -1
- package/dist/analysis/passes/sink-filter-pass.js +372 -14
- package/dist/analysis/passes/sink-filter-pass.js.map +1 -1
- package/dist/analysis/passes/taint-propagation-pass.d.ts.map +1 -1
- package/dist/analysis/passes/taint-propagation-pass.js +289 -13
- package/dist/analysis/passes/taint-propagation-pass.js.map +1 -1
- package/dist/analysis/project-callee-escape-gate.js +1 -1
- package/dist/analysis/project-callee-escape-gate.js.map +1 -1
- package/dist/analysis/rules.d.ts.map +1 -1
- package/dist/analysis/rules.js +9 -0
- package/dist/analysis/rules.js.map +1 -1
- package/dist/analysis/sbom.d.ts +49 -0
- package/dist/analysis/sbom.d.ts.map +1 -1
- package/dist/analysis/sbom.js +126 -1
- package/dist/analysis/sbom.js.map +1 -1
- package/dist/analysis/taint-matcher.d.ts.map +1 -1
- package/dist/analysis/taint-matcher.js +85 -16
- package/dist/analysis/taint-matcher.js.map +1 -1
- package/dist/analysis/taint-propagation.d.ts +1 -0
- package/dist/analysis/taint-propagation.d.ts.map +1 -1
- package/dist/analysis/taint-propagation.js +32 -0
- package/dist/analysis/taint-propagation.js.map +1 -1
- package/dist/analysis/test-to-production-taint-gate.d.ts +13 -0
- package/dist/analysis/test-to-production-taint-gate.d.ts.map +1 -0
- package/dist/analysis/test-to-production-taint-gate.js +30 -0
- package/dist/analysis/test-to-production-taint-gate.js.map +1 -0
- package/dist/analyzer.d.ts +15 -3
- package/dist/analyzer.d.ts.map +1 -1
- package/dist/analyzer.js +56 -2
- package/dist/analyzer.js.map +1 -1
- package/dist/browser/circle-ir.js +5149 -2477
- package/dist/core/circle-ir-core.cjs +2969 -2223
- package/dist/core/circle-ir-core.js +2969 -2219
- package/dist/core/extractors/calls.d.ts +10 -1
- package/dist/core/extractors/calls.d.ts.map +1 -1
- package/dist/core/extractors/calls.js +148 -6
- package/dist/core/extractors/calls.js.map +1 -1
- package/dist/core/extractors/cfg.d.ts.map +1 -1
- package/dist/core/extractors/cfg.js +12 -0
- package/dist/core/extractors/cfg.js.map +1 -1
- package/dist/core/extractors/dfg.d.ts.map +1 -1
- package/dist/core/extractors/dfg.js +151 -18
- package/dist/core/extractors/dfg.js.map +1 -1
- package/dist/core/extractors/types.d.ts +5 -0
- package/dist/core/extractors/types.d.ts.map +1 -1
- package/dist/core/extractors/types.js +149 -4
- package/dist/core/extractors/types.js.map +1 -1
- package/dist/core/parser.d.ts.map +1 -1
- package/dist/core/parser.js +3 -1
- package/dist/core/parser.js.map +1 -1
- package/dist/core/ts-grammar-workarounds.d.ts +18 -0
- package/dist/core/ts-grammar-workarounds.d.ts.map +1 -0
- package/dist/core/ts-grammar-workarounds.js +40 -0
- package/dist/core/ts-grammar-workarounds.js.map +1 -0
- package/dist/facts/facts2.d.ts +12 -3
- package/dist/facts/facts2.d.ts.map +1 -1
- package/dist/facts/facts2.js +24 -7
- package/dist/facts/facts2.js.map +1 -1
- package/dist/facts/index.d.ts +3 -1
- package/dist/facts/index.d.ts.map +1 -1
- package/dist/facts/index.js +2 -1
- package/dist/facts/index.js.map +1 -1
- package/dist/facts/schema2.d.ts +3 -3
- package/dist/facts/schema2.js +3 -3
- package/dist/facts/t6.d.ts +84 -0
- package/dist/facts/t6.d.ts.map +1 -0
- package/dist/facts/t6.js +226 -0
- package/dist/facts/t6.js.map +1 -0
- package/dist/graph-facts/dead-code.d.ts.map +1 -1
- package/dist/graph-facts/dead-code.js +3 -2
- package/dist/graph-facts/dead-code.js.map +1 -1
- package/dist/graph-facts/index.d.ts +1 -1
- package/dist/graph-facts/index.d.ts.map +1 -1
- package/dist/graph-facts/index.js +1 -1
- package/dist/graph-facts/index.js.map +1 -1
- package/dist/graph-facts/reach.d.ts +31 -4
- package/dist/graph-facts/reach.d.ts.map +1 -1
- package/dist/graph-facts/reach.js +120 -4
- package/dist/graph-facts/reach.js.map +1 -1
- package/dist/index.d.ts +8 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -7
- package/dist/index.js.map +1 -1
- package/dist/navigation/index.d.ts +1 -0
- package/dist/navigation/index.d.ts.map +1 -1
- package/dist/navigation/index.js +1 -0
- package/dist/navigation/index.js.map +1 -1
- package/dist/navigation/java-graph.d.ts +31 -9
- package/dist/navigation/java-graph.d.ts.map +1 -1
- package/dist/navigation/java-graph.js +174 -11
- package/dist/navigation/java-graph.js.map +1 -1
- package/dist/navigation/java-registrations.d.ts +93 -0
- package/dist/navigation/java-registrations.d.ts.map +1 -0
- package/dist/navigation/java-registrations.js +254 -0
- package/dist/navigation/java-registrations.js.map +1 -0
- package/dist/navigation/navigation-index.d.ts +65 -3
- package/dist/navigation/navigation-index.d.ts.map +1 -1
- package/dist/navigation/navigation-index.js +181 -11
- package/dist/navigation/navigation-index.js.map +1 -1
- package/dist/navigation/ts-call-edges.d.ts +6 -0
- package/dist/navigation/ts-call-edges.d.ts.map +1 -1
- package/dist/navigation/ts-call-edges.js.map +1 -1
- package/dist/navigation/ts-entry-tables.d.ts +1 -1
- package/dist/navigation/ts-entry-tables.d.ts.map +1 -1
- package/dist/navigation/ts-entry-tables.js.map +1 -1
- package/dist/navigation/xml-scan.d.ts +40 -0
- package/dist/navigation/xml-scan.d.ts.map +1 -0
- package/dist/navigation/xml-scan.js +269 -0
- package/dist/navigation/xml-scan.js.map +1 -0
- package/dist/stable-ids/index.d.ts +3 -3
- package/dist/stable-ids/index.d.ts.map +1 -1
- package/dist/stable-ids/index.js +16 -4
- package/dist/stable-ids/index.js.map +1 -1
- package/dist/stable-ids/nodes.d.ts +16 -6
- package/dist/stable-ids/nodes.d.ts.map +1 -1
- package/dist/stable-ids/nodes.js +17 -7
- package/dist/stable-ids/nodes.js.map +1 -1
- package/dist/stable-ids/ts-parse-errors.d.ts.map +1 -1
- package/dist/stable-ids/ts-parse-errors.js +21 -2
- package/dist/stable-ids/ts-parse-errors.js.map +1 -1
- package/dist/stable-ids/typescript.d.ts +5 -0
- package/dist/stable-ids/typescript.d.ts.map +1 -1
- package/dist/stable-ids/typescript.js +41 -8
- package/dist/stable-ids/typescript.js.map +1 -1
- package/dist/types/index.d.ts +21 -3
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/docs/SPEC.md +9 -0
- package/package.json +3 -3
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Java entry points declared outside Java source (`entry-index@0.1`): the
|
|
3
|
+
* classes and methods a runtime instantiates or calls because a registering
|
|
4
|
+
* file names them. The call graph cannot see these; without them every such
|
|
5
|
+
* class looks unreached.
|
|
6
|
+
*
|
|
7
|
+
* The caller passes the files as text (the library reads none). Recognised by
|
|
8
|
+
* path (`registrationFileKind`):
|
|
9
|
+
*
|
|
10
|
+
* - **OSGi Declarative Services** component descriptions (`OSGI-INF/*.xml`):
|
|
11
|
+
* each component's `implementation` class (`osgi-ds`), and the methods the
|
|
12
|
+
* runtime calls by name: `activate` / `deactivate` / `modified` on the
|
|
13
|
+
* component and `bind` / `unbind` / `updated` on its references
|
|
14
|
+
* (`declared`), plus the specification's default `activate` / `deactivate`
|
|
15
|
+
* when the class has them (`conventional`). `provide` interfaces are
|
|
16
|
+
* contracts, not entries: the implementation is the entry.
|
|
17
|
+
* - **`META-INF/MANIFEST.MF`**: `Bundle-Activator` (`lifecycle`); and the
|
|
18
|
+
* packages of `Export-Package`, whose public top-level types are `export`
|
|
19
|
+
* entries only when the caller asks for them (a library's surface).
|
|
20
|
+
* - **Eclipse `plugin.xml` / `fragment.xml`**: every `class` attribute inside
|
|
21
|
+
* an `<extension>`, any `:data` suffix dropped (`extension-point`, the
|
|
22
|
+
* source naming the point).
|
|
23
|
+
* - **Servlet `web.xml` / `web-fragment.xml`**: `servlet-class` (`route`, its
|
|
24
|
+
* `servlet-mapping` URL patterns as paths), `filter-class` (`route`,
|
|
25
|
+
* middleware) and `listener-class` (`lifecycle`).
|
|
26
|
+
*
|
|
27
|
+
* This module only reads the files. `buildJavaGraph` resolves the names
|
|
28
|
+
* against the tree's declarations (a type for a class name, a method for a
|
|
29
|
+
* member name, looked up through in-tree superclasses) and records a name it
|
|
30
|
+
* cannot resolve as an unresolved registration, never dropping it.
|
|
31
|
+
*/
|
|
32
|
+
import { joinRoutePath } from './ts-call-edges.js';
|
|
33
|
+
import { childText, parseXml, xmlElements } from './xml-scan.js';
|
|
34
|
+
/** Which kind of registering file `path` is, by its name and directory; `null` for any other file. */
|
|
35
|
+
export function registrationFileKind(path) {
|
|
36
|
+
const p = path.replace(/\\/g, '/');
|
|
37
|
+
const base = p.slice(p.lastIndexOf('/') + 1);
|
|
38
|
+
if (base === 'MANIFEST.MF')
|
|
39
|
+
return /(^|\/)META-INF\/MANIFEST\.MF$/.test(p) ? 'manifest' : null;
|
|
40
|
+
if (base === 'plugin.xml' || base === 'fragment.xml')
|
|
41
|
+
return 'plugin';
|
|
42
|
+
if (base === 'web.xml' || base === 'web-fragment.xml')
|
|
43
|
+
return 'web';
|
|
44
|
+
if (/(^|\/)OSGI-INF\/(?:[^/]+\/)*[^/]+\.xml$/.test(p))
|
|
45
|
+
return 'osgi-ds';
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
const JAVA_NAME = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/;
|
|
49
|
+
/** Read every registering file; files of no known kind are ignored. Deterministic in the input order. */
|
|
50
|
+
export function scanRegistrations(files) {
|
|
51
|
+
const out = { registrations: [], exportedPackages: [] };
|
|
52
|
+
for (const f of files) {
|
|
53
|
+
switch (registrationFileKind(f.path)) {
|
|
54
|
+
case 'osgi-ds':
|
|
55
|
+
dsComponents(f, out.registrations);
|
|
56
|
+
break;
|
|
57
|
+
case 'manifest':
|
|
58
|
+
manifest(f, out);
|
|
59
|
+
break;
|
|
60
|
+
case 'plugin':
|
|
61
|
+
pluginExtensions(f, out.registrations);
|
|
62
|
+
break;
|
|
63
|
+
case 'web':
|
|
64
|
+
webDescriptor(f, out.registrations);
|
|
65
|
+
break;
|
|
66
|
+
default: break;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return out;
|
|
70
|
+
}
|
|
71
|
+
// ---------------------------------------------------------------------------
|
|
72
|
+
// OSGi Declarative Services
|
|
73
|
+
const DS_COMPONENT_METHODS = ['activate', 'deactivate', 'modified'];
|
|
74
|
+
const DS_REFERENCE_METHODS = ['bind', 'unbind', 'updated'];
|
|
75
|
+
const DS_DEFAULT_METHODS = ['activate', 'deactivate'];
|
|
76
|
+
function dsComponents(f, out) {
|
|
77
|
+
for (const c of xmlElements(parseXml(f.text))) {
|
|
78
|
+
if (c.name !== 'component')
|
|
79
|
+
continue;
|
|
80
|
+
const impl = c.children.find(x => x.name === 'implementation');
|
|
81
|
+
const cls = impl?.attrs.get('class')?.trim();
|
|
82
|
+
if (!impl || !cls)
|
|
83
|
+
continue;
|
|
84
|
+
const base = { kind: 'osgi-ds', framework: 'osgi', file: f.path, className: cls };
|
|
85
|
+
out.push({ ...base, source: 'OSGI-INF implementation', certainty: 'declared', line: impl.line, col: impl.col });
|
|
86
|
+
for (const a of DS_COMPONENT_METHODS) {
|
|
87
|
+
const m = c.attrs.get(a)?.trim();
|
|
88
|
+
if (m)
|
|
89
|
+
out.push({ ...base, source: `OSGI-INF ${a}`, certainty: 'declared', member: m, line: c.line, col: c.col });
|
|
90
|
+
}
|
|
91
|
+
for (const a of DS_DEFAULT_METHODS) {
|
|
92
|
+
if (c.attrs.has(a))
|
|
93
|
+
continue;
|
|
94
|
+
out.push({ ...base, source: `OSGI-INF ${a} (default)`, certainty: 'conventional', member: a, optional: true, line: c.line, col: c.col });
|
|
95
|
+
}
|
|
96
|
+
for (const r of c.children) {
|
|
97
|
+
if (r.name !== 'reference')
|
|
98
|
+
continue;
|
|
99
|
+
for (const a of DS_REFERENCE_METHODS) {
|
|
100
|
+
const m = r.attrs.get(a)?.trim();
|
|
101
|
+
if (m)
|
|
102
|
+
out.push({ ...base, source: `OSGI-INF ${a}`, certainty: 'declared', member: m, line: r.line, col: r.col });
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Main-section headers, keyed by lower-cased name (header names are
|
|
109
|
+
* case-insensitive in a JAR manifest); a line starting with one space
|
|
110
|
+
* continues the previous header.
|
|
111
|
+
*/
|
|
112
|
+
export function manifestHeaders(text) {
|
|
113
|
+
const heads = new Map();
|
|
114
|
+
let cur = null;
|
|
115
|
+
const lines = text.split(/\r\n|\r|\n/);
|
|
116
|
+
for (let i = 0; i < lines.length; i++) {
|
|
117
|
+
const line = lines[i];
|
|
118
|
+
if (line === '') {
|
|
119
|
+
if (heads.size > 0)
|
|
120
|
+
break; // the main section ends at the first blank line
|
|
121
|
+
continue;
|
|
122
|
+
}
|
|
123
|
+
if (line.startsWith(' ')) {
|
|
124
|
+
if (cur !== null)
|
|
125
|
+
heads.get(cur).value += line.slice(1);
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
const colon = line.indexOf(':');
|
|
129
|
+
if (colon <= 0) {
|
|
130
|
+
cur = null;
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
cur = line.slice(0, colon).trim().toLowerCase();
|
|
134
|
+
heads.set(cur, { value: line.slice(colon + 1).replace(/^ /, ''), line: i + 1 });
|
|
135
|
+
}
|
|
136
|
+
return heads;
|
|
137
|
+
}
|
|
138
|
+
/** Split on `sep` outside double quotes. */
|
|
139
|
+
function splitOutsideQuotes(v, sep) {
|
|
140
|
+
const out = [];
|
|
141
|
+
let cur = '';
|
|
142
|
+
let quoted = false;
|
|
143
|
+
for (const ch of v) {
|
|
144
|
+
if (ch === '"')
|
|
145
|
+
quoted = !quoted;
|
|
146
|
+
if (ch === sep && !quoted) {
|
|
147
|
+
out.push(cur.trim());
|
|
148
|
+
cur = '';
|
|
149
|
+
}
|
|
150
|
+
else
|
|
151
|
+
cur += ch;
|
|
152
|
+
}
|
|
153
|
+
out.push(cur.trim());
|
|
154
|
+
return out.filter(s => s !== '');
|
|
155
|
+
}
|
|
156
|
+
/** The package names of an `Export-Package` value (`a;b;version="1"` exports `a` and `b`). */
|
|
157
|
+
export function exportedPackageNames(value) {
|
|
158
|
+
const out = [];
|
|
159
|
+
for (const clause of splitOutsideQuotes(value, ',')) {
|
|
160
|
+
for (const part of splitOutsideQuotes(clause, ';')) {
|
|
161
|
+
if (part.includes('='))
|
|
162
|
+
continue; // an attribute or a directive
|
|
163
|
+
if (JAVA_NAME.test(part))
|
|
164
|
+
out.push(part);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return out;
|
|
168
|
+
}
|
|
169
|
+
function manifest(f, out) {
|
|
170
|
+
const h = manifestHeaders(f.text);
|
|
171
|
+
const activator = h.get('bundle-activator');
|
|
172
|
+
const cls = activator?.value.trim();
|
|
173
|
+
if (activator && cls) {
|
|
174
|
+
out.registrations.push({ kind: 'lifecycle', source: 'Bundle-Activator', certainty: 'declared', className: cls, framework: 'osgi', file: f.path, line: activator.line, col: 0 });
|
|
175
|
+
}
|
|
176
|
+
const exp = h.get('export-package');
|
|
177
|
+
if (exp)
|
|
178
|
+
for (const name of exportedPackageNames(exp.value))
|
|
179
|
+
out.exportedPackages.push({ name, file: f.path, line: exp.line });
|
|
180
|
+
}
|
|
181
|
+
// ---------------------------------------------------------------------------
|
|
182
|
+
// Eclipse plugin.xml / fragment.xml
|
|
183
|
+
function pluginExtensions(f, out) {
|
|
184
|
+
const base = f.path.slice(f.path.lastIndexOf('/') + 1);
|
|
185
|
+
for (const root of parseXml(f.text)) {
|
|
186
|
+
for (const ext of root.children) {
|
|
187
|
+
if (ext.name !== 'extension')
|
|
188
|
+
continue;
|
|
189
|
+
const point = ext.attrs.get('point')?.trim() ?? '';
|
|
190
|
+
// Only `class` attributes name an entry. Other class-valued attributes some points
|
|
191
|
+
// define (`contributorClass`, `defaultHandler`, `launcher` …) are not read.
|
|
192
|
+
for (const el of xmlElements([ext])) {
|
|
193
|
+
const raw = el.attrs.get('class');
|
|
194
|
+
if (raw === undefined)
|
|
195
|
+
continue;
|
|
196
|
+
const cls = raw.split(':')[0].trim();
|
|
197
|
+
if (!cls)
|
|
198
|
+
continue;
|
|
199
|
+
out.push({ kind: 'extension-point', source: `${base} ${point}`.trim(), certainty: 'declared', className: cls, framework: 'eclipse', file: f.path, line: el.line, col: el.col });
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
// ---------------------------------------------------------------------------
|
|
205
|
+
// Servlet web.xml / web-fragment.xml
|
|
206
|
+
function urlPatterns(roots, mapping, nameTag) {
|
|
207
|
+
const out = new Map();
|
|
208
|
+
for (const root of roots) {
|
|
209
|
+
for (const m of root.children) {
|
|
210
|
+
if (m.name !== mapping)
|
|
211
|
+
continue;
|
|
212
|
+
const name = childText(m, nameTag);
|
|
213
|
+
if (!name)
|
|
214
|
+
continue;
|
|
215
|
+
const list = out.get(name) ?? [];
|
|
216
|
+
for (const u of m.children)
|
|
217
|
+
if (u.name === 'url-pattern' && u.text.trim())
|
|
218
|
+
list.push(u.text.trim());
|
|
219
|
+
out.set(name, list);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return out;
|
|
223
|
+
}
|
|
224
|
+
function webDescriptor(f, out) {
|
|
225
|
+
const base = f.path.slice(f.path.lastIndexOf('/') + 1);
|
|
226
|
+
const roots = parseXml(f.text);
|
|
227
|
+
const servletPaths = urlPatterns(roots, 'servlet-mapping', 'servlet-name');
|
|
228
|
+
const filterPaths = urlPatterns(roots, 'filter-mapping', 'filter-name');
|
|
229
|
+
for (const root of roots) {
|
|
230
|
+
for (const el of root.children) {
|
|
231
|
+
const tag = el.name === 'servlet' ? 'servlet-class' : el.name === 'filter' ? 'filter-class' : el.name === 'listener' ? 'listener-class' : null;
|
|
232
|
+
if (!tag)
|
|
233
|
+
continue;
|
|
234
|
+
const clsEl = el.children.find(x => x.name === tag);
|
|
235
|
+
const cls = clsEl?.text.trim();
|
|
236
|
+
if (!clsEl || !cls)
|
|
237
|
+
continue;
|
|
238
|
+
const at = { file: f.path, line: clsEl.line, col: clsEl.col, className: cls, framework: 'servlet', certainty: 'declared', source: `${base} ${tag}` };
|
|
239
|
+
if (el.name === 'listener') {
|
|
240
|
+
out.push({ ...at, kind: 'lifecycle' });
|
|
241
|
+
continue;
|
|
242
|
+
}
|
|
243
|
+
const name = childText(el, el.name === 'servlet' ? 'servlet-name' : 'filter-name') ?? '';
|
|
244
|
+
const paths = [...new Set((el.name === 'servlet' ? servletPaths : filterPaths).get(name) ?? [])];
|
|
245
|
+
const route = el.name === 'servlet' ? { method: 'ANY' } : { method: 'USE', surface: 'middleware' };
|
|
246
|
+
if (paths.length === 0)
|
|
247
|
+
out.push({ ...at, kind: 'route', ...route });
|
|
248
|
+
// An extension mapping (`*.do`) is kept as written; a path mapping is normalised like `@WebServlet` paths.
|
|
249
|
+
for (const p of paths)
|
|
250
|
+
out.push({ ...at, kind: 'route', ...route, path: p.startsWith('*.') ? p : joinRoutePath([p]) });
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
//# sourceMappingURL=java-registrations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"java-registrations.js","sourceRoot":"","sources":["../../src/navigation/java-registrations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,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AAC,CAAC;YACjG,MAAM,KAAK,GAAG,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,YAAqB,EAAE,CAAC;YAC5G,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;gBAAE,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC;YACrE,2GAA2G;YAC3G,KAAK,MAAM,CAAC,IAAI,KAAK;gBAAE,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QACzH,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -18,7 +18,10 @@
|
|
|
18
18
|
* the receiver as an expression string. The chain is walked left to right,
|
|
19
19
|
* typing each step from the previous step's declared return type.
|
|
20
20
|
* - **A constructor.** `new Widget()` arrives as a call named `Widget` with
|
|
21
|
-
* no receiver. It is bound to `app.Widget.<init>`.
|
|
21
|
+
* no receiver. It is bound to `app.Widget.<init>`. An explicit
|
|
22
|
+
* `super(…)` or `this(…)` arrives as a constructor call named `super` or
|
|
23
|
+
* `this`, naming the superclass or the enclosing type, and binds the same
|
|
24
|
+
* way.
|
|
22
25
|
* - **A nested type's static import.** `import static app.Outer.Inner.make`
|
|
23
26
|
* names `app.Outer.Inner.make`, which only matches a symbol table that
|
|
24
27
|
* kept the nesting — hence `TypeInfo.enclosing_type`.
|
|
@@ -220,7 +223,11 @@ export declare class NavigationIndex {
|
|
|
220
223
|
* overrides it below.
|
|
221
224
|
*/
|
|
222
225
|
private tierFor;
|
|
223
|
-
/**
|
|
226
|
+
/**
|
|
227
|
+
* `new Widget()` → `app.Widget.<init>`, with the constructor chosen like any
|
|
228
|
+
* overload. An explicit constructor invocation (`super(…)` / `this(…)`)
|
|
229
|
+
* binds the same way, to the class the extractor names for it.
|
|
230
|
+
*/
|
|
224
231
|
private bindConstructor;
|
|
225
232
|
/**
|
|
226
233
|
* The overloads of `name` a receiver of type `fqn` can see: its own, then
|
|
@@ -244,7 +251,18 @@ export declare class NavigationIndex {
|
|
|
244
251
|
private selectOverload;
|
|
245
252
|
/** Whether `c` applies to arguments of these types in compiler phase 1, 2 or 3. */
|
|
246
253
|
private applicable;
|
|
247
|
-
/**
|
|
254
|
+
/**
|
|
255
|
+
* `m` is more specific than `o`: each of its parameter types fits the other's.
|
|
256
|
+
*
|
|
257
|
+
* A reference parameter type of `m` that is the argument's own type also
|
|
258
|
+
* counts where it only possibly fits `o`'s: whenever `o` applies, the
|
|
259
|
+
* argument's type, which is `m`'s, is a subtype of `o`'s there, so in every
|
|
260
|
+
* case where `o` competes `m` is the more specific. That settles
|
|
261
|
+
* `this(ctx, copy, (String) null)` against a `ResultSet` overload when
|
|
262
|
+
* `copy`'s class has a supertype outside the tree. An argument of a
|
|
263
|
+
* narrower type than `m`'s parameter is not the same question and stays
|
|
264
|
+
* undecided.
|
|
265
|
+
*/
|
|
248
266
|
private moreSpecific;
|
|
249
267
|
/**
|
|
250
268
|
* Whether a value of type `a` can be passed as `p` — certainly, possibly,
|
|
@@ -401,6 +419,50 @@ export declare class NavigationIndex {
|
|
|
401
419
|
private uniqueByName;
|
|
402
420
|
/** A simple or qualified type name, resolved from one file's point of view. */
|
|
403
421
|
private resolveTypeRecord;
|
|
422
|
+
/**
|
|
423
|
+
* The class an explicit constructor invocation constructs.
|
|
424
|
+
*
|
|
425
|
+
* `this(…)`: the enclosing type, which the extractor names exactly.
|
|
426
|
+
*
|
|
427
|
+
* `super(…)`: the superclass as written, resolved the way Java resolves a
|
|
428
|
+
* name in the class's `extends` clause.
|
|
429
|
+
*
|
|
430
|
+
* 1. A member type of an enclosing type, innermost first: declared there or
|
|
431
|
+
* inherited from a supertype in the tree. The class's own members are
|
|
432
|
+
* not in scope in its own `extends` clause. A member type hides an
|
|
433
|
+
* imported or same-package type with the same name.
|
|
434
|
+
* 2. An exact name, an import, the same package.
|
|
435
|
+
* 3. The extractor's qualified name. For an implicitly imported `java.lang`
|
|
436
|
+
* type it is outside the tree, so `extends Exception` stays
|
|
437
|
+
* `java.lang.Exception` even when some package in the tree declares an
|
|
438
|
+
* `Exception`.
|
|
439
|
+
* 4. A type one of the file's wildcard imports names (`import a.b.*`, or
|
|
440
|
+
* `import a.Outer.*` for its member types), when exactly one does.
|
|
441
|
+
*
|
|
442
|
+
* Anything else is left unbound. A type nested somewhere else in the file
|
|
443
|
+
* is not in scope. A type of the same simple name elsewhere in the tree
|
|
444
|
+
* that no import names may not be the one meant: the name can come from a
|
|
445
|
+
* wildcard package outside the tree, from `java.lang`, or from a supertype
|
|
446
|
+
* outside the tree.
|
|
447
|
+
*/
|
|
448
|
+
private invokedConstructorType;
|
|
449
|
+
/**
|
|
450
|
+
* `name` (`Node`, or `Node.Leaf`) as a member type in scope inside the type
|
|
451
|
+
* at nesting path `inType` (`Tree.Leaf`) of this file. The types enclosing
|
|
452
|
+
* it are searched innermost first, the type itself excluded. Each is
|
|
453
|
+
* searched with its supertypes in the tree, so an inherited member type
|
|
454
|
+
* counts. Present when the first part of `name` is such a member;
|
|
455
|
+
* `type` is then the declaration, or undefined when the rest of `name` is
|
|
456
|
+
* not in the tree. Absent when no enclosing type has that member.
|
|
457
|
+
*/
|
|
458
|
+
private memberTypeInScope;
|
|
459
|
+
/** `fqn`, or the nearest of its supertypes in the tree, that has a member type `name`. */
|
|
460
|
+
private memberTypeOwner;
|
|
461
|
+
/**
|
|
462
|
+
* `anywhere`: also a type nested in a type of this file, then a simple name
|
|
463
|
+
* declared once in the whole tree. Off, only an exact name, an import and
|
|
464
|
+
* the same package.
|
|
465
|
+
*/
|
|
404
466
|
private resolveTypeName;
|
|
405
467
|
/**
|
|
406
468
|
* Why a site in range produced no answer.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"navigation-index.d.ts","sourceRoot":"","sources":["../../src/navigation/navigation-index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"navigation-index.d.ts","sourceRoot":"","sources":["../../src/navigation/navigation-index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAoC,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACvG,OAAO,KAAK,EAGV,gBAAgB,EAChB,KAAK,EACL,SAAS,EACT,YAAY,EAEZ,IAAI,EAEJ,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAEpB,2FAA2F;AAC3F,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,EAAE,EAAE,QAAQ,CAAC;IACb,mEAAmE;IACnE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,YAAY;IAC3B;;;;;OAKG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,uFAAuF;IACvF,QAAQ,CAAC,EAAE,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACtD,8EAA8E;IAC9E,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AA0FD,wEAAwE;AACxE,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,iFAAiF;IACjF,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE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AAO,CAAC,YAAY;IAOpB,gEAAgE;IAChE,OAAO,CAAC,cAAc;IAiBtB,OAAO,CAAC,eAAe;IAIvB,iEAAiE;IACjE,OAAO,CAAC,eAAe;IASvB,6FAA6F;IAC7F,OAAO,CAAC,QAAQ;IAahB,uEAAuE;IACvE,OAAO,CAAC,sBAAsB;IAoB9B;;;;;;;;;;;;;OAaG;IACH,OAAO,CAAC,UAAU;IASlB;;;;;;;;;OASG;IACH,OAAO,CAAC,gBAAgB;IAkBxB,iFAAiF;IACjF,OAAO,CAAC,YAAY;IASpB,+EAA+E;IAC/E,OAAO,CAAC,iBAAiB;IAKzB;;;;;;;;;;;;;;;;;;;;;;;;;OAyBG;IACH,OAAO,CAAC,sBAAsB;IAe9B;;;;;;;;OAQG;IACH,OAAO,CAAC,iBAAiB;IAczB,0FAA0F;IAC1F,OAAO,CAAC,eAAe;IAkBvB;;;;OAIG;IACH,OAAO,CAAC,eAAe;IAuBvB;;;;;;;OAOG;IACH,OAAO,CAAC,SAAS;IAuCjB,oEAAoE;IACpE,OAAO,CAAC,gBAAgB;IA+BxB,2EAA2E;IAC3E,OAAO,CAAC,yBAAyB;IASjC,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,MAAM;IAMd,2DAA2D;IAC3D,OAAO,CAAC,cAAc;IAQtB,OAAO,CAAC,WAAW;IAqBnB,OAAO,CAAC,MAAM;IAYd,OAAO,CAAC,MAAM;CA6Cf"}
|
|
@@ -18,7 +18,10 @@
|
|
|
18
18
|
* the receiver as an expression string. The chain is walked left to right,
|
|
19
19
|
* typing each step from the previous step's declared return type.
|
|
20
20
|
* - **A constructor.** `new Widget()` arrives as a call named `Widget` with
|
|
21
|
-
* no receiver. It is bound to `app.Widget.<init>`.
|
|
21
|
+
* no receiver. It is bound to `app.Widget.<init>`. An explicit
|
|
22
|
+
* `super(…)` or `this(…)` arrives as a constructor call named `super` or
|
|
23
|
+
* `this`, naming the superclass or the enclosing type, and binds the same
|
|
24
|
+
* way.
|
|
22
25
|
* - **A nested type's static import.** `import static app.Outer.Inner.make`
|
|
23
26
|
* names `app.Outer.Inner.make`, which only matches a symbol table that
|
|
24
27
|
* kept the nesting — hence `TypeInfo.enclosing_type`.
|
|
@@ -468,7 +471,16 @@ export class NavigationIndex {
|
|
|
468
471
|
const bare = name?.replace(/<.*>$/, '').replace(/\[\]$/, '').trim();
|
|
469
472
|
if (!bare)
|
|
470
473
|
return undefined;
|
|
471
|
-
|
|
474
|
+
if (bare.includes('.'))
|
|
475
|
+
return bare;
|
|
476
|
+
const imported = rec.imports.get(bare);
|
|
477
|
+
if (imported)
|
|
478
|
+
return imported;
|
|
479
|
+
const ownsSimple = (rec.pkg ? this.typesByFqn.has(`${rec.pkg}.${bare}`) : false) ||
|
|
480
|
+
[...this.typesBySimpleName.get(bare) ?? []].some((t) => t.file === rec.path);
|
|
481
|
+
if (!ownsSimple && (JAVA_LANG.has(bare) || bare in JDK_SUPERS))
|
|
482
|
+
return `java.lang.${bare}`;
|
|
483
|
+
return bare;
|
|
472
484
|
}
|
|
473
485
|
targetOf(owner, name, overload) {
|
|
474
486
|
if (overload)
|
|
@@ -668,8 +680,13 @@ export class NavigationIndex {
|
|
|
668
680
|
: `${evidence}; ${method} is the unique method of that name on ${owner.fqn}, and it has a body`,
|
|
669
681
|
};
|
|
670
682
|
}
|
|
671
|
-
/**
|
|
683
|
+
/**
|
|
684
|
+
* `new Widget()` → `app.Widget.<init>`, with the constructor chosen like any
|
|
685
|
+
* overload. An explicit constructor invocation (`super(…)` / `this(…)`)
|
|
686
|
+
* binds the same way, to the class the extractor names for it.
|
|
687
|
+
*/
|
|
672
688
|
bindConstructor(call, rec, depth) {
|
|
689
|
+
const explicit = isExplicitConstructorInvocation(call);
|
|
673
690
|
const looksCtor = call.is_constructor === true ||
|
|
674
691
|
(call.receiver === null &&
|
|
675
692
|
!!call.receiver_type &&
|
|
@@ -677,13 +694,41 @@ export class NavigationIndex {
|
|
|
677
694
|
/^[A-Z]/.test(call.method_name));
|
|
678
695
|
if (!looksCtor)
|
|
679
696
|
return undefined;
|
|
680
|
-
const
|
|
697
|
+
const rawType = call.receiver_type ?? call.method_name;
|
|
698
|
+
const simpleCtorName = rawType?.replace(/<.*>$/, '').trim();
|
|
699
|
+
let t;
|
|
700
|
+
if (explicit) {
|
|
701
|
+
t = this.invokedConstructorType(call, rec);
|
|
702
|
+
}
|
|
703
|
+
else if (simpleCtorName) {
|
|
704
|
+
const member = this.memberTypeInScope(simpleCtorName, call.in_type, rec);
|
|
705
|
+
if (member?.type) {
|
|
706
|
+
t = member.type;
|
|
707
|
+
}
|
|
708
|
+
else {
|
|
709
|
+
const enclFqn = call.in_type != null && call.in_type !== ''
|
|
710
|
+
? [rec.pkg, ...call.in_type.split('.')].filter(Boolean).join('.')
|
|
711
|
+
: this.enclosingTypeOf(call, rec)?.fqn;
|
|
712
|
+
if (enclFqn) {
|
|
713
|
+
const owner = this.memberTypeOwner(enclFqn, simpleCtorName);
|
|
714
|
+
if (owner)
|
|
715
|
+
t = this.typesByFqn.get(`${owner}.${simpleCtorName}`);
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
if (!t)
|
|
719
|
+
t = this.resolveTypeRecord(rawType, rec);
|
|
720
|
+
}
|
|
721
|
+
else {
|
|
722
|
+
t = this.resolveTypeRecord(rawType, rec);
|
|
723
|
+
}
|
|
681
724
|
if (!t)
|
|
682
725
|
return undefined;
|
|
683
726
|
const result = {
|
|
684
727
|
target: `${t.fqn}.<init>`,
|
|
685
728
|
tier: 'exact',
|
|
686
|
-
evidence:
|
|
729
|
+
evidence: explicit
|
|
730
|
+
? `${call.method_name}(…) runs a constructor of ${t.fqn}, declared at ${t.file}:${t.startLine}`
|
|
731
|
+
: `object creation of ${t.fqn}, declared at ${t.file}:${t.startLine}`,
|
|
687
732
|
};
|
|
688
733
|
const ctors = this.declaredOverloads(t, '<init>').map(overload => ({ owner: t, overload }));
|
|
689
734
|
// A type with no declared constructor has the implicit one; a call that
|
|
@@ -802,7 +847,7 @@ export class NavigationIndex {
|
|
|
802
847
|
const C = P.filter(c => fit.get(c)[phase - 1] === 'yes');
|
|
803
848
|
if (C.length === 0)
|
|
804
849
|
return { kind: 'ambiguous', candidates: possible };
|
|
805
|
-
const best = C.find(m => P.every(o => o === m || this.moreSpecific(m, o, phase, self)));
|
|
850
|
+
const best = C.find(m => P.every(o => o === m || this.moreSpecific(m, o, phase, self, args)));
|
|
806
851
|
if (best) {
|
|
807
852
|
return {
|
|
808
853
|
kind: 'one',
|
|
@@ -837,15 +882,32 @@ export class NavigationIndex {
|
|
|
837
882
|
args.forEach((a, i) => meet(this.fits(a, i < params.length - 1 ? params[i] : elem, 2)));
|
|
838
883
|
return worst;
|
|
839
884
|
}
|
|
840
|
-
/**
|
|
841
|
-
|
|
885
|
+
/**
|
|
886
|
+
* `m` is more specific than `o`: each of its parameter types fits the other's.
|
|
887
|
+
*
|
|
888
|
+
* A reference parameter type of `m` that is the argument's own type also
|
|
889
|
+
* counts where it only possibly fits `o`'s: whenever `o` applies, the
|
|
890
|
+
* argument's type, which is `m`'s, is a subtype of `o`'s there, so in every
|
|
891
|
+
* case where `o` competes `m` is the more specific. That settles
|
|
892
|
+
* `this(ctx, copy, (String) null)` against a `ResultSet` overload when
|
|
893
|
+
* `copy`'s class has a supertype outside the tree. An argument of a
|
|
894
|
+
* narrower type than `m`'s parameter is not the same question and stays
|
|
895
|
+
* undecided.
|
|
896
|
+
*/
|
|
897
|
+
moreSpecific(m, o, phase, self, args) {
|
|
842
898
|
if (phase === 3)
|
|
843
899
|
return false;
|
|
844
900
|
const mp = this.paramRefsFrom(m, self);
|
|
845
901
|
const op = this.paramRefsFrom(o, self);
|
|
846
902
|
if (mp.length !== op.length)
|
|
847
903
|
return false;
|
|
848
|
-
return mp.every((t, i) =>
|
|
904
|
+
return mp.every((t, i) => {
|
|
905
|
+
const f = this.fits(t, op[i], 1);
|
|
906
|
+
if (f === 'yes')
|
|
907
|
+
return true;
|
|
908
|
+
const a = args?.[i];
|
|
909
|
+
return f === 'maybe' && !!a && isArgumentsOwnType(a, t);
|
|
910
|
+
});
|
|
849
911
|
}
|
|
850
912
|
/**
|
|
851
913
|
* Whether a value of type `a` can be passed as `p` — certainly, possibly,
|
|
@@ -1741,7 +1803,101 @@ export class NavigationIndex {
|
|
|
1741
1803
|
const fqn = this.resolveTypeName(name, rec);
|
|
1742
1804
|
return fqn ? this.typesByFqn.get(fqn) : undefined;
|
|
1743
1805
|
}
|
|
1744
|
-
|
|
1806
|
+
/**
|
|
1807
|
+
* The class an explicit constructor invocation constructs.
|
|
1808
|
+
*
|
|
1809
|
+
* `this(…)`: the enclosing type, which the extractor names exactly.
|
|
1810
|
+
*
|
|
1811
|
+
* `super(…)`: the superclass as written, resolved the way Java resolves a
|
|
1812
|
+
* name in the class's `extends` clause.
|
|
1813
|
+
*
|
|
1814
|
+
* 1. A member type of an enclosing type, innermost first: declared there or
|
|
1815
|
+
* inherited from a supertype in the tree. The class's own members are
|
|
1816
|
+
* not in scope in its own `extends` clause. A member type hides an
|
|
1817
|
+
* imported or same-package type with the same name.
|
|
1818
|
+
* 2. An exact name, an import, the same package.
|
|
1819
|
+
* 3. The extractor's qualified name. For an implicitly imported `java.lang`
|
|
1820
|
+
* type it is outside the tree, so `extends Exception` stays
|
|
1821
|
+
* `java.lang.Exception` even when some package in the tree declares an
|
|
1822
|
+
* `Exception`.
|
|
1823
|
+
* 4. A type one of the file's wildcard imports names (`import a.b.*`, or
|
|
1824
|
+
* `import a.Outer.*` for its member types), when exactly one does.
|
|
1825
|
+
*
|
|
1826
|
+
* Anything else is left unbound. A type nested somewhere else in the file
|
|
1827
|
+
* is not in scope. A type of the same simple name elsewhere in the tree
|
|
1828
|
+
* that no import names may not be the one meant: the name can come from a
|
|
1829
|
+
* wildcard package outside the tree, from `java.lang`, or from a supertype
|
|
1830
|
+
* outside the tree.
|
|
1831
|
+
*/
|
|
1832
|
+
invokedConstructorType(call, rec) {
|
|
1833
|
+
const name = call.receiver_type?.replace(/<.*>$/, '').trim();
|
|
1834
|
+
if (!name)
|
|
1835
|
+
return undefined;
|
|
1836
|
+
if (call.method_name === 'this') {
|
|
1837
|
+
return call.receiver_type_fqn ? this.typesByFqn.get(call.receiver_type_fqn) : this.resolveTypeRecord(name, rec);
|
|
1838
|
+
}
|
|
1839
|
+
const member = this.memberTypeInScope(name, call.in_type, rec);
|
|
1840
|
+
if (member)
|
|
1841
|
+
return member.type;
|
|
1842
|
+
const scoped = this.resolveTypeName(name, rec, false);
|
|
1843
|
+
if (scoped)
|
|
1844
|
+
return this.typesByFqn.get(scoped);
|
|
1845
|
+
if (call.receiver_type_fqn)
|
|
1846
|
+
return this.typesByFqn.get(call.receiver_type_fqn);
|
|
1847
|
+
const viaWildcard = [...new Set(rec.staticWildcards)].map(w => this.typesByFqn.get(`${w}.${name}`)).filter((t) => t !== undefined);
|
|
1848
|
+
return viaWildcard.length === 1 ? viaWildcard[0] : undefined;
|
|
1849
|
+
}
|
|
1850
|
+
/**
|
|
1851
|
+
* `name` (`Node`, or `Node.Leaf`) as a member type in scope inside the type
|
|
1852
|
+
* at nesting path `inType` (`Tree.Leaf`) of this file. The types enclosing
|
|
1853
|
+
* it are searched innermost first, the type itself excluded. Each is
|
|
1854
|
+
* searched with its supertypes in the tree, so an inherited member type
|
|
1855
|
+
* counts. Present when the first part of `name` is such a member;
|
|
1856
|
+
* `type` is then the declaration, or undefined when the rest of `name` is
|
|
1857
|
+
* not in the tree. Absent when no enclosing type has that member.
|
|
1858
|
+
*/
|
|
1859
|
+
memberTypeInScope(name, inType, rec) {
|
|
1860
|
+
if (!inType)
|
|
1861
|
+
return undefined;
|
|
1862
|
+
const dot = name.indexOf('.');
|
|
1863
|
+
const head = dot < 0 ? name : name.slice(0, dot);
|
|
1864
|
+
const rest = dot < 0 ? '' : name.slice(dot);
|
|
1865
|
+
const path = inType.split('.');
|
|
1866
|
+
for (let k = path.length - 1; k >= 1; k--) {
|
|
1867
|
+
const enclosing = [rec.pkg, ...path.slice(0, k)].filter(Boolean).join('.');
|
|
1868
|
+
const owner = this.memberTypeOwner(enclosing, head);
|
|
1869
|
+
if (owner)
|
|
1870
|
+
return { type: this.typesByFqn.get(`${owner}.${head}${rest}`) };
|
|
1871
|
+
}
|
|
1872
|
+
return undefined;
|
|
1873
|
+
}
|
|
1874
|
+
/** `fqn`, or the nearest of its supertypes in the tree, that has a member type `name`. */
|
|
1875
|
+
memberTypeOwner(fqn, name) {
|
|
1876
|
+
const seen = new Set();
|
|
1877
|
+
const queue = [fqn];
|
|
1878
|
+
while (queue.length > 0) {
|
|
1879
|
+
const f = queue.shift();
|
|
1880
|
+
if (seen.has(f))
|
|
1881
|
+
continue;
|
|
1882
|
+
seen.add(f);
|
|
1883
|
+
if (this.typesByFqn.has(`${f}.${name}`))
|
|
1884
|
+
return f;
|
|
1885
|
+
const t = this.typesByFqn.get(f);
|
|
1886
|
+
const frec = t ? this.files.get(t.file) : undefined;
|
|
1887
|
+
for (const sup of t?.superNames ?? []) {
|
|
1888
|
+
const supFqn = frec ? this.resolveTypeName(sup, frec) : undefined;
|
|
1889
|
+
if (supFqn)
|
|
1890
|
+
queue.push(supFqn);
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1893
|
+
return undefined;
|
|
1894
|
+
}
|
|
1895
|
+
/**
|
|
1896
|
+
* `anywhere`: also a type nested in a type of this file, then a simple name
|
|
1897
|
+
* declared once in the whole tree. Off, only an exact name, an import and
|
|
1898
|
+
* the same package.
|
|
1899
|
+
*/
|
|
1900
|
+
resolveTypeName(name, rec, anywhere = true) {
|
|
1745
1901
|
const bare = name.replace(/<.*>$/, '').replace(/\[\]$/, '').trim();
|
|
1746
1902
|
if (!bare)
|
|
1747
1903
|
return undefined;
|
|
@@ -1750,10 +1906,12 @@ export class NavigationIndex {
|
|
|
1750
1906
|
const imported = rec.imports.get(bare);
|
|
1751
1907
|
if (imported && this.typesByFqn.has(imported))
|
|
1752
1908
|
return imported;
|
|
1753
|
-
// Same package
|
|
1909
|
+
// Same package (a qualified `Outer.Inner` of the package included).
|
|
1754
1910
|
const samePkg = rec.pkg ? `${rec.pkg}.${bare}` : bare;
|
|
1755
1911
|
if (this.typesByFqn.has(samePkg))
|
|
1756
1912
|
return samePkg;
|
|
1913
|
+
if (!anywhere)
|
|
1914
|
+
return undefined;
|
|
1757
1915
|
for (const t of rec.types) {
|
|
1758
1916
|
const nested = `${t.fqn}.${bare}`;
|
|
1759
1917
|
if (this.typesByFqn.has(nested))
|
|
@@ -1954,6 +2112,18 @@ export class NavigationIndex {
|
|
|
1954
2112
|
}
|
|
1955
2113
|
}
|
|
1956
2114
|
// ------------------------------------------------------------------ helpers
|
|
2115
|
+
/**
|
|
2116
|
+
* `p` is exactly the argument's type `a`: the same resolved reference type,
|
|
2117
|
+
* array depth included, with no type variable on either side.
|
|
2118
|
+
*/
|
|
2119
|
+
function isArgumentsOwnType(a, p) {
|
|
2120
|
+
return !a.prim && !p.prim && !a.typeVar && !p.typeVar && !p.opaque && !a.inferred
|
|
2121
|
+
&& a.fqn !== null && a.fqn === p.fqn && a.dims === p.dims;
|
|
2122
|
+
}
|
|
2123
|
+
/** `super(…)` / `this(…)` as the extractor writes it: a constructor call named by the keyword. */
|
|
2124
|
+
function isExplicitConstructorInvocation(call) {
|
|
2125
|
+
return call.is_constructor === true && (call.method_name === 'super' || call.method_name === 'this');
|
|
2126
|
+
}
|
|
1957
2127
|
function buildFileRecord(f) {
|
|
1958
2128
|
const pkg = f.ir.meta?.package ?? '';
|
|
1959
2129
|
const imports = new Map();
|