| 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 Sources.SourceMapNamesResolver = {}; | 4 Sources.SourceMapNamesResolver = {}; |
| 5 | 5 |
| 6 Sources.SourceMapNamesResolver._cachedMapSymbol = Symbol('cache'); | 6 Sources.SourceMapNamesResolver._cachedMapSymbol = Symbol('cache'); |
| 7 Sources.SourceMapNamesResolver._cachedIdentifiersSymbol = Symbol('cachedIdentifi
ers'); | 7 Sources.SourceMapNamesResolver._cachedIdentifiersSymbol = Symbol('cachedIdentifi
ers'); |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * @unrestricted | 10 * @unrestricted |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 * @param {!SDK.DebuggerModel.CallFrame} callFrame | 218 * @param {!SDK.DebuggerModel.CallFrame} callFrame |
| 219 * @param {string} originalText | 219 * @param {string} originalText |
| 220 * @param {!Workspace.UISourceCode} uiSourceCode | 220 * @param {!Workspace.UISourceCode} uiSourceCode |
| 221 * @param {number} lineNumber | 221 * @param {number} lineNumber |
| 222 * @param {number} startColumnNumber | 222 * @param {number} startColumnNumber |
| 223 * @param {number} endColumnNumber | 223 * @param {number} endColumnNumber |
| 224 * @return {!Promise<string>} | 224 * @return {!Promise<string>} |
| 225 */ | 225 */ |
| 226 Sources.SourceMapNamesResolver.resolveExpression = function( | 226 Sources.SourceMapNamesResolver.resolveExpression = function( |
| 227 callFrame, originalText, uiSourceCode, lineNumber, startColumnNumber, endCol
umnNumber) { | 227 callFrame, originalText, uiSourceCode, lineNumber, startColumnNumber, endCol
umnNumber) { |
| 228 if (!Runtime.experiments.isEnabled('resolveVariableNames') || !uiSourceCode.co
ntentType().isFromSourceMap()) | 228 if (!uiSourceCode.contentType().isFromSourceMap()) |
| 229 return Promise.resolve(''); | 229 return Promise.resolve(''); |
| 230 | 230 |
| 231 return Sources.SourceMapNamesResolver._allVariablesInCallFrame(callFrame).then
(findCompiledName); | 231 return Sources.SourceMapNamesResolver._allVariablesInCallFrame(callFrame).then
(findCompiledName); |
| 232 | 232 |
| 233 /** | 233 /** |
| 234 * @param {!Map<string, string>} reverseMapping | 234 * @param {!Map<string, string>} reverseMapping |
| 235 * @return {!Promise<string>} | 235 * @return {!Promise<string>} |
| 236 */ | 236 */ |
| 237 function findCompiledName(reverseMapping) { | 237 function findCompiledName(reverseMapping) { |
| 238 if (reverseMapping.has(originalText)) | 238 if (reverseMapping.has(originalText)) |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 } | 294 } |
| 295 }; | 295 }; |
| 296 | 296 |
| 297 /** | 297 /** |
| 298 * @param {?SDK.DebuggerModel.CallFrame} callFrame | 298 * @param {?SDK.DebuggerModel.CallFrame} callFrame |
| 299 * @return {!Promise<?SDK.RemoteObject>} | 299 * @return {!Promise<?SDK.RemoteObject>} |
| 300 */ | 300 */ |
| 301 Sources.SourceMapNamesResolver.resolveThisObject = function(callFrame) { | 301 Sources.SourceMapNamesResolver.resolveThisObject = function(callFrame) { |
| 302 if (!callFrame) | 302 if (!callFrame) |
| 303 return Promise.resolve(/** @type {?SDK.RemoteObject} */ (null)); | 303 return Promise.resolve(/** @type {?SDK.RemoteObject} */ (null)); |
| 304 if (!Runtime.experiments.isEnabled('resolveVariableNames') || !callFrame.scope
Chain().length) | 304 if (!callFrame.scopeChain().length) |
| 305 return Promise.resolve(callFrame.thisObject()); | 305 return Promise.resolve(callFrame.thisObject()); |
| 306 | 306 |
| 307 return Sources.SourceMapNamesResolver._resolveScope(callFrame.scopeChain()[0])
.then(onScopeResolved); | 307 return Sources.SourceMapNamesResolver._resolveScope(callFrame.scopeChain()[0])
.then(onScopeResolved); |
| 308 | 308 |
| 309 /** | 309 /** |
| 310 * @param {!Map<string, string>} namesMapping | 310 * @param {!Map<string, string>} namesMapping |
| 311 * @return {!Promise<?SDK.RemoteObject>} | 311 * @return {!Promise<?SDK.RemoteObject>} |
| 312 */ | 312 */ |
| 313 function onScopeResolved(namesMapping) { | 313 function onScopeResolved(namesMapping) { |
| 314 var thisMappings = namesMapping.inverse().get('this'); | 314 var thisMappings = namesMapping.inverse().get('this'); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 331 evaluateResult ? callFrame.target().runtimeModel.createRemoteObject(eval
uateResult) : callFrame.thisObject(); | 331 evaluateResult ? callFrame.target().runtimeModel.createRemoteObject(eval
uateResult) : callFrame.thisObject(); |
| 332 callback(remoteObject); | 332 callback(remoteObject); |
| 333 } | 333 } |
| 334 }; | 334 }; |
| 335 | 335 |
| 336 /** | 336 /** |
| 337 * @param {!SDK.DebuggerModel.Scope} scope | 337 * @param {!SDK.DebuggerModel.Scope} scope |
| 338 * @return {!SDK.RemoteObject} | 338 * @return {!SDK.RemoteObject} |
| 339 */ | 339 */ |
| 340 Sources.SourceMapNamesResolver.resolveScopeInObject = function(scope) { | 340 Sources.SourceMapNamesResolver.resolveScopeInObject = function(scope) { |
| 341 if (!Runtime.experiments.isEnabled('resolveVariableNames')) | |
| 342 return scope.object(); | |
| 343 | |
| 344 var startLocation = scope.startLocation(); | 341 var startLocation = scope.startLocation(); |
| 345 var endLocation = scope.endLocation(); | 342 var endLocation = scope.endLocation(); |
| 346 | 343 |
| 347 if (scope.type() === Protocol.Debugger.ScopeType.Global || !startLocation || !
endLocation || | 344 if (scope.type() === Protocol.Debugger.ScopeType.Global || !startLocation || !
endLocation || |
| 348 !startLocation.script().sourceMapURL || startLocation.script() !== endLoca
tion.script()) | 345 !startLocation.script().sourceMapURL || startLocation.script() !== endLoca
tion.script()) |
| 349 return scope.object(); | 346 return scope.object(); |
| 350 | 347 |
| 351 return new Sources.SourceMapNamesResolver.RemoteObject(scope); | 348 return new Sources.SourceMapNamesResolver.RemoteObject(scope); |
| 352 }; | 349 }; |
| 353 | 350 |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 } | 541 } |
| 545 | 542 |
| 546 /** | 543 /** |
| 547 * @override | 544 * @override |
| 548 * @return {boolean} | 545 * @return {boolean} |
| 549 */ | 546 */ |
| 550 isNode() { | 547 isNode() { |
| 551 return this._object.isNode(); | 548 return this._object.isNode(); |
| 552 } | 549 } |
| 553 }; | 550 }; |
| OLD | NEW |