MCPcopy Create free account
hub / github.com/ChromeDevTools/devtools-frontend / scopeTreeForScript

Function scopeTreeForScript

front_end/core/sdk/ScopeTreeCache.ts:27–49  ·  view source on GitHub ↗
(script: Script)

Source from the content-addressed store, hash-verified

25 * and the text allows conversion from/to line/column numbers.
26 */
27export function scopeTreeForScript(script: Script): Promise<{scopeTree: ScopeTreeNode, text: Text}|null> {
28 if (script.isWasm()) {
29 return Promise.resolve(null);
30 }
31
32 let promise = scopeTrees.get(script);
33 if (promise === undefined) {
34 promise = script.requestContentData().then(content => {
35 if (TextUtils.ContentData.ContentData.isError(content)) {
36 return null;
37 }
38
39 const sourceType = script.isModule ? 'module' : 'script';
40 return Formatter.FormatterWorkerPool.formatterWorkerPool()
41 .javaScriptScopeTree(content.text, sourceType)
42 .then(scopeTree => scopeTree ? ({scopeTree, text: content.textObj}) : null)
43 .catch(() => null);
44 });
45 scopeTrees.set(script, promise);
46 }
47 // We intentionally return `null` here if the script already failed to parse once.
48 return promise;
49}

Callers 2

#buildScopesFallbackMethod · 0.85

Calls 7

javaScriptScopeTreeMethod · 0.80
resolveMethod · 0.65
getMethod · 0.65
requestContentDataMethod · 0.65
setMethod · 0.65
isWasmMethod · 0.45
isErrorMethod · 0.45

Tested by

no test coverage detected