Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(732)

Unified Diff: third_party/WebKit/Source/devtools/front_end/formatter_worker/FormatterWorker.js

Issue 1887913002: DevTools: improve identifier extraction in SourceMapNamesResolver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/devtools/front_end/formatter_worker/FormatterWorker.js
diff --git a/third_party/WebKit/Source/devtools/front_end/formatter_worker/FormatterWorker.js b/third_party/WebKit/Source/devtools/front_end/formatter_worker/FormatterWorker.js
index 37014ddcfc467fcdfb9099eb1d9ffe47a2fc3e32..7b2e52912080c3731e10ed5b6e34ee7594f8c559 100644
--- a/third_party/WebKit/Source/devtools/front_end/formatter_worker/FormatterWorker.js
+++ b/third_party/WebKit/Source/devtools/front_end/formatter_worker/FormatterWorker.js
@@ -135,7 +135,7 @@ WebInspector.javaScriptIdentifiers = function(content)
/** @type {!Array<!ESTree.Node>} */
var identifiers = [];
var functionDeclarationCounter = 0;
dgozman 2016/04/14 19:15:37 Remove this one.
lushnikov 2016/04/15 00:16:01 Done.
- var walker = new WebInspector.ESTreeWalker(beforeVisit, afterVisit);
+ var walker = new WebInspector.ESTreeWalker(beforeVisit);
/**
* @param {!ESTree.Node} node
@@ -152,28 +152,27 @@ WebInspector.javaScriptIdentifiers = function(content)
function beforeVisit(node)
dgozman 2016/04/14 19:15:37 Let's add tests.
lushnikov 2016/04/15 00:16:01 Done.
{
if (isFunction(node))
- functionDeclarationCounter++;
-
- if (functionDeclarationCounter > 1)
- return;
-
- if (isFunction(node) && node.params)
- identifiers.pushAll(node.params);
+ return WebInspector.ESTreeWalker.SkipSubtree;
if (node.type === "VariableDeclarator")
dgozman 2016/04/14 19:15:37 Remove this one.
lushnikov 2016/04/15 00:16:01 Done.
identifiers.push(/** @type {!ESTree.Node} */(node.id));
+ if (node.type === "MemberExpression") {
+ if (node.object.type === "Identifier")
dgozman 2016/04/14 19:15:37 Ignore "property" identifier of "MemberExpression"
lushnikov 2016/04/15 00:16:01 Done.
+ identifiers.push(node.object);
+ return WebInspector.ESTreeWalker.SkipSubtree;
+ }
+ if (node.type === "Identifier")
+ identifiers.push(node);
}
- /**
- * @param {!ESTree.Node} node
- */
- function afterVisit(node)
- {
- if (isFunction(node))
- functionDeclarationCounter--;
+ if (!root || root.type !== "Program" || root.body.length !== 1 || !isFunction(root.body[0])) {
+ postMessage([]);
+ return;
}
- walker.walk(root);
+ var functionNode = root.body[0];
+ identifiers.pushAll(functionNode.params);
dgozman 2016/04/14 19:15:37 for (var param of functionNode.params) walker.
lushnikov 2016/04/15 00:16:01 Done.
+ walker.walk(functionNode.body);
var reduced = identifiers.map(id => ({name: id.name, offset: id.start}));
postMessage(reduced);
}

Powered by Google App Engine
This is Rietveld 408576698