- Revision
- 190184
- Author
- sbar...@apple.com
- Date
- 2015-09-23 13:58:51 -0700 (Wed, 23 Sep 2015)
Log Message
Web Inspector: Type bubbles missing for computed methods and methods on object literals
https://bugs.webkit.org/show_bug.cgi?id=148562
Reviewed by Joseph Pecoraro.
Source/WebInspectorUI:
This patch makes sure that computed methods are working
for both classes and object literals. Also, methods now
work on object literals. This patch also cleans up the
"isGetterOrSetter" and "getterOrSetterRange" fields.
Basically, we used this as a way to ask the type profiler
for the return types of a function. Now, we just have
a field called "typeProfilingReturnDivot" that is set
on all functions so we don't need to conditionally ask
if it's a getter or setter.
* UserInterface/Controllers/TypeTokenAnnotator.js:
(WebInspector.TypeTokenAnnotator.prototype._insertTypeToken):
* UserInterface/Models/ScriptSyntaxTree.js:
(WebInspector.ScriptSyntaxTree.functionReturnDivot):
(WebInspector.ScriptSyntaxTree.prototype._recurseArray):
(WebInspector.ScriptSyntaxTree.prototype._createInternalSyntaxTree):
(WebInspector.ScriptSyntaxTree):
LayoutTests:
* inspector/model/parse-script-syntax-tree-expected.txt:
* inspector/model/parse-script-syntax-tree.html:
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (190183 => 190184)
--- trunk/LayoutTests/ChangeLog 2015-09-23 20:34:18 UTC (rev 190183)
+++ trunk/LayoutTests/ChangeLog 2015-09-23 20:58:51 UTC (rev 190184)
@@ -1,3 +1,13 @@
+2015-09-23 Saam barati <sbar...@apple.com>
+
+ Web Inspector: Type bubbles missing for computed methods and methods on object literals
+ https://bugs.webkit.org/show_bug.cgi?id=148562
+
+ Reviewed by Joseph Pecoraro.
+
+ * inspector/model/parse-script-syntax-tree-expected.txt:
+ * inspector/model/parse-script-syntax-tree.html:
+
2015-09-23 Beth Dakin <bda...@apple.com>
accessibility/mac/aria-expanded-notifications.html is flaky
Modified: trunk/LayoutTests/inspector/model/parse-script-syntax-tree-expected.txt (190183 => 190184)
--- trunk/LayoutTests/inspector/model/parse-script-syntax-tree-expected.txt 2015-09-23 20:34:18 UTC (rev 190183)
+++ trunk/LayoutTests/inspector/model/parse-script-syntax-tree-expected.txt 2015-09-23 20:58:51 UTC (rev 190184)
@@ -41,5 +41,8 @@
passed ClassStatement, Super, MetaProperty
passed AssignmentPattern
passed ArrowFunctionExpression
+passed computed method on object literal
+passed method on object literal
+passed computed method property on object literal
passed ALL TESTS
Modified: trunk/LayoutTests/inspector/model/parse-script-syntax-tree.html (190183 => 190184)
--- trunk/LayoutTests/inspector/model/parse-script-syntax-tree.html 2015-09-23 20:34:18 UTC (rev 190183)
+++ trunk/LayoutTests/inspector/model/parse-script-syntax-tree.html 2015-09-23 20:58:51 UTC (rev 190184)
@@ -193,13 +193,10 @@
InspectorTest.assert(node.params[1].type === WebInspector.ScriptSyntaxTree.NodeType.Identifier);
InspectorTest.assert(node.body);
InspectorTest.assert(node.body.type === WebInspector.ScriptSyntaxTree.NodeType.BlockStatement);
- InspectorTest.assert(!node.isGetterOrSetter);
node = makeNode("x = {get foo(){return 20}}", true);
InspectorTest.assert(node.right.properties[0].value.type === WebInspector.ScriptSyntaxTree.NodeType.FunctionExpression);
- InspectorTest.assert(node.right.properties[0].value.isGetterOrSetter);
node = makeNode("x = {set foo(x){return 20}}", true);
InspectorTest.assert(node.right.properties[0].value.type === WebInspector.ScriptSyntaxTree.NodeType.FunctionExpression);
- InspectorTest.assert(node.right.properties[0].value.isGetterOrSetter);
InspectorTest.log("passed FunctionDeclaration");
node = makeNode("foo(function(x,y){})", true);
@@ -496,6 +493,51 @@
InspectorTest.assert(node.body.type === WebInspector.ScriptSyntaxTree.NodeType.BlockStatement);
InspectorTest.log("passed ArrowFunctionExpression");
+ node = makeNode("var o = {['c']() { }};", false);
+ // ^
+ // type profiling return divot.
+ InspectorTest.assert(node.type === WebInspector.ScriptSyntaxTree.NodeType.VariableDeclaration);
+ InspectorTest.assert(node.declarations.length === 1);
+ InspectorTest.assert(node.declarations[0].type === WebInspector.ScriptSyntaxTree.NodeType.VariableDeclarator);
+ InspectorTest.assert(node.declarations[0].init.type === WebInspector.ScriptSyntaxTree.NodeType.ObjectExpression);
+ InspectorTest.assert(node.declarations[0].init.properties.length === 1);
+ InspectorTest.assert(node.declarations[0].init.properties[0].type === WebInspector.ScriptSyntaxTree.NodeType.Property);
+ InspectorTest.assert(!!node.declarations[0].init.properties[0].method);
+ InspectorTest.assert(!!node.declarations[0].init.properties[0].computed);
+ InspectorTest.assert(node.declarations[0].init.properties[0].value.type === WebInspector.ScriptSyntaxTree.NodeType.FunctionExpression);
+ InspectorTest.assert(node.declarations[0].init.properties[0].value.typeProfilingReturnDivot === 9);
+ InspectorTest.log("passed computed method on object literal");
+
+ node = makeNode("var o = { m(){ } };", false);
+ // ^
+ // type profiling return divot.
+ InspectorTest.assert(node.type === WebInspector.ScriptSyntaxTree.NodeType.VariableDeclaration);
+ InspectorTest.assert(node.declarations.length === 1);
+ InspectorTest.assert(node.declarations[0].type === WebInspector.ScriptSyntaxTree.NodeType.VariableDeclarator);
+ InspectorTest.assert(node.declarations[0].init.type === WebInspector.ScriptSyntaxTree.NodeType.ObjectExpression);
+ InspectorTest.assert(node.declarations[0].init.properties.length === 1);
+ InspectorTest.assert(node.declarations[0].init.properties[0].type === WebInspector.ScriptSyntaxTree.NodeType.Property);
+ InspectorTest.assert(!!node.declarations[0].init.properties[0].method);
+ InspectorTest.assert(!node.declarations[0].init.properties[0].computed);
+ InspectorTest.assert(node.declarations[0].init.properties[0].value.type === WebInspector.ScriptSyntaxTree.NodeType.FunctionExpression);
+ InspectorTest.assert(node.declarations[0].init.properties[0].value.typeProfilingReturnDivot === 10);
+ InspectorTest.log("passed method on object literal");
+
+ node = makeNode("var o = {['c']: function(){ } };", false);
+ // ^
+ // type profiling return divot.
+ InspectorTest.assert(node.type === WebInspector.ScriptSyntaxTree.NodeType.VariableDeclaration);
+ InspectorTest.assert(node.declarations.length === 1);
+ InspectorTest.assert(node.declarations[0].type === WebInspector.ScriptSyntaxTree.NodeType.VariableDeclarator);
+ InspectorTest.assert(node.declarations[0].init.type === WebInspector.ScriptSyntaxTree.NodeType.ObjectExpression);
+ InspectorTest.assert(node.declarations[0].init.properties.length === 1);
+ InspectorTest.assert(node.declarations[0].init.properties[0].type === WebInspector.ScriptSyntaxTree.NodeType.Property);
+ InspectorTest.assert(!node.declarations[0].init.properties[0].method);
+ InspectorTest.assert(!!node.declarations[0].init.properties[0].computed);
+ InspectorTest.assert(node.declarations[0].init.properties[0].value.type === WebInspector.ScriptSyntaxTree.NodeType.FunctionExpression);
+ InspectorTest.assert(node.declarations[0].init.properties[0].value.typeProfilingReturnDivot === 16);
+ InspectorTest.log("passed computed method property on object literal");
+
InspectorTest.log("passed ALL TESTS");
InspectorTest.completeTest();
}
Modified: trunk/Source/WebInspectorUI/ChangeLog (190183 => 190184)
--- trunk/Source/WebInspectorUI/ChangeLog 2015-09-23 20:34:18 UTC (rev 190183)
+++ trunk/Source/WebInspectorUI/ChangeLog 2015-09-23 20:58:51 UTC (rev 190184)
@@ -1,3 +1,28 @@
+2015-09-23 Saam barati <sbar...@apple.com>
+
+ Web Inspector: Type bubbles missing for computed methods and methods on object literals
+ https://bugs.webkit.org/show_bug.cgi?id=148562
+
+ Reviewed by Joseph Pecoraro.
+
+ This patch makes sure that computed methods are working
+ for both classes and object literals. Also, methods now
+ work on object literals. This patch also cleans up the
+ "isGetterOrSetter" and "getterOrSetterRange" fields.
+ Basically, we used this as a way to ask the type profiler
+ for the return types of a function. Now, we just have
+ a field called "typeProfilingReturnDivot" that is set
+ on all functions so we don't need to conditionally ask
+ if it's a getter or setter.
+
+ * UserInterface/Controllers/TypeTokenAnnotator.js:
+ (WebInspector.TypeTokenAnnotator.prototype._insertTypeToken):
+ * UserInterface/Models/ScriptSyntaxTree.js:
+ (WebInspector.ScriptSyntaxTree.functionReturnDivot):
+ (WebInspector.ScriptSyntaxTree.prototype._recurseArray):
+ (WebInspector.ScriptSyntaxTree.prototype._createInternalSyntaxTree):
+ (WebInspector.ScriptSyntaxTree):
+
2015-09-22 Devin Rousso <dcrousso+web...@gmail.com>
Web Inspector: The right sidebar always opens up on breakpoint
Modified: trunk/Source/WebInspectorUI/UserInterface/Controllers/TypeTokenAnnotator.js (190183 => 190184)
--- trunk/Source/WebInspectorUI/UserInterface/Controllers/TypeTokenAnnotator.js 2015-09-23 20:34:18 UTC (rev 190183)
+++ trunk/Source/WebInspectorUI/UserInterface/Controllers/TypeTokenAnnotator.js 2015-09-23 20:58:51 UTC (rev 190184)
@@ -106,8 +106,7 @@
var scriptSyntaxTree = this._script._scriptSyntaxTree;
if (!node.attachments.__typeToken && (scriptSyntaxTree.containsNonEmptyReturnStatement(node.body) || !functionReturnType.typeSet.isContainedIn(WebInspector.TypeSet.TypeBit.Undefined))) {
var functionName = node.id ? node.id.name : null;
- var offset = node.isGetterOrSetter ? node.getterOrSetterRange[0] : node.range[0];
- this._insertToken(offset, node, true, WebInspector.TypeTokenView.TitleType.ReturnStatement, functionName);
+ this._insertToken(node.typeProfilingReturnDivot, node, true, WebInspector.TypeTokenView.TitleType.ReturnStatement, functionName);
}
if (node.attachments.__typeToken)
Modified: trunk/Source/WebInspectorUI/UserInterface/Models/ScriptSyntaxTree.js (190183 => 190184)
--- trunk/Source/WebInspectorUI/UserInterface/Models/ScriptSyntaxTree.js 2015-09-23 20:34:18 UTC (rev 190183)
+++ trunk/Source/WebInspectorUI/UserInterface/Models/ScriptSyntaxTree.js 2015-09-23 20:58:51 UTC (rev 190184)
@@ -157,8 +157,9 @@
if (!DOMAgent.hasEvent("pseudoElementAdded"))
return node.body.range[0];
- // "f" in function, "s" in set, "g" in get, first letter in any method name for classes.
- return node.isGetterOrSetter ? node.getterOrSetterRange[0] : node.range[0];
+ // "f" in "function". "s" in "set". "g" in "get". First letter in any method name for classes and object literals.
+ // The "[" for computed methods in classes and object literals.
+ return node.typeProfilingReturnDivot;
}
updateTypes(nodesToUpdate, callback)
@@ -516,7 +517,7 @@
}
// This function translates from esprima's Abstract Syntax Tree to ours.
- // Mostly, this is just the identity function. We've added an extra isGetterOrSetter property for functions.
+ // Mostly, this is just the identity function. We've added an extra typeProfilingReturnDivot property for functions/methods.
// Our AST complies with the Mozilla parser API:
// https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Parser_API
_createInternalSyntaxTree(node)
@@ -546,7 +547,7 @@
defaults: node.defaults.map(this._createInternalSyntaxTree.bind(this)),
body: this._createInternalSyntaxTree(node.body),
_expression_: node._expression_, // Boolean indicating if the body a single _expression_ or a block statement.
- isGetterOrSetter: false
+ typeProfilingReturnDivot: node.range[0]
};
break;
case "AssignmentExpression":
@@ -689,7 +690,7 @@
params: node.params.map(this._createInternalSyntaxTree.bind(this)),
defaults: node.defaults.map(this._createInternalSyntaxTree.bind(this)),
body: this._createInternalSyntaxTree(node.body),
- isGetterOrSetter: false // This is obvious, but is convenient none the less b/c Declarations and Expressions are often intertwined.
+ typeProfilingReturnDivot: node.range[0]
};
break;
case "FunctionExpression":
@@ -699,7 +700,7 @@
params: node.params.map(this._createInternalSyntaxTree.bind(this)),
defaults: node.defaults.map(this._createInternalSyntaxTree.bind(this)),
body: this._createInternalSyntaxTree(node.body),
- isGetterOrSetter: false // If true, it is set in the Property AST node.
+ typeProfilingReturnDivot: node.range[0] // This may be overridden in the Property AST node.
};
break;
case "Identifier":
@@ -763,14 +764,7 @@
kind: node.kind,
static: node.static
};
- if (result.kind === "get" || result.kind === "set") {
- const length = result.key.range[1] - result.key.range[0];
- result.value.getterOrSetterRange = node.range;
- result.value.getterOrSetterRange[1] = node.range[0] + length;
- } else
- result.value.getterOrSetterRange = result.key.range;
- // FIXME: <https://webkit.org/b/143171> Web Inspector: Improve Type Profiler Support for ES6 Syntax
- result.value.isGetterOrSetter = true;
+ result.value.typeProfilingReturnDivot = node.range[0]; // "g" in "get" or "s" in "set" or "[" in "['computed']" or "m" in "methodName".
break;
case "NewExpression":
result = {
@@ -803,12 +797,12 @@
type: WebInspector.ScriptSyntaxTree.NodeType.Property,
key: this._createInternalSyntaxTree(node.key),
value: this._createInternalSyntaxTree(node.value),
- kind: node.kind
+ kind: node.kind,
+ method: node.method,
+ computed: node.computed
};
- if (result.kind === "get" || result.kind === "set") {
- result.value.isGetterOrSetter = true;
- result.value.getterOrSetterRange = result.key.range;
- }
+ if (result.kind === "get" || result.kind === "set" || result.method)
+ result.value.typeProfilingReturnDivot = node.range[0]; // "g" in "get" or "s" in "set" or "[" in "['computed']" method or "m" in "methodName".
break;
case "ReturnStatement":
result = {