@shapeshift-labs/frontier-lang-compiler 0.2.99 → 0.2.100
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/declarations/semantic-edit-bundle.d.ts +13 -1
- package/dist/declarations/semantic-edit-script.d.ts +34 -37
- package/dist/declarations/semantic-lineage.d.ts +63 -34
- package/dist/declarations/semantic-patch-bundle.d.ts +13 -0
- package/dist/internal/index-impl/declarationRecord.js +2 -2
- package/dist/internal/index-impl/inferSemanticLineageEvents.js +8 -0
- package/dist/internal/index-impl/projectSemanticEditScriptToSource.js +56 -64
- package/dist/internal/index-impl/replaySemanticEditProjection.js +54 -22
- package/dist/internal/index-impl/semanticEditBundleAdmission.js +95 -12
- package/dist/internal/index-impl/semanticEditBundleIndex.js +16 -10
- package/dist/internal/index-impl/semanticEditSourceRanges.js +204 -0
- package/dist/internal/index-impl/semanticHistoryLineageResolution.js +35 -1
- package/dist/internal/index-impl/semanticIndexFromNativeDeclarations.js +2 -2
- package/dist/internal/index-impl/semanticLineageInferenceMatching.js +150 -13
- package/dist/internal/index-impl/semanticLineageResolutionRecords.js +28 -1
- package/dist/internal/index-impl/semanticPatchBundleAdmission.js +122 -20
- package/dist/internal/index-impl/semanticPatchBundleLineageLinks.js +199 -0
- package/dist/internal/index-impl/semanticPatchBundleOverlaps.js +6 -2
- package/dist/internal/index-impl/semanticPatchBundleRecords.js +28 -104
- package/dist/internal/index-impl/semanticPatchBundleSourceRecords.js +127 -0
- package/dist/internal/index-impl/sourceTextForSpan.js +4 -9
- package/dist/lightweight-dependency-relations.js +113 -7
- package/dist/native-import-utils.js +15 -1
- package/dist/native-region-scanner-js-helpers.js +61 -17
- package/dist/native-region-scanner-js.js +12 -4
- package/dist/semantic-import-regions.js +3 -3
- package/package.json +1 -1
|
@@ -68,12 +68,14 @@ function addIdentifierTarget(map, identifier, target) {
|
|
|
68
68
|
|
|
69
69
|
function scanDeclarationDependencies(input, documentId, scan, identifiers, lines, records) {
|
|
70
70
|
const state = { inBlockComment: false };
|
|
71
|
+
const factState = { braceDepth: 0, pendingSwitch: false, switchDepth: 0 };
|
|
71
72
|
for (let lineNumber = scan.startLine; lineNumber <= scan.endLine; lineNumber += 1) {
|
|
72
73
|
const scanLine = maskDependencyLine(input, lines[lineNumber - 1]?.line ?? '', state);
|
|
73
|
-
addLightweightSemanticFacts(input, documentId, scan.declaration, scanLine, lineNumber, records);
|
|
74
|
+
addLightweightSemanticFacts(input, documentId, scan.declaration, scanLine, lineNumber, records, factState);
|
|
74
75
|
for (const match of scanLine.matchAll(/[A-Za-z_$][\w$]*/g)) {
|
|
75
76
|
const name = match[0];
|
|
76
77
|
if (!isDependencyIdentifier(name) || !identifiers.has(name)) continue;
|
|
78
|
+
if (isIgnoredDependencyOccurrence(input, scanLine, match.index, name)) continue;
|
|
77
79
|
const targets = identifiers.get(name).filter((target) => target.symbolId !== scan.declaration.symbolId);
|
|
78
80
|
for (const target of targets) {
|
|
79
81
|
addDependencyRecord(input, documentId, scan.declaration, target, {
|
|
@@ -87,10 +89,11 @@ function scanDeclarationDependencies(input, documentId, scan, identifiers, lines
|
|
|
87
89
|
}
|
|
88
90
|
}
|
|
89
91
|
|
|
90
|
-
function addLightweightSemanticFacts(input, documentId, declaration, line, lineNumber, records) {
|
|
92
|
+
function addLightweightSemanticFacts(input, documentId, declaration, line, lineNumber, records, factState) {
|
|
93
|
+
if (!shouldScanRuntimeFacts(input, declaration)) return;
|
|
91
94
|
const text = String(line ?? '').trim();
|
|
92
95
|
if (!text) return;
|
|
93
|
-
for (const item of lightweightControlFlowKinds(text)) {
|
|
96
|
+
for (const item of lightweightControlFlowKinds(text, factState)) {
|
|
94
97
|
addFactRecord(input, documentId, declaration, 'controlFlow', item, lineNumber, records);
|
|
95
98
|
}
|
|
96
99
|
for (const item of lightweightEffectKinds(text)) {
|
|
@@ -99,11 +102,45 @@ function addLightweightSemanticFacts(input, documentId, declaration, line, lineN
|
|
|
99
102
|
for (const item of lightweightMutationKinds(text)) {
|
|
100
103
|
addFactRecord(input, documentId, declaration, 'mutation', item, lineNumber, records);
|
|
101
104
|
}
|
|
105
|
+
updateLightweightFactState(text, factState);
|
|
102
106
|
}
|
|
103
107
|
|
|
104
|
-
function
|
|
108
|
+
function shouldScanRuntimeFacts(input, declaration) {
|
|
109
|
+
if (!isJavaScriptLike(input)) return true;
|
|
110
|
+
if (declaration?.fields?.typeKind) return false;
|
|
111
|
+
if (/^Type(?:Alias|Method|Property|FunctionProperty)/.test(String(declaration?.kind ?? ''))) return false;
|
|
112
|
+
return !['interface', 'type'].includes(String(declaration?.symbolKind ?? '').toLowerCase());
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function isJavaScriptLike(input) {
|
|
116
|
+
return ['javascript', 'typescript'].includes(String(input?.language ?? '').toLowerCase());
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function isIgnoredDependencyOccurrence(input, line, startIndex, name) {
|
|
120
|
+
if (!isJavaScriptLike(input)) return false;
|
|
121
|
+
const endIndex = startIndex + String(name).length;
|
|
122
|
+
const previous = previousNonSpace(line, startIndex - 1);
|
|
123
|
+
const next = nextNonSpace(line, endIndex);
|
|
124
|
+
return previous === '.' || next === ':';
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function previousNonSpace(line, index) {
|
|
128
|
+
for (let cursor = index; cursor >= 0; cursor -= 1) {
|
|
129
|
+
if (!/\s/.test(line[cursor])) return line[cursor];
|
|
130
|
+
}
|
|
131
|
+
return '';
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function nextNonSpace(line, index) {
|
|
135
|
+
for (let cursor = index; cursor < line.length; cursor += 1) {
|
|
136
|
+
if (!/\s/.test(line[cursor])) return line[cursor];
|
|
137
|
+
}
|
|
138
|
+
return '';
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function lightweightControlFlowKinds(line, state = {}) {
|
|
105
142
|
const kinds = [];
|
|
106
|
-
if (
|
|
143
|
+
if (hasBranchSyntax(line, state)) kinds.push('branch');
|
|
107
144
|
if (/\b(for|while|do)\b/.test(line)) kinds.push('loop');
|
|
108
145
|
if (/\b(return|yield)\b/.test(line)) kinds.push('exit');
|
|
109
146
|
if (/\b(throw|catch|finally|try)\b/.test(line)) kinds.push('exception');
|
|
@@ -114,7 +151,7 @@ function lightweightControlFlowKinds(line) {
|
|
|
114
151
|
function lightweightEffectKinds(line) {
|
|
115
152
|
const kinds = [];
|
|
116
153
|
if (/\bawait\b|import\s*\(/.test(line)) kinds.push('async');
|
|
117
|
-
if (
|
|
154
|
+
if (hasGlobalNetworkCall(line)) kinds.push('network');
|
|
118
155
|
if (/\b(localStorage|sessionStorage|indexedDB|caches|cookie)\b/.test(line)) kinds.push('storage');
|
|
119
156
|
if (/\b(setTimeout|setInterval|requestAnimationFrame|queueMicrotask)\s*\(/.test(line)) kinds.push('scheduler');
|
|
120
157
|
if (/\b(console|process|Deno|Bun)\s*\./.test(line)) kinds.push('host');
|
|
@@ -125,12 +162,81 @@ function lightweightEffectKinds(line) {
|
|
|
125
162
|
function lightweightMutationKinds(line) {
|
|
126
163
|
const kinds = [];
|
|
127
164
|
if (/\bdelete\s+[A-Za-z_$][\w$.[\]]*/.test(line)) kinds.push('delete');
|
|
128
|
-
if (
|
|
165
|
+
if (hasRuntimeAssignment(line)) kinds.push('assignment');
|
|
129
166
|
if (/\+\+|--|(?:\+=|-=|\*=|\/=|%=|\|\|=|&&=|\?\?=)/.test(line)) kinds.push('update');
|
|
130
167
|
if (/\.(?:push|pop|shift|unshift|splice|sort|reverse|set|add|delete|clear)\s*\(/.test(line)) kinds.push('mutating-call');
|
|
131
168
|
return kinds;
|
|
132
169
|
}
|
|
133
170
|
|
|
171
|
+
function hasBranchSyntax(line, state) {
|
|
172
|
+
return /\bif\s*\(/.test(line)
|
|
173
|
+
|| /(?:^|[}\s;])else\b(?:\s+if\s*\(|\s*[{;]|$)/.test(line)
|
|
174
|
+
|| /\bswitch\s*\(/.test(line)
|
|
175
|
+
|| ((state?.switchDepth ?? 0) > 0 && /^\s*(?:case\b[^:]*|default)\s*:/.test(line));
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function updateLightweightFactState(line, state = {}) {
|
|
179
|
+
const hadSwitch = /\bswitch\s*\(/.test(line);
|
|
180
|
+
const beforeDepth = state.braceDepth ?? 0;
|
|
181
|
+
const delta = blockBraceDelta(line);
|
|
182
|
+
if (hadSwitch) state.pendingSwitch = true;
|
|
183
|
+
state.braceDepth = Math.max(0, beforeDepth + delta);
|
|
184
|
+
if (state.pendingSwitch && state.braceDepth > beforeDepth) {
|
|
185
|
+
state.switchDepth = state.braceDepth;
|
|
186
|
+
state.pendingSwitch = false;
|
|
187
|
+
}
|
|
188
|
+
if ((state.switchDepth ?? 0) > 0 && state.braceDepth < state.switchDepth) {
|
|
189
|
+
state.switchDepth = 0;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function blockBraceDelta(line) {
|
|
194
|
+
let delta = 0;
|
|
195
|
+
for (const char of String(line ?? '')) {
|
|
196
|
+
if (char === '{') delta += 1;
|
|
197
|
+
else if (char === '}') delta -= 1;
|
|
198
|
+
}
|
|
199
|
+
return delta;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function hasGlobalNetworkCall(line) {
|
|
203
|
+
return hasBareCall(line, ['fetch', 'XMLHttpRequest', 'WebSocket', 'EventSource'])
|
|
204
|
+
|| hasGlobalPropertyCall(line, ['fetch', 'XMLHttpRequest', 'WebSocket', 'EventSource']);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function hasBareCall(line, names) {
|
|
208
|
+
return names.some((name) => new RegExp(`(?:^|[^\\w$.])${name}\\s*\\(`).test(line));
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function hasGlobalPropertyCall(line, names) {
|
|
212
|
+
return names.some((name) => new RegExp(`\\b(?:window|globalThis|self)\\s*\\.\\s*${name}\\s*\\(`).test(line));
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function hasRuntimeAssignment(line) {
|
|
216
|
+
const text = String(line ?? '');
|
|
217
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
218
|
+
if (text[index] !== '=' || !isPlainAssignmentOperator(text, index)) continue;
|
|
219
|
+
if (!isLocalDeclarationInitializer(text, index)) return true;
|
|
220
|
+
}
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function isPlainAssignmentOperator(text, index) {
|
|
225
|
+
const previous = text[index - 1] ?? '';
|
|
226
|
+
const next = text[index + 1] ?? '';
|
|
227
|
+
if (next === '=' || next === '>') return false;
|
|
228
|
+
return !['=', '!', '<', '>', '+', '-', '*', '/', '%', '&', '|', '?', '^'].includes(previous);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function isLocalDeclarationInitializer(text, index) {
|
|
232
|
+
const prefix = text.slice(0, index);
|
|
233
|
+
const statementStart = Math.max(prefix.lastIndexOf(';'), prefix.lastIndexOf('{'), prefix.lastIndexOf('}'));
|
|
234
|
+
const statement = prefix.slice(statementStart + 1).trim();
|
|
235
|
+
return /^(?:export\s+)?(?:declare\s+)?(?:const|let|var|using)\b/.test(statement)
|
|
236
|
+
|| /^for\s*\([^;)]*(?:const|let|var)\b/.test(statement)
|
|
237
|
+
|| /^(?:export\s+)?type\s+[A-Za-z_$][\w$]*(?:\s*<[^>]+>)?\s*$/.test(statement);
|
|
238
|
+
}
|
|
239
|
+
|
|
134
240
|
function addFactRecord(input, documentId, declaration, predicate, factKind, lineNumber, records) {
|
|
135
241
|
const key = `${declaration.symbolId}|${predicate}|${factKind}|${lineNumber}`;
|
|
136
242
|
if (records.seen.has(key)) return;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export function uniqueStrings(values) {
|
|
2
|
-
return [...new Set((values ?? []).map((value) => String(value)).filter(Boolean))];
|
|
2
|
+
return [...new Set((values ?? []).filter((value) => value !== undefined && value !== null).map((value) => String(value)).filter(Boolean))];
|
|
3
3
|
}
|
|
4
4
|
|
|
5
5
|
export function uniqueRecordsById(records) {
|
|
@@ -141,3 +141,17 @@ export function idFragment(value) {
|
|
|
141
141
|
.replace(/^_+|_+$/g, '')
|
|
142
142
|
.slice(0, 80) || 'native';
|
|
143
143
|
}
|
|
144
|
+
|
|
145
|
+
export function caseSensitiveIdFragment(value) {
|
|
146
|
+
const text = String(value ?? 'native');
|
|
147
|
+
return `${idFragment(text)}_${caseSensitiveHash(text)}`;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function caseSensitiveHash(value) {
|
|
151
|
+
let hash = 0x811c9dc5;
|
|
152
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
153
|
+
hash ^= value.charCodeAt(index);
|
|
154
|
+
hash = Math.imul(hash, 0x01000193);
|
|
155
|
+
}
|
|
156
|
+
return (hash >>> 0).toString(36);
|
|
157
|
+
}
|
|
@@ -121,10 +121,64 @@ function jsRegionKindForDeclarationName(name, source = '') {
|
|
|
121
121
|
function jsExportedContainerDeclaration(input, lineNumber, trimmed) {
|
|
122
122
|
let match = trimmed.match(/^export\s+default\s+(.+)$/);
|
|
123
123
|
if (match) return jsContainerExport(input, lineNumber, 'ExportDefaultContainer', 'default', match[1], { exportDefault: true });
|
|
124
|
-
match = trimmed.match(/^(
|
|
124
|
+
match = trimmed.match(/^(module\.exports|exports)(?:\.([A-Za-z_$][\w$]*))?\s*=\s*(.+)$/);
|
|
125
125
|
if (!match) return undefined;
|
|
126
|
-
const name = match[
|
|
127
|
-
return jsContainerExport(input, lineNumber, 'CommonJsContainerExport', name, match[
|
|
126
|
+
const name = match[2] ? `${match[1]}.${match[2]}` : 'module.exports';
|
|
127
|
+
return jsContainerExport(input, lineNumber, 'CommonJsContainerExport', name, match[3], { export: 'commonjs' });
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function jsExportedFunctionWrapperDeclaration(input, lineNumber, trimmed) {
|
|
131
|
+
const match = trimmed.match(/^export\s+default\s+((?:React\.)?(?:forwardRef|memo|lazy|observer))\s*(?:<[^>]+>)?\s*\(\s*(.+)$/);
|
|
132
|
+
if (!match) return undefined;
|
|
133
|
+
const wrapper = match[1];
|
|
134
|
+
const argument = match[2].trim();
|
|
135
|
+
let functionMatch = argument.match(/^(?:async\s+)?function\*?\s*([A-Za-z_$][\w$]*)?\s*(?:<[^({;]+>)?\s*\(([^)]*)\)/);
|
|
136
|
+
if (functionMatch) {
|
|
137
|
+
return nativeDeclaration(input, lineNumber, 'ExportDefaultFunctionWrapperDeclaration', 'function', functionMatch[1] ?? 'default', {
|
|
138
|
+
exportDefault: true,
|
|
139
|
+
wrapper,
|
|
140
|
+
parameters: splitParameters(functionMatch[2])
|
|
141
|
+
}, true);
|
|
142
|
+
}
|
|
143
|
+
functionMatch = argument.match(/^(?:async\s*)?(?:\(([^)]*)\)|([A-Za-z_$][\w$]*))\s*(?::\s*[^=]+)?=>/);
|
|
144
|
+
if (functionMatch) {
|
|
145
|
+
return nativeDeclaration(input, lineNumber, 'ExportDefaultFunctionWrapperDeclaration', 'function', 'default', {
|
|
146
|
+
exportDefault: true,
|
|
147
|
+
wrapper,
|
|
148
|
+
parameters: splitParameters(functionMatch[1] ?? functionMatch[2])
|
|
149
|
+
}, true);
|
|
150
|
+
}
|
|
151
|
+
const aliasMatch = argument.match(/^([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*(?:[,)]|$)/);
|
|
152
|
+
if (!aliasMatch) return undefined;
|
|
153
|
+
return nativeDeclaration(input, lineNumber, 'ExportDefaultWrappedAlias', 'variable', 'default', {
|
|
154
|
+
exportDefault: true,
|
|
155
|
+
wrapper,
|
|
156
|
+
alias: aliasMatch[1],
|
|
157
|
+
initializerKind: 'function-wrapper'
|
|
158
|
+
}, false, {
|
|
159
|
+
metadata: { exportDefault: true, wrapper, alias: aliasMatch[1], initializerKind: 'function-wrapper' }
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function jsExportAliasDeclaration(input, lineNumber, trimmed) {
|
|
164
|
+
let match = trimmed.match(/^export\s+default\s+([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*;?$/);
|
|
165
|
+
if (match) return jsAliasExport(input, lineNumber, 'ExportDefaultAlias', 'default', match[1], { exportDefault: true }, trimmed);
|
|
166
|
+
match = trimmed.match(/^module\.exports\s*=\s*([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*;?$/);
|
|
167
|
+
if (match) return jsAliasExport(input, lineNumber, 'CommonJsAliasExport', 'module.exports', match[1], { export: 'commonjs' }, trimmed);
|
|
168
|
+
match = trimmed.match(/^(?:module\.)?exports\.([A-Za-z_$][\w$]*)\s*=\s*([A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*)\s*;?$/);
|
|
169
|
+
if (!match) return undefined;
|
|
170
|
+
return jsAliasExport(input, lineNumber, 'CommonJsAliasExport', match[1], match[2], { export: 'commonjs' }, trimmed);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function jsAliasExport(input, lineNumber, languageKind, name, alias, fields, source) {
|
|
174
|
+
const regionKind = jsRegionKindForDeclarationName(name, source);
|
|
175
|
+
return nativeDeclaration(input, lineNumber, languageKind, 'variable', name, {
|
|
176
|
+
...fields,
|
|
177
|
+
alias
|
|
178
|
+
}, false, {
|
|
179
|
+
regionKind,
|
|
180
|
+
metadata: { ...fields, alias }
|
|
181
|
+
});
|
|
128
182
|
}
|
|
129
183
|
|
|
130
184
|
function jsContainerExport(input, lineNumber, languageKind, name, initializer, fields) {
|
|
@@ -254,17 +308,7 @@ function findUnescapedBacktick(text, startIndex) {
|
|
|
254
308
|
return -1;
|
|
255
309
|
}
|
|
256
310
|
|
|
257
|
-
export {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
jsExportedContainerDeclaration,
|
|
262
|
-
jsInitializerKind,
|
|
263
|
-
jsImportDeclarations,
|
|
264
|
-
jsObjectPropertyDeclaration,
|
|
265
|
-
jsObjectRegionContext,
|
|
266
|
-
jsRegionKindForDeclarationName,
|
|
267
|
-
jsRouteRecordDeclaration,
|
|
268
|
-
jsVariableHasBody,
|
|
269
|
-
jsVariableSymbolKind
|
|
270
|
-
};
|
|
311
|
+
export { jsCommentOnlyLine, jsContainerDelta, jsDeclarationScanLine };
|
|
312
|
+
export { jsExportAliasDeclaration, jsExportedContainerDeclaration, jsExportedFunctionWrapperDeclaration };
|
|
313
|
+
export { jsInitializerKind, jsImportDeclarations, jsObjectPropertyDeclaration, jsObjectRegionContext };
|
|
314
|
+
export { jsRegionKindForDeclarationName, jsRouteRecordDeclaration, jsVariableHasBody, jsVariableSymbolKind };
|
|
@@ -10,7 +10,9 @@ import {
|
|
|
10
10
|
jsCommentOnlyLine,
|
|
11
11
|
jsContainerDelta,
|
|
12
12
|
jsDeclarationScanLine,
|
|
13
|
+
jsExportAliasDeclaration,
|
|
13
14
|
jsExportedContainerDeclaration,
|
|
15
|
+
jsExportedFunctionWrapperDeclaration,
|
|
14
16
|
jsInitializerKind,
|
|
15
17
|
jsImportDeclarations,
|
|
16
18
|
jsObjectPropertyDeclaration,
|
|
@@ -75,11 +77,13 @@ function scanJavaScriptLike(input) {
|
|
|
75
77
|
pushDeclaration(nativeDeclaration(input, number, 'FunctionDeclaration', 'function', match[1], { parameters: splitParameters(match[2]) }, declarationLine.includes('{')));
|
|
76
78
|
} else if ((match = trimmed.match(/^export\s+default\s+(?:async\s+)?function\*?\s*([A-Za-z_$][\w$]*)?\s*(?:<[^({;]+>)?\s*\(([^)]*)\)\s*(?::\s*[^={]+)?/))) {
|
|
77
79
|
pushDeclaration(nativeDeclaration(input, number, 'ExportDefaultFunctionDeclaration', 'function', match[1] ?? 'default', { parameters: splitParameters(match[2]), exportDefault: true }, trimmed.includes('{')));
|
|
78
|
-
} else if ((match = declarationLine.match(/^(
|
|
79
|
-
|
|
80
|
-
|
|
80
|
+
} else if ((match = declarationLine.match(/^(default\s+)?(?:abstract\s+)?class\b(?:\s+(?!(?:extends|implements)\b)([A-Za-z_$][\w$]*))?/)) && (match[1] || match[2])) {
|
|
81
|
+
const className = match[2] ?? 'default';
|
|
82
|
+
const exportDefault = Boolean(match[1]);
|
|
83
|
+
pushDeclaration(nativeDeclaration(input, number, exportDefault ? 'ExportDefaultClassDeclaration' : 'ClassDeclaration', 'class', className, { exportDefault: exportDefault || undefined }, declarationLine.includes('{')));
|
|
84
|
+
pushDeclarations(jsInlineClassMemberDeclarations(input, number, declarationLine, className));
|
|
81
85
|
if (jsStructureDelta(declarationLine).value > 0) {
|
|
82
|
-
currentClass =
|
|
86
|
+
currentClass = className;
|
|
83
87
|
classDepth = 0;
|
|
84
88
|
}
|
|
85
89
|
} else if ((match = declarationLine.match(/^interface\s+([A-Za-z_$][\w$]*)/))) {
|
|
@@ -109,10 +113,14 @@ function scanJavaScriptLike(input) {
|
|
|
109
113
|
pushDeclarations(jsInlineNestedObjectDeclarations(input, number, declarationLine, declarations[declarations.length - 1]));
|
|
110
114
|
const objectContext = jsObjectRegionContext(match[1], declarationLine, number, regionKind);
|
|
111
115
|
if (objectContext) objectStack.push(objectContext);
|
|
116
|
+
} else if ((match = jsExportedFunctionWrapperDeclaration(input, number, trimmed))) {
|
|
117
|
+
pushDeclaration(match);
|
|
112
118
|
} else if ((match = jsExportedContainerDeclaration(input, number, trimmed))) {
|
|
113
119
|
pushDeclaration(match.declaration);
|
|
114
120
|
pushDeclarations(jsInlineNestedObjectDeclarations(input, number, trimmed, match.declaration));
|
|
115
121
|
if (match.context) objectStack.push(match.context);
|
|
122
|
+
} else if ((match = jsExportAliasDeclaration(input, number, trimmed))) {
|
|
123
|
+
pushDeclaration(match);
|
|
116
124
|
} else if ((match = trimmed.match(/^(?:module\.)?exports\.([A-Za-z_$][\w$]*)\s*=\s*(?:async\s+)?function\*?\s*\(([^)]*)\)/))) {
|
|
117
125
|
pushDeclaration(nativeDeclaration(input, number, 'CommonJsFunctionExport', 'function', match[1], { parameters: splitParameters(match[2]) }, true));
|
|
118
126
|
} else if ((match = trimmed.match(/^(?:module\.)?exports\.([A-Za-z_$][\w$]*)\s*=/))) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { idFragment, uniqueStrings } from './native-import-utils.js';
|
|
1
|
+
import { caseSensitiveIdFragment, idFragment, uniqueStrings } from './native-import-utils.js';
|
|
2
2
|
|
|
3
3
|
const NativeImportRegionTaxonomyKinds = Object.freeze([
|
|
4
4
|
'symbol',
|
|
@@ -27,7 +27,7 @@ function semanticOwnershipRegionForSymbol(imported, symbol, mapping, nativeNode,
|
|
|
27
27
|
symbol.name ?? symbol.id
|
|
28
28
|
].map((part) => String(part).replace(/\s+/g, ' ').trim()).join('#');
|
|
29
29
|
return {
|
|
30
|
-
id: `region_${
|
|
30
|
+
id: `region_${caseSensitiveIdFragment(key)}`,
|
|
31
31
|
key,
|
|
32
32
|
regionKind,
|
|
33
33
|
granularity: 'symbol',
|
|
@@ -54,7 +54,7 @@ function semanticOwnershipRegionForDeclaration(input, declaration, documentId) {
|
|
|
54
54
|
const regionKind = semanticRegionKindForDeclaration(declaration);
|
|
55
55
|
const key = ['source', sourcePath, regionKind, name].map((part) => String(part).replace(/\s+/g, ' ').trim()).join('#');
|
|
56
56
|
return {
|
|
57
|
-
id: `region_${
|
|
57
|
+
id: `region_${caseSensitiveIdFragment(key)}`,
|
|
58
58
|
key,
|
|
59
59
|
regionKind,
|
|
60
60
|
granularity: 'symbol',
|
package/package.json
CHANGED