Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 WebInspector.SourceMapNamesResolver = {}; | 5 WebInspector.SourceMapNamesResolver = {}; |
| 6 | 6 |
| 7 WebInspector.SourceMapNamesResolver._cachedMapSymbol = Symbol("cache"); | 7 WebInspector.SourceMapNamesResolver._cachedMapSymbol = Symbol("cache"); |
| 8 WebInspector.SourceMapNamesResolver._cachedPromiseSymbol = Symbol("cache"); | 8 WebInspector.SourceMapNamesResolver._cachedPromiseSymbol = Symbol("cache"); |
| 9 | 9 |
| 10 /** | 10 /** |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 return new Map(); | 46 return new Map(); |
| 47 | 47 |
| 48 var startLocation = scope.startLocation(); | 48 var startLocation = scope.startLocation(); |
| 49 var endLocation = scope.endLocation(); | 49 var endLocation = scope.endLocation(); |
| 50 var textRange = new WebInspector.TextRange(startLocation.lineNumber, sta rtLocation.columnNumber, endLocation.lineNumber, endLocation.columnNumber); | 50 var textRange = new WebInspector.TextRange(startLocation.lineNumber, sta rtLocation.columnNumber, endLocation.lineNumber, endLocation.columnNumber); |
| 51 | 51 |
| 52 var scopeText = textRange.extract(content); | 52 var scopeText = textRange.extract(content); |
| 53 var scopeStart = textRange.toSourceRange(content).offset; | 53 var scopeStart = textRange.toSourceRange(content).offset; |
| 54 var prefix = "function fui"; | 54 var prefix = "function fui"; |
| 55 var root = acorn.parse(prefix + scopeText, {}); | 55 var root = acorn.parse(prefix + scopeText, {}); |
| 56 /** @type {!Array<!ESTree.Node>} */ | 56 /** @type {!Array<?ESTree.Node>} */ |
|
lushnikov
2016/03/04 22:49:18
revert
kozy
2016/03/04 23:18:50
Done.
| |
| 57 var identifiers = []; | 57 var identifiers = []; |
| 58 var functionDeclarationCounter = 0; | 58 var functionDeclarationCounter = 0; |
| 59 var walker = new WebInspector.ESTreeWalker(beforeVisit, afterVisit); | 59 var walker = new WebInspector.ESTreeWalker(beforeVisit, afterVisit); |
| 60 | 60 |
| 61 /** | 61 /** |
| 62 * @param {!ESTree.Node} node | 62 * @param {!ESTree.Node} node |
| 63 * @return {boolean} | 63 * @return {boolean} |
| 64 */ | 64 */ |
| 65 function isFunction(node) | 65 function isFunction(node) |
| 66 { | 66 { |
| 67 return node.type === "FunctionDeclaration" || node.type === "Functio nExpression"; | 67 return node.type === "FunctionDeclaration" || node.type === "Functio nExpression"; |
| 68 } | 68 } |
| 69 | 69 |
| 70 /** | 70 /** |
| 71 * @param {!ESTree.Node} node | 71 * @param {!ESTree.Node} node |
| 72 */ | 72 */ |
| 73 function beforeVisit(node) | 73 function beforeVisit(node) |
| 74 { | 74 { |
| 75 if (isFunction(node)) | 75 if (isFunction(node)) |
| 76 functionDeclarationCounter++; | 76 functionDeclarationCounter++; |
| 77 | 77 |
| 78 if (functionDeclarationCounter > 1) | 78 if (functionDeclarationCounter > 1) |
| 79 return; | 79 return; |
| 80 | 80 |
| 81 if (isFunction(node) && node.params) | 81 if (isFunction(node) && node.params) |
| 82 identifiers.pushAll(node.params); | 82 identifiers.pushAll(node.params); |
| 83 | 83 |
| 84 if (node.type === "VariableDeclarator") | 84 if (node.type === "VariableDeclarator") |
| 85 identifiers.push(node.id); | 85 identifiers.push(node.id); |
|
lushnikov
2016/03/04 22:49:18
cast to !Estree.node
kozy
2016/03/04 23:18:50
Done.
| |
| 86 } | 86 } |
| 87 | 87 |
| 88 /** | 88 /** |
| 89 * @param {!ESTree.Node} node | 89 * @param {!ESTree.Node} node |
| 90 */ | 90 */ |
| 91 function afterVisit(node) | 91 function afterVisit(node) |
| 92 { | 92 { |
| 93 if (isFunction(node)) | 93 if (isFunction(node)) |
| 94 functionDeclarationCounter--; | 94 functionDeclarationCounter--; |
| 95 } | 95 } |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 371 /** | 371 /** |
| 372 * @override | 372 * @override |
| 373 * @param {function(?Array<!DebuggerAgent.CollectionEntry>)} callback | 373 * @param {function(?Array<!DebuggerAgent.CollectionEntry>)} callback |
| 374 */ | 374 */ |
| 375 collectionEntries: function(callback) | 375 collectionEntries: function(callback) |
| 376 { | 376 { |
| 377 this._object.collectionEntries(callback); | 377 this._object.collectionEntries(callback); |
| 378 }, | 378 }, |
| 379 | 379 |
| 380 __proto__: WebInspector.RemoteObject.prototype | 380 __proto__: WebInspector.RemoteObject.prototype |
| 381 } | 381 } |
| OLD | NEW |