chrome-devtools-frontend 1.0.1014346 → 1.0.1014853
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/.eslintignore +1 -0
- package/front_end/core/sdk/SourceMap.ts +88 -27
- package/front_end/models/javascript_metadata/DOMPinnedProperties.ts +3322 -833
- package/front_end/models/source_map_scopes/NamesResolver.ts +88 -19
- package/package.json +1 -1
- package/scripts/webidl-properties/config.js +305 -239
- package/scripts/webidl-properties/get-props.js +23 -12
- package/scripts/webidl-properties/index.js +14 -9
- package/scripts/webidl-properties/tests.js +58 -14
@@ -174,6 +174,15 @@ export const scopeIdentifiers = async function(
|
|
174
174
|
}
|
175
175
|
};
|
176
176
|
|
177
|
+
const identifierAndPunctuationRegExp = /^\s*([A-Za-z_$][A-Za-z_$0-9]*)\s*([.;,]?)\s*$/;
|
178
|
+
|
179
|
+
const enum Punctuation {
|
180
|
+
None = 0,
|
181
|
+
Comma = 1,
|
182
|
+
Dot = 2,
|
183
|
+
Semicolon = 3,
|
184
|
+
}
|
185
|
+
|
177
186
|
const resolveScope =
|
178
187
|
async(scope: SDK.DebuggerModel
|
179
188
|
.ScopeChainEntry): Promise<{variableMapping: Map<string, string>, thisMapping: string | null}> => {
|
@@ -182,8 +191,6 @@ const resolveScope =
|
|
182
191
|
const sourceMap = Bindings.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().sourceMapForScript(script);
|
183
192
|
|
184
193
|
if (!cachedScopeMap || cachedScopeMap.sourceMap !== sourceMap) {
|
185
|
-
// TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration)
|
186
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
187
194
|
// TODO(crbug.com/1172300) Ignored during the jsdoc to ts migration)
|
188
195
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
189
196
|
const identifiersPromise =
|
@@ -260,33 +267,95 @@ const resolveScope =
|
|
260
267
|
script: SDK.Script.Script, sourceMap: SDK.SourceMap.SourceMap, name: string,
|
261
268
|
position: {lineNumber: number, columnNumber: number},
|
262
269
|
textCache: Map<string, TextUtils.Text.Text>): Promise<string|null> {
|
263
|
-
const
|
264
|
-
|
265
|
-
if (!startEntry || !endEntry || !startEntry.sourceURL || startEntry.sourceURL !== endEntry.sourceURL ||
|
266
|
-
!startEntry.sourceLineNumber || !startEntry.sourceColumnNumber || !endEntry.sourceLineNumber ||
|
267
|
-
!endEntry.sourceColumnNumber) {
|
270
|
+
const ranges = sourceMap.findEntryRanges(position.lineNumber, position.columnNumber);
|
271
|
+
if (!ranges) {
|
268
272
|
return null;
|
269
273
|
}
|
270
|
-
|
271
|
-
|
272
|
-
endEntry.sourceColumnNumber);
|
274
|
+
// Extract the underlying text from the compiled code's range and make sure that
|
275
|
+
// it starts with the identifier |name|.
|
273
276
|
const uiSourceCode =
|
274
277
|
Bindings.DebuggerWorkspaceBinding.DebuggerWorkspaceBinding.instance().uiSourceCodeForSourceMapSourceURL(
|
275
|
-
script.debuggerModel,
|
278
|
+
script.debuggerModel, ranges.sourceURL, script.isContentScript());
|
276
279
|
if (!uiSourceCode) {
|
277
280
|
return null;
|
278
281
|
}
|
279
|
-
const
|
280
|
-
if (!
|
282
|
+
const compiledText = getTextFor((await script.requestContent()).content);
|
283
|
+
if (!compiledText) {
|
284
|
+
return null;
|
285
|
+
}
|
286
|
+
const compiledToken = compiledText.extract(ranges.range);
|
287
|
+
const parsedCompiledToken = extractIdentifier(compiledToken);
|
288
|
+
if (!parsedCompiledToken) {
|
281
289
|
return null;
|
282
290
|
}
|
283
|
-
|
284
|
-
if (
|
285
|
-
|
286
|
-
|
291
|
+
const {name: compiledName, punctuation: compiledPunctuation} = parsedCompiledToken;
|
292
|
+
if (compiledName !== name) {
|
293
|
+
return null;
|
294
|
+
}
|
295
|
+
|
296
|
+
// Extract the mapped name from the source code range and ensure that the punctuation
|
297
|
+
// matches the one from the compiled code.
|
298
|
+
const sourceText = getTextFor((await uiSourceCode.requestContent()).content);
|
299
|
+
if (!sourceText) {
|
300
|
+
return null;
|
301
|
+
}
|
302
|
+
const sourceToken = sourceText.extract(ranges.sourceRange);
|
303
|
+
const parsedSourceToken = extractIdentifier(sourceToken);
|
304
|
+
if (!parsedSourceToken) {
|
305
|
+
return null;
|
306
|
+
}
|
307
|
+
const {name: sourceName, punctuation: sourcePunctuation} = parsedSourceToken;
|
308
|
+
// Accept the source name if it is followed by the same punctuation.
|
309
|
+
if (compiledPunctuation === sourcePunctuation) {
|
310
|
+
return sourceName;
|
311
|
+
}
|
312
|
+
// Let us also allow semicolons into commas since that it is a common transformation.
|
313
|
+
if (compiledPunctuation === Punctuation.Comma && sourcePunctuation === Punctuation.Semicolon) {
|
314
|
+
return sourceName;
|
315
|
+
}
|
316
|
+
|
317
|
+
return null;
|
318
|
+
|
319
|
+
function extractIdentifier(token: string): {name: string, punctuation: Punctuation}|null {
|
320
|
+
const match = token.match(identifierAndPunctuationRegExp);
|
321
|
+
if (!match) {
|
322
|
+
return null;
|
323
|
+
}
|
324
|
+
|
325
|
+
const name = match[1];
|
326
|
+
let punctuation: Punctuation|null = null;
|
327
|
+
switch (match[2]) {
|
328
|
+
case '.':
|
329
|
+
punctuation = Punctuation.Dot;
|
330
|
+
break;
|
331
|
+
case ',':
|
332
|
+
punctuation = Punctuation.Comma;
|
333
|
+
break;
|
334
|
+
case ';':
|
335
|
+
punctuation = Punctuation.Semicolon;
|
336
|
+
break;
|
337
|
+
case '':
|
338
|
+
punctuation = Punctuation.None;
|
339
|
+
break;
|
340
|
+
default:
|
341
|
+
console.error(`Name token parsing error: unexpected token "${match[2]}"`);
|
342
|
+
return null;
|
343
|
+
}
|
344
|
+
|
345
|
+
return {name, punctuation};
|
346
|
+
}
|
347
|
+
|
348
|
+
function getTextFor(content: string|null): TextUtils.Text.Text|null {
|
349
|
+
if (!content) {
|
350
|
+
return null;
|
351
|
+
}
|
352
|
+
let text = textCache.get(content);
|
353
|
+
if (!text) {
|
354
|
+
text = new TextUtils.Text.Text(content);
|
355
|
+
textCache.set(content, text);
|
356
|
+
}
|
357
|
+
return text;
|
287
358
|
}
|
288
|
-
const originalIdentifier = text.extract(sourceTextRange).trim();
|
289
|
-
return /[a-zA-Z0-9_$]+/.test(originalIdentifier) ? originalIdentifier : null;
|
290
359
|
}
|
291
360
|
|
292
361
|
function findFunctionScope(): SDK.DebuggerModel.ScopeChainEntry|null {
|
package/package.json
CHANGED