| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 /** | 30 /** |
| 31 * @implements {Bindings.DebuggerSourceMapping} | 31 * @implements {Bindings.DebuggerSourceMapping} |
| 32 * @unrestricted | 32 * @unrestricted |
| 33 */ | 33 */ |
| 34 Bindings.CompilerScriptMapping = class { | 34 Bindings.CompilerScriptMapping = class { |
| 35 /** | 35 /** |
| 36 * @param {!SDK.DebuggerModel} debuggerModel | 36 * @param {!SDK.DebuggerModel} debuggerModel |
| 37 * @param {!Workspace.Workspace} workspace | 37 * @param {!Workspace.Workspace} workspace |
| 38 * @param {!Bindings.NetworkMapping} networkMapping | |
| 39 * @param {!Bindings.NetworkProject} networkProject | 38 * @param {!Bindings.NetworkProject} networkProject |
| 40 * @param {!Bindings.DebuggerWorkspaceBinding} debuggerWorkspaceBinding | 39 * @param {!Bindings.DebuggerWorkspaceBinding} debuggerWorkspaceBinding |
| 41 */ | 40 */ |
| 42 constructor(debuggerModel, workspace, networkMapping, networkProject, debugger
WorkspaceBinding) { | 41 constructor(debuggerModel, workspace, networkProject, debuggerWorkspaceBinding
) { |
| 43 this._target = debuggerModel.target(); | 42 this._target = debuggerModel.target(); |
| 44 this._debuggerModel = debuggerModel; | 43 this._debuggerModel = debuggerModel; |
| 45 this._networkMapping = networkMapping; | 44 this._workspace = workspace; |
| 46 this._networkProject = networkProject; | 45 this._networkProject = networkProject; |
| 47 this._debuggerWorkspaceBinding = debuggerWorkspaceBinding; | 46 this._debuggerWorkspaceBinding = debuggerWorkspaceBinding; |
| 48 | 47 |
| 49 /** @type {!Map<string, !Promise<?SDK.TextSourceMap>>} */ | 48 /** @type {!Map<string, !Promise<?SDK.TextSourceMap>>} */ |
| 50 this._sourceMapLoadingPromises = new Map(); | 49 this._sourceMapLoadingPromises = new Map(); |
| 51 /** @type {!Map<string, !SDK.TextSourceMap>} */ | 50 /** @type {!Map<string, !SDK.TextSourceMap>} */ |
| 52 this._sourceMapForScriptId = new Map(); | 51 this._sourceMapForScriptId = new Map(); |
| 53 /** @type {!Map.<!SDK.TextSourceMap, !SDK.Script>} */ | 52 /** @type {!Map.<!SDK.TextSourceMap, !SDK.Script>} */ |
| 54 this._scriptForSourceMap = new Map(); | 53 this._scriptForSourceMap = new Map(); |
| 55 /** @type {!Map.<string, !SDK.TextSourceMap>} */ | 54 /** @type {!Map.<string, !SDK.TextSourceMap>} */ |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 if (!sourceMap) | 110 if (!sourceMap) |
| 112 return null; | 111 return null; |
| 113 var lineNumber = debuggerModelLocation.lineNumber; | 112 var lineNumber = debuggerModelLocation.lineNumber; |
| 114 var columnNumber = debuggerModelLocation.columnNumber || 0; | 113 var columnNumber = debuggerModelLocation.columnNumber || 0; |
| 115 var entry = sourceMap.findEntry(lineNumber, columnNumber); | 114 var entry = sourceMap.findEntry(lineNumber, columnNumber); |
| 116 if (!entry || !entry.sourceURL) | 115 if (!entry || !entry.sourceURL) |
| 117 return null; | 116 return null; |
| 118 var script = rawLocation.script(); | 117 var script = rawLocation.script(); |
| 119 if (!script) | 118 if (!script) |
| 120 return null; | 119 return null; |
| 121 var uiSourceCode = this._networkMapping.uiSourceCodeForScriptURL(/** @type {
string} */ (entry.sourceURL), script); | 120 var uiSourceCode = Bindings.NetworkProject.uiSourceCodeForScriptURL(this._wo
rkspace, /** @type {string} */ (entry.sourceURL), script); |
| 122 if (!uiSourceCode) | 121 if (!uiSourceCode) |
| 123 return null; | 122 return null; |
| 124 return uiSourceCode.uiLocation( | 123 return uiSourceCode.uiLocation( |
| 125 /** @type {number} */ (entry.sourceLineNumber), /** @type {number} */ (e
ntry.sourceColumnNumber)); | 124 /** @type {number} */ (entry.sourceLineNumber), /** @type {number} */ (e
ntry.sourceColumnNumber)); |
| 126 } | 125 } |
| 127 | 126 |
| 128 /** | 127 /** |
| 129 * @override | 128 * @override |
| 130 * @param {!Workspace.UISourceCode} uiSourceCode | 129 * @param {!Workspace.UISourceCode} uiSourceCode |
| 131 * @param {number} lineNumber | 130 * @param {number} lineNumber |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 | 230 |
| 232 this._sourceMapForScriptId.set(script.scriptId, sourceMap); | 231 this._sourceMapForScriptId.set(script.scriptId, sourceMap); |
| 233 this._scriptForSourceMap.set(sourceMap, script); | 232 this._scriptForSourceMap.set(sourceMap, script); |
| 234 | 233 |
| 235 // Report sources. | 234 // Report sources. |
| 236 var missingSources = []; | 235 var missingSources = []; |
| 237 for (var sourceURL of sourceMap.sourceURLs()) { | 236 for (var sourceURL of sourceMap.sourceURLs()) { |
| 238 if (this._sourceMapForURL.get(sourceURL)) | 237 if (this._sourceMapForURL.get(sourceURL)) |
| 239 continue; | 238 continue; |
| 240 this._sourceMapForURL.set(sourceURL, sourceMap); | 239 this._sourceMapForURL.set(sourceURL, sourceMap); |
| 241 var uiSourceCode = this._networkMapping.uiSourceCodeForScriptURL(sourceURL
, script); | 240 var uiSourceCode = Bindings.NetworkProject.uiSourceCodeForScriptURL(this._
workspace, sourceURL, script); |
| 242 if (!uiSourceCode) { | 241 if (!uiSourceCode) { |
| 243 var contentProvider = sourceMap.sourceContentProvider(sourceURL, Common.
resourceTypes.SourceMapScript); | 242 var contentProvider = sourceMap.sourceContentProvider(sourceURL, Common.
resourceTypes.SourceMapScript); |
| 244 var embeddedContent = sourceMap.embeddedContentByURL(sourceURL); | 243 var embeddedContent = sourceMap.embeddedContentByURL(sourceURL); |
| 245 var embeddedContentLength = typeof embeddedContent === 'string' ? embedd
edContent.length : null; | 244 var embeddedContentLength = typeof embeddedContent === 'string' ? embedd
edContent.length : null; |
| 246 uiSourceCode = this._networkProject.addFile( | 245 uiSourceCode = this._networkProject.addFile( |
| 247 contentProvider, SDK.ResourceTreeFrame.fromScript(script), script.is
ContentScript(), embeddedContentLength); | 246 contentProvider, SDK.ResourceTreeFrame.fromScript(script), script.is
ContentScript(), embeddedContentLength); |
| 248 uiSourceCode[Bindings.CompilerScriptMapping._originSymbol] = script.sour
ceURL; | 247 uiSourceCode[Bindings.CompilerScriptMapping._originSymbol] = script.sour
ceURL; |
| 249 } | 248 } |
| 250 if (uiSourceCode) { | 249 if (uiSourceCode) { |
| 251 this._bindUISourceCode(uiSourceCode); | 250 this._bindUISourceCode(uiSourceCode); |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 _debuggerReset() { | 352 _debuggerReset() { |
| 354 /** | 353 /** |
| 355 * @param {!SDK.TextSourceMap} sourceMap | 354 * @param {!SDK.TextSourceMap} sourceMap |
| 356 * @this {Bindings.CompilerScriptMapping} | 355 * @this {Bindings.CompilerScriptMapping} |
| 357 */ | 356 */ |
| 358 function unbindSourceMapSources(sourceMap) { | 357 function unbindSourceMapSources(sourceMap) { |
| 359 var script = this._scriptForSourceMap.get(sourceMap); | 358 var script = this._scriptForSourceMap.get(sourceMap); |
| 360 if (!script) | 359 if (!script) |
| 361 return; | 360 return; |
| 362 for (var sourceURL of sourceMap.sourceURLs()) { | 361 for (var sourceURL of sourceMap.sourceURLs()) { |
| 363 var uiSourceCode = this._networkMapping.uiSourceCodeForScriptURL(sourceU
RL, script); | 362 var uiSourceCode = Bindings.NetworkProject.uiSourceCodeForScriptURL(this
._workspace, sourceURL, script); |
| 364 if (uiSourceCode) | 363 if (uiSourceCode) |
| 365 this._unbindUISourceCode(uiSourceCode); | 364 this._unbindUISourceCode(uiSourceCode); |
| 366 } | 365 } |
| 367 } | 366 } |
| 368 | 367 |
| 369 this._sourceMapForURL.valuesArray().forEach(unbindSourceMapSources.bind(this
)); | 368 this._sourceMapForURL.valuesArray().forEach(unbindSourceMapSources.bind(this
)); |
| 370 | 369 |
| 371 this._sourceMapLoadingPromises.clear(); | 370 this._sourceMapLoadingPromises.clear(); |
| 372 this._sourceMapForScriptId.clear(); | 371 this._sourceMapForScriptId.clear(); |
| 373 this._scriptForSourceMap.clear(); | 372 this._scriptForSourceMap.clear(); |
| 374 this._sourceMapForURL.clear(); | 373 this._sourceMapForURL.clear(); |
| 375 } | 374 } |
| 376 | 375 |
| 377 dispose() { | 376 dispose() { |
| 378 Common.EventTarget.removeEventListeners(this._eventListeners); | 377 Common.EventTarget.removeEventListeners(this._eventListeners); |
| 379 this._debuggerReset(); | 378 this._debuggerReset(); |
| 380 this._stubProject.dispose(); | 379 this._stubProject.dispose(); |
| 381 } | 380 } |
| 382 }; | 381 }; |
| 383 | 382 |
| 384 Bindings.CompilerScriptMapping._originSymbol = Symbol('origin'); | 383 Bindings.CompilerScriptMapping._originSymbol = Symbol('origin'); |
| OLD | NEW |