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

Unified Diff: third_party/WebKit/Source/devtools/front_end/es_tree/ESTreeWalker.js

Issue 1912973002: [DevTools] JSONView parsing smarter (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/es_tree/ESTreeWalker.js
diff --git a/third_party/WebKit/Source/devtools/front_end/es_tree/ESTreeWalker.js b/third_party/WebKit/Source/devtools/front_end/es_tree/ESTreeWalker.js
index dfa926c0ba32ebabaa210b6b4cbeee93e0c7c806..b990d423872d0695012cb5f18f13f035bd3e9716 100644
--- a/third_party/WebKit/Source/devtools/front_end/es_tree/ESTreeWalker.js
+++ b/third_party/WebKit/Source/devtools/front_end/es_tree/ESTreeWalker.js
@@ -4,19 +4,29 @@
/**
* @constructor
- * @param {function(!ESTree.Node)} beforeVisit
+ * @param {function(!ESTree.Node):(!Object|undefined)} beforeVisit
* @param {function(!ESTree.Node)=} afterVisit
*/
WebInspector.ESTreeWalker = function(beforeVisit, afterVisit)
{
this._beforeVisit = beforeVisit;
this._afterVisit = afterVisit || new Function();
+ this._walkNulls = false;
}
+/** @typedef {!Object} WebInspector.ESTreeWalker.SkipSubtree */
WebInspector.ESTreeWalker.SkipSubtree = {};
WebInspector.ESTreeWalker.prototype = {
/**
+ * @param {boolean} value
+ */
+ setWalkNulls: function(value)
+ {
+ this._walkNulls = value;
+ },
+
+ /**
* @param {!ESTree.Node} ast
*/
walk: function(ast)
@@ -30,6 +40,14 @@ WebInspector.ESTreeWalker.prototype = {
*/
_innerWalk: function(node, parent)
{
+ if (!node && parent && this._walkNulls) {
+ node = /** @type {!ESTree.Node} */ ({
+ type: "Literal",
+ raw: "null",
+ value: null
+ });
+ }
+
if (!node)
return;
node.parent = parent;

Powered by Google App Engine
This is Rietveld 408576698