Commit b5a068ca authored by kozyatinskiy's avatar kozyatinskiy Committed by Commit bot

[DevTools] Fixed inline scope variables for object property

BUG=593937
R=lushnikov@chromium.org

Review-Url: https://codereview.chromium.org/2388903004
Cr-Commit-Position: refs/heads/master@{#423049}
parent 53f2d769
CONSOLE MESSAGE: line 13: 3
Tests that inline scope variables are rendering correctly.
Set timer for test function.
9: length = 123
10: a = [1, 2, 3]
11:
12: b = 42
13: a = [1, 2, 3]
<html>
<head>
<script src="../../../http/tests/inspector/inspector-test.js"></script>
<script src="../../../http/tests/inspector/debugger-test.js"></script>
<script>
function testFunction()
{
var length = 123;
var a = [1, 2, 3];
if (a.length) {
var b = 42;
console.log(a.length);
debugger;
return b;
}
}
var test = function()
{
InspectorTest.startDebuggerTest(step1, true);
function step1()
{
InspectorTest.addSnifferPromise(WebInspector.JavaScriptSourceFrame.prototype, "_renderDecorations").then(step2);
InspectorTest.runTestFunctionAndWaitUntilPaused();
}
function step2()
{
var currentFrame = WebInspector.panels.sources.visibleView;
var decorations = currentFrame.textEditor._decorations;
for (var line of decorations.keysArray()) {
var lineDecorations = Array.from(decorations.get(line)).map(decoration => decoration.element.textContent).join(", ");
InspectorTest.addResult(`${line + 1}: ${lineDecorations}`);
}
InspectorTest.completeDebuggerTest();
}
}
</script>
</head>
<body onload="runTest()">
<p>Tests that inline scope variables are rendering correctly.</p>
</body>
</html>
...@@ -712,6 +712,7 @@ WebInspector.JavaScriptSourceFrame.prototype = { ...@@ -712,6 +712,7 @@ WebInspector.JavaScriptSourceFrame.prototype = {
/** @type {!Map.<number, !Set<string>>} */ /** @type {!Map.<number, !Set<string>>} */
var namesPerLine = new Map(); var namesPerLine = new Map();
var skipObjectProperty = false;
var tokenizer = new WebInspector.CodeMirrorUtils.TokenizerFactory().createTokenizer("text/javascript"); var tokenizer = new WebInspector.CodeMirrorUtils.TokenizerFactory().createTokenizer("text/javascript");
tokenizer(this.textEditor.line(fromLine).substring(fromColumn), processToken.bind(this, fromLine)); tokenizer(this.textEditor.line(fromLine).substring(fromColumn), processToken.bind(this, fromLine));
for (var i = fromLine + 1; i < toLine; ++i) for (var i = fromLine + 1; i < toLine; ++i)
...@@ -727,7 +728,7 @@ WebInspector.JavaScriptSourceFrame.prototype = { ...@@ -727,7 +728,7 @@ WebInspector.JavaScriptSourceFrame.prototype = {
*/ */
function processToken(lineNumber, tokenValue, tokenType, column, newColumn) function processToken(lineNumber, tokenValue, tokenType, column, newColumn)
{ {
if (tokenType && this._isIdentifier(tokenType) && valuesMap.get(tokenValue)) { if (!skipObjectProperty && tokenType && this._isIdentifier(tokenType) && valuesMap.get(tokenValue)) {
var names = namesPerLine.get(lineNumber); var names = namesPerLine.get(lineNumber);
if (!names) { if (!names) {
names = new Set(); names = new Set();
...@@ -735,6 +736,7 @@ WebInspector.JavaScriptSourceFrame.prototype = { ...@@ -735,6 +736,7 @@ WebInspector.JavaScriptSourceFrame.prototype = {
} }
names.add(tokenValue); names.add(tokenValue);
} }
skipObjectProperty = tokenValue === ".";
} }
this.textEditor.operation(this._renderDecorations.bind(this, valuesMap, namesPerLine, fromLine, toLine)); this.textEditor.operation(this._renderDecorations.bind(this, valuesMap, namesPerLine, fromLine, toLine));
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment