| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 * @unrestricted | 5 * @unrestricted |
| 6 * @implements {SDK.SDKModelObserver<!SDK.DebuggerModel>} | 6 * @implements {SDK.SDKModelObserver<!SDK.DebuggerModel>} |
| 7 */ | 7 */ |
| 8 Bindings.DebuggerWorkspaceBinding = class extends Common.Object { | 8 Bindings.DebuggerWorkspaceBinding = class { |
| 9 /** | 9 /** |
| 10 * @param {!SDK.TargetManager} targetManager | 10 * @param {!SDK.TargetManager} targetManager |
| 11 * @param {!Workspace.Workspace} workspace | 11 * @param {!Workspace.Workspace} workspace |
| 12 */ | 12 */ |
| 13 constructor(targetManager, workspace) { | 13 constructor(targetManager, workspace) { |
| 14 super(); | |
| 15 this._workspace = workspace; | 14 this._workspace = workspace; |
| 16 | 15 |
| 16 /** @type {!Array<!Bindings.DebuggerSourceMapping>} */ |
| 17 this._sourceMappings = []; |
| 18 |
| 17 /** @type {!Map.<!SDK.DebuggerModel, !Bindings.DebuggerWorkspaceBinding.Mode
lData>} */ | 19 /** @type {!Map.<!SDK.DebuggerModel, !Bindings.DebuggerWorkspaceBinding.Mode
lData>} */ |
| 18 this._debuggerModelToData = new Map(); | 20 this._debuggerModelToData = new Map(); |
| 19 targetManager.addModelListener( | 21 targetManager.addModelListener( |
| 20 SDK.DebuggerModel, SDK.DebuggerModel.Events.GlobalObjectCleared, this._g
lobalObjectCleared, this); | 22 SDK.DebuggerModel, SDK.DebuggerModel.Events.GlobalObjectCleared, this._g
lobalObjectCleared, this); |
| 21 targetManager.addModelListener( | 23 targetManager.addModelListener( |
| 22 SDK.DebuggerModel, SDK.DebuggerModel.Events.DebuggerResumed, this._debug
gerResumed, this); | 24 SDK.DebuggerModel, SDK.DebuggerModel.Events.DebuggerResumed, this._debug
gerResumed, this); |
| 23 workspace.addEventListener(Workspace.Workspace.Events.UISourceCodeRemoved, t
his._onUISourceCodeRemoved, this); | |
| 24 workspace.addEventListener(Workspace.Workspace.Events.ProjectRemoved, this._
projectRemoved, this); | |
| 25 targetManager.observeModels(SDK.DebuggerModel, this); | 25 targetManager.observeModels(SDK.DebuggerModel, this); |
| 26 } | 26 } |
| 27 | 27 |
| 28 /** | 28 /** |
| 29 * @param {!Bindings.DebuggerSourceMapping} sourceMapping |
| 30 */ |
| 31 addSourceMapping(sourceMapping) { |
| 32 this._sourceMappings.push(sourceMapping); |
| 33 } |
| 34 |
| 35 /** |
| 29 * @override | 36 * @override |
| 30 * @param {!SDK.DebuggerModel} debuggerModel | 37 * @param {!SDK.DebuggerModel} debuggerModel |
| 31 */ | 38 */ |
| 32 modelAdded(debuggerModel) { | 39 modelAdded(debuggerModel) { |
| 33 this._debuggerModelToData.set(debuggerModel, new Bindings.DebuggerWorkspaceB
inding.ModelData(debuggerModel, this)); | 40 this._debuggerModelToData.set(debuggerModel, new Bindings.DebuggerWorkspaceB
inding.ModelData(debuggerModel, this)); |
| 34 } | 41 } |
| 35 | 42 |
| 36 /** | 43 /** |
| 37 * @override | 44 * @override |
| 38 * @param {!SDK.DebuggerModel} debuggerModel | 45 * @param {!SDK.DebuggerModel} debuggerModel |
| 39 */ | 46 */ |
| 40 modelRemoved(debuggerModel) { | 47 modelRemoved(debuggerModel) { |
| 41 var modelData = this._debuggerModelToData.get(debuggerModel); | 48 var modelData = this._debuggerModelToData.get(debuggerModel); |
| 42 modelData._dispose(); | 49 modelData._dispose(); |
| 43 this._debuggerModelToData.remove(debuggerModel); | 50 this._debuggerModelToData.remove(debuggerModel); |
| 44 } | 51 } |
| 45 | 52 |
| 46 /** | 53 /** |
| 47 * @param {!Common.Event} event | |
| 48 */ | |
| 49 _onUISourceCodeRemoved(event) { | |
| 50 var uiSourceCode = /** @type {!Workspace.UISourceCode} */ (event.data); | |
| 51 this._uiSourceCodeRemoved(uiSourceCode); | |
| 52 } | |
| 53 | |
| 54 /** | |
| 55 * @param {!Common.Event} event | |
| 56 */ | |
| 57 _projectRemoved(event) { | |
| 58 var project = /** @type {!Workspace.Project} */ (event.data); | |
| 59 var uiSourceCodes = project.uiSourceCodes(); | |
| 60 for (var uiSourceCode of uiSourceCodes) | |
| 61 this._uiSourceCodeRemoved(uiSourceCode); | |
| 62 } | |
| 63 | |
| 64 /** | |
| 65 * @param {!SDK.Script} script | |
| 66 * @param {!Bindings.DebuggerSourceMapping} sourceMapping | |
| 67 */ | |
| 68 pushSourceMapping(script, sourceMapping) { | |
| 69 var info = this._ensureInfoForScript(script); | |
| 70 info._pushSourceMapping(sourceMapping); | |
| 71 } | |
| 72 | |
| 73 /** | |
| 74 * @param {!SDK.Script} script | |
| 75 * @return {!Bindings.DebuggerSourceMapping} | |
| 76 */ | |
| 77 popSourceMapping(script) { | |
| 78 var info = this._infoForScript(script); | |
| 79 console.assert(info); | |
| 80 return info._popSourceMapping(); | |
| 81 } | |
| 82 | |
| 83 /** | |
| 84 * @param {!SDK.DebuggerModel} debuggerModel | |
| 85 * @param {!Workspace.UISourceCode} uiSourceCode | |
| 86 * @param {?Bindings.DebuggerSourceMapping} sourceMapping | |
| 87 */ | |
| 88 setSourceMapping(debuggerModel, uiSourceCode, sourceMapping) { | |
| 89 if (uiSourceCode[Bindings.DebuggerWorkspaceBinding._sourceMappingSymbol] ===
sourceMapping) | |
| 90 return; | |
| 91 | |
| 92 if (sourceMapping) | |
| 93 uiSourceCode[Bindings.DebuggerWorkspaceBinding._sourceMappingSymbol] = sou
rceMapping; | |
| 94 else | |
| 95 delete uiSourceCode[Bindings.DebuggerWorkspaceBinding._sourceMappingSymbol
]; | |
| 96 | |
| 97 this.dispatchEventToListeners(Bindings.DebuggerWorkspaceBinding.Events.Sourc
eMappingChanged, { | |
| 98 uiSourceCode: uiSourceCode, | |
| 99 debuggerModel: debuggerModel, | |
| 100 isIdentity: sourceMapping ? sourceMapping.isIdentity() : false | |
| 101 }); | |
| 102 } | |
| 103 | |
| 104 /** | |
| 105 * @param {!SDK.Script} script | 54 * @param {!SDK.Script} script |
| 106 */ | 55 */ |
| 107 updateLocations(script) { | 56 updateLocations(script) { |
| 108 var info = this._infoForScript(script); | 57 var info = this._infoForScript(script); |
| 109 if (info) | 58 if (info) |
| 110 info._updateLocations(); | 59 info._updateLocations(); |
| 111 } | 60 } |
| 112 | 61 |
| 113 /** | 62 /** |
| 114 * @param {!SDK.DebuggerModel.Location} rawLocation | 63 * @param {!SDK.DebuggerModel.Location} rawLocation |
| 115 * @param {function(!Bindings.LiveLocation)} updateDelegate | 64 * @param {function(!Bindings.LiveLocation)} updateDelegate |
| 116 * @param {!Bindings.LiveLocationPool} locationPool | 65 * @param {!Bindings.LiveLocationPool} locationPool |
| 117 * @return {!Bindings.DebuggerWorkspaceBinding.Location} | 66 * @return {!Bindings.DebuggerWorkspaceBinding.Location} |
| 118 */ | 67 */ |
| 119 createLiveLocation(rawLocation, updateDelegate, locationPool) { | 68 createLiveLocation(rawLocation, updateDelegate, locationPool) { |
| 120 var info = this._infoForScript(rawLocation.script()); | 69 var script = /** @type {!SDK.Script} */ (rawLocation.script()); |
| 121 console.assert(info); | 70 console.assert(script); |
| 71 var info = this._ensureInfoForScript(script); |
| 122 var location = | 72 var location = |
| 123 new Bindings.DebuggerWorkspaceBinding.Location(info._script, rawLocation
, this, updateDelegate, locationPool); | 73 new Bindings.DebuggerWorkspaceBinding.Location(info._script, rawLocation
, this, updateDelegate, locationPool); |
| 124 info._addLocation(location); | 74 info._addLocation(location); |
| 125 return location; | 75 return location; |
| 126 } | 76 } |
| 127 | 77 |
| 128 /** | 78 /** |
| 129 * @param {!Array<!SDK.DebuggerModel.Location>} rawLocations | 79 * @param {!Array<!SDK.DebuggerModel.Location>} rawLocations |
| 130 * @param {function(!Bindings.LiveLocation)} updateDelegate | 80 * @param {function(!Bindings.LiveLocation)} updateDelegate |
| 131 * @param {!Bindings.LiveLocationPool} locationPool | 81 * @param {!Bindings.LiveLocationPool} locationPool |
| (...skipping 22 matching lines...) Expand all Loading... |
| 154 var liveLocation = this.createLiveLocation(location, updateDelegate, locatio
nPool); | 104 var liveLocation = this.createLiveLocation(location, updateDelegate, locatio
nPool); |
| 155 this._registerCallFrameLiveLocation(debuggerModel, liveLocation); | 105 this._registerCallFrameLiveLocation(debuggerModel, liveLocation); |
| 156 return liveLocation; | 106 return liveLocation; |
| 157 } | 107 } |
| 158 | 108 |
| 159 /** | 109 /** |
| 160 * @param {!SDK.DebuggerModel.Location} rawLocation | 110 * @param {!SDK.DebuggerModel.Location} rawLocation |
| 161 * @return {!Workspace.UILocation} | 111 * @return {!Workspace.UILocation} |
| 162 */ | 112 */ |
| 163 rawLocationToUILocation(rawLocation) { | 113 rawLocationToUILocation(rawLocation) { |
| 164 var info = this._infoForScript(rawLocation.script()); | 114 for (var i = 0; i < this._sourceMappings.length; ++i) { |
| 165 console.assert(info); | 115 var uiLocation = this._sourceMappings[i].rawLocationToUILocation(rawLocati
on); |
| 166 return info._rawLocationToUILocation(rawLocation); | 116 if (uiLocation) |
| 117 return uiLocation; |
| 118 } |
| 119 var modelData = this._debuggerModelToData.get(rawLocation.debuggerModel); |
| 120 return modelData._rawLocationToUILocation(rawLocation); |
| 167 } | 121 } |
| 168 | 122 |
| 169 /** | 123 /** |
| 170 * @param {!SDK.DebuggerModel} debuggerModel | 124 * @param {!SDK.DebuggerModel} debuggerModel |
| 171 * @param {string} url | 125 * @param {string} url |
| 172 * @param {boolean} isContentScript | 126 * @param {boolean} isContentScript |
| 173 */ | 127 */ |
| 174 uiSourceCodeForSourceMapSourceURL(debuggerModel, url, isContentScript) { | 128 uiSourceCodeForSourceMapSourceURL(debuggerModel, url, isContentScript) { |
| 175 var modelData = this._debuggerModelToData.get(debuggerModel); | 129 var modelData = this._debuggerModelToData.get(debuggerModel); |
| 176 if (!modelData) | 130 if (!modelData) |
| 177 return null; | 131 return null; |
| 178 return modelData._compilerMapping.uiSourceCodeForURL(url, isContentScript); | 132 return modelData._compilerMapping.uiSourceCodeForURL(url, isContentScript); |
| 179 } | 133 } |
| 180 | 134 |
| 181 /** | 135 /** |
| 182 * @param {!Workspace.UISourceCode} uiSourceCode | 136 * @param {!Workspace.UISourceCode} uiSourceCode |
| 183 * @param {number} lineNumber | 137 * @param {number} lineNumber |
| 184 * @param {number} columnNumber | 138 * @param {number} columnNumber |
| 185 * @return {?SDK.DebuggerModel.Location} | 139 * @return {?SDK.DebuggerModel.Location} |
| 186 */ | 140 */ |
| 187 uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber) { | 141 uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber) { |
| 188 var sourceMapping = uiSourceCode[Bindings.DebuggerWorkspaceBinding._sourceMa
ppingSymbol]; | 142 for (var i = 0; i < this._sourceMappings.length; ++i) { |
| 189 return sourceMapping && sourceMapping.uiLocationToRawLocation(uiSourceCode,
lineNumber, columnNumber); | 143 var rawLocation = this._sourceMappings[i].uiLocationToRawLocation(uiSource
Code, lineNumber, columnNumber); |
| 144 if (rawLocation) |
| 145 return rawLocation; |
| 146 } |
| 147 |
| 148 for (var modelData of this._debuggerModelToData.values()) { |
| 149 var rawLocation = modelData._uiLocationToRawLocation(uiSourceCode, lineNum
ber, columnNumber); |
| 150 if (rawLocation) |
| 151 return rawLocation; |
| 152 } |
| 153 return null; |
| 190 } | 154 } |
| 191 | 155 |
| 192 /** | 156 /** |
| 193 * @param {!Workspace.UILocation} uiLocation | 157 * @param {!Workspace.UILocation} uiLocation |
| 194 * @return {!Workspace.UILocation} | 158 * @return {!Workspace.UILocation} |
| 195 */ | 159 */ |
| 196 normalizeUILocation(uiLocation) { | 160 normalizeUILocation(uiLocation) { |
| 197 var rawLocation = | 161 var rawLocation = |
| 198 this.uiLocationToRawLocation(uiLocation.uiSourceCode, uiLocation.lineNum
ber, uiLocation.columnNumber); | 162 this.uiLocationToRawLocation(uiLocation.uiSourceCode, uiLocation.lineNum
ber, uiLocation.columnNumber); |
| 199 if (rawLocation) | 163 if (rawLocation) |
| 200 return this.rawLocationToUILocation(rawLocation); | 164 return this.rawLocationToUILocation(rawLocation); |
| 201 return uiLocation; | 165 return uiLocation; |
| 202 } | 166 } |
| 203 | 167 |
| 204 /** | 168 /** |
| 205 * @param {!Workspace.UISourceCode} uiSourceCode | 169 * @param {!Workspace.UISourceCode} uiSourceCode |
| 206 * @param {number} lineNumber | |
| 207 * @return {boolean} | |
| 208 */ | |
| 209 uiLineHasMapping(uiSourceCode, lineNumber) { | |
| 210 var sourceMapping = uiSourceCode[Bindings.DebuggerWorkspaceBinding._sourceMa
ppingSymbol]; | |
| 211 return sourceMapping ? sourceMapping.uiLineHasMapping(uiSourceCode, lineNumb
er) : true; | |
| 212 } | |
| 213 | |
| 214 /** | |
| 215 * @param {!Workspace.UISourceCode} uiSourceCode | |
| 216 */ | |
| 217 _uiSourceCodeRemoved(uiSourceCode) { | |
| 218 delete uiSourceCode[Bindings.DebuggerWorkspaceBinding._sourceMappingSymbol]; | |
| 219 } | |
| 220 | |
| 221 /** | |
| 222 * @param {!Workspace.UISourceCode} uiSourceCode | |
| 223 * @param {!SDK.DebuggerModel} debuggerModel | 170 * @param {!SDK.DebuggerModel} debuggerModel |
| 224 * @return {?Bindings.ResourceScriptFile} | 171 * @return {?Bindings.ResourceScriptFile} |
| 225 */ | 172 */ |
| 226 scriptFile(uiSourceCode, debuggerModel) { | 173 scriptFile(uiSourceCode, debuggerModel) { |
| 227 var modelData = this._debuggerModelToData.get(debuggerModel); | 174 var modelData = this._debuggerModelToData.get(debuggerModel); |
| 228 return modelData ? modelData._resourceMapping.scriptFile(uiSourceCode) : nul
l; | 175 return modelData ? modelData._resourceMapping.scriptFile(uiSourceCode) : nul
l; |
| 229 } | 176 } |
| 230 | 177 |
| 231 /** | 178 /** |
| 232 * @param {!SDK.Script} script | 179 * @param {!SDK.Script} script |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 /** | 257 /** |
| 311 * @param {!Common.Event} event | 258 * @param {!Common.Event} event |
| 312 */ | 259 */ |
| 313 _debuggerResumed(event) { | 260 _debuggerResumed(event) { |
| 314 var debuggerModel = /** @type {!SDK.DebuggerModel} */ (event.data); | 261 var debuggerModel = /** @type {!SDK.DebuggerModel} */ (event.data); |
| 315 this._reset(debuggerModel); | 262 this._reset(debuggerModel); |
| 316 } | 263 } |
| 317 }; | 264 }; |
| 318 | 265 |
| 319 Bindings.DebuggerWorkspaceBinding._scriptInfoSymbol = Symbol('scriptDataMap'); | 266 Bindings.DebuggerWorkspaceBinding._scriptInfoSymbol = Symbol('scriptDataMap'); |
| 320 Bindings.DebuggerWorkspaceBinding._sourceMappingSymbol = Symbol('sourceMapping')
; | |
| 321 | 267 |
| 322 /** | 268 /** |
| 323 * @unrestricted | 269 * @unrestricted |
| 324 */ | 270 */ |
| 325 Bindings.DebuggerWorkspaceBinding.ModelData = class { | 271 Bindings.DebuggerWorkspaceBinding.ModelData = class { |
| 326 /** | 272 /** |
| 327 * @param {!SDK.DebuggerModel} debuggerModel | 273 * @param {!SDK.DebuggerModel} debuggerModel |
| 328 * @param {!Bindings.DebuggerWorkspaceBinding} debuggerWorkspaceBinding | 274 * @param {!Bindings.DebuggerWorkspaceBinding} debuggerWorkspaceBinding |
| 329 */ | 275 */ |
| 330 constructor(debuggerModel, debuggerWorkspaceBinding) { | 276 constructor(debuggerModel, debuggerWorkspaceBinding) { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 344 this._eventListeners = [ | 290 this._eventListeners = [ |
| 345 debuggerModel.addEventListener(SDK.DebuggerModel.Events.ParsedScriptSource
, this._parsedScriptSource, this), | 291 debuggerModel.addEventListener(SDK.DebuggerModel.Events.ParsedScriptSource
, this._parsedScriptSource, this), |
| 346 debuggerModel.addEventListener( | 292 debuggerModel.addEventListener( |
| 347 SDK.DebuggerModel.Events.FailedToParseScriptSource, this._parsedScript
Source, this), | 293 SDK.DebuggerModel.Events.FailedToParseScriptSource, this._parsedScript
Source, this), |
| 348 debuggerModel.addEventListener( | 294 debuggerModel.addEventListener( |
| 349 SDK.DebuggerModel.Events.DiscardedAnonymousScriptSource, this._discard
edScriptSource, this) | 295 SDK.DebuggerModel.Events.DiscardedAnonymousScriptSource, this._discard
edScriptSource, this) |
| 350 ]; | 296 ]; |
| 351 } | 297 } |
| 352 | 298 |
| 353 /** | 299 /** |
| 300 * @param {!SDK.DebuggerModel.Location} rawLocation |
| 301 * @return {!Workspace.UILocation} |
| 302 */ |
| 303 _rawLocationToUILocation(rawLocation) { |
| 304 var uiLocation = null; |
| 305 uiLocation = uiLocation || this._compilerMapping.rawLocationToUILocation(raw
Location); |
| 306 uiLocation = uiLocation || this._resourceMapping.rawLocationToUILocation(raw
Location); |
| 307 uiLocation = uiLocation || this._defaultMapping.rawLocationToUILocation(rawL
ocation); |
| 308 // DefaultMapping ensures uiLocation for every rawLocation. |
| 309 console.assert(uiLocation); |
| 310 return /** @type {!Workspace.UILocation} */ (uiLocation); |
| 311 } |
| 312 |
| 313 /** |
| 314 * @param {!Workspace.UISourceCode} uiSourceCode |
| 315 * @param {number} lineNumber |
| 316 * @param {number} columnNumber |
| 317 * @return {?SDK.DebuggerModel.Location} |
| 318 */ |
| 319 _uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber) { |
| 320 var rawLocation = null; |
| 321 rawLocation = rawLocation || this._compilerMapping.uiLocationToRawLocation(u
iSourceCode, lineNumber, columnNumber); |
| 322 rawLocation = rawLocation || this._resourceMapping.uiLocationToRawLocation(u
iSourceCode, lineNumber, columnNumber); |
| 323 rawLocation = rawLocation || this._defaultMapping.uiLocationToRawLocation(ui
SourceCode, lineNumber, columnNumber); |
| 324 return rawLocation; |
| 325 } |
| 326 |
| 327 /** |
| 354 * @param {!SDK.DebuggerPausedDetails} debuggerPausedDetails | 328 * @param {!SDK.DebuggerPausedDetails} debuggerPausedDetails |
| 355 * @return {boolean} | 329 * @return {boolean} |
| 356 */ | 330 */ |
| 357 _beforePaused(debuggerPausedDetails) { | 331 _beforePaused(debuggerPausedDetails) { |
| 358 return !!this._compilerMapping.mapsToSourceCode(debuggerPausedDetails.callFr
ames[0].location()); | 332 return !!this._compilerMapping.mapsToSourceCode(debuggerPausedDetails.callFr
ames[0].location()); |
| 359 } | 333 } |
| 360 | 334 |
| 361 /** | 335 /** |
| 362 * @param {!Common.Event} event | 336 * @param {!Common.Event} event |
| 363 */ | 337 */ |
| (...skipping 13 matching lines...) Expand all Loading... |
| 377 | 351 |
| 378 _dispose() { | 352 _dispose() { |
| 379 this._debuggerModel.setBeforePausedCallback(null); | 353 this._debuggerModel.setBeforePausedCallback(null); |
| 380 Common.EventTarget.removeEventListeners(this._eventListeners); | 354 Common.EventTarget.removeEventListeners(this._eventListeners); |
| 381 this._compilerMapping.dispose(); | 355 this._compilerMapping.dispose(); |
| 382 this._resourceMapping.dispose(); | 356 this._resourceMapping.dispose(); |
| 383 this._defaultMapping.dispose(); | 357 this._defaultMapping.dispose(); |
| 384 } | 358 } |
| 385 }; | 359 }; |
| 386 | 360 |
| 387 /** @enum {symbol} */ | |
| 388 Bindings.DebuggerWorkspaceBinding.Events = { | |
| 389 SourceMappingChanged: Symbol('SourceMappingChanged'), | |
| 390 }; | |
| 391 | |
| 392 | |
| 393 /** | 361 /** |
| 394 * @unrestricted | 362 * @unrestricted |
| 395 */ | 363 */ |
| 396 Bindings.DebuggerWorkspaceBinding.ScriptInfo = class { | 364 Bindings.DebuggerWorkspaceBinding.ScriptInfo = class { |
| 397 /** | 365 /** |
| 398 * @param {!SDK.Script} script | 366 * @param {!SDK.Script} script |
| 399 */ | 367 */ |
| 400 constructor(script) { | 368 constructor(script) { |
| 401 this._script = script; | 369 this._script = script; |
| 402 // We create a lot of these, do not add arrays/collections/expensive data st
ructures. | 370 // We create a lot of these, do not add arrays/collections/expensive data st
ructures. |
| 403 } | 371 } |
| 404 | 372 |
| 405 /** | 373 /** |
| 406 * @param {!Bindings.DebuggerSourceMapping} sourceMapping | |
| 407 */ | |
| 408 _pushSourceMapping(sourceMapping) { | |
| 409 if (this._sourceMapping) { | |
| 410 if (!this._backupMappings) { | |
| 411 /** @type {!Array.<!Bindings.DebuggerSourceMapping>} */ | |
| 412 this._backupMappings = []; | |
| 413 } | |
| 414 this._backupMappings.push(this._sourceMapping); | |
| 415 } | |
| 416 this._sourceMapping = sourceMapping; | |
| 417 this._updateLocations(); | |
| 418 } | |
| 419 | |
| 420 /** | |
| 421 * @return {!Bindings.DebuggerSourceMapping} | |
| 422 */ | |
| 423 _popSourceMapping() { | |
| 424 var sourceMapping = this._sourceMapping; | |
| 425 this._sourceMapping = this._backupMappings ? this._backupMappings.pop() : un
defined; | |
| 426 this._updateLocations(); | |
| 427 return sourceMapping; | |
| 428 } | |
| 429 | |
| 430 /** | |
| 431 * @param {!Bindings.LiveLocation} location | 374 * @param {!Bindings.LiveLocation} location |
| 432 */ | 375 */ |
| 433 _addLocation(location) { | 376 _addLocation(location) { |
| 434 if (!this._locations) { | 377 if (!this._locations) { |
| 435 /** @type {!Set<!Bindings.LiveLocation>} */ | 378 /** @type {!Set<!Bindings.LiveLocation>} */ |
| 436 this._locations = new Set(); | 379 this._locations = new Set(); |
| 437 } | 380 } |
| 438 this._locations.add(location); | 381 this._locations.add(location); |
| 439 location.update(); | 382 location.update(); |
| 440 } | 383 } |
| 441 | 384 |
| 442 /** | 385 /** |
| 443 * @param {!Bindings.LiveLocation} location | 386 * @param {!Bindings.LiveLocation} location |
| 444 */ | 387 */ |
| 445 _removeLocation(location) { | 388 _removeLocation(location) { |
| 446 if (!this._locations) | 389 if (!this._locations) |
| 447 return; | 390 return; |
| 448 this._locations.delete(location); | 391 this._locations.delete(location); |
| 449 } | 392 } |
| 450 | 393 |
| 451 _updateLocations() { | 394 _updateLocations() { |
| 452 if (!this._locations) | 395 if (!this._locations) |
| 453 return; | 396 return; |
| 454 for (var location of this._locations) | 397 for (var location of this._locations) |
| 455 location.update(); | 398 location.update(); |
| 456 } | 399 } |
| 457 | |
| 458 /** | |
| 459 * @param {!SDK.DebuggerModel.Location} rawLocation | |
| 460 * @return {!Workspace.UILocation} | |
| 461 */ | |
| 462 _rawLocationToUILocation(rawLocation) { | |
| 463 var uiLocation = this._sourceMapping ? this._sourceMapping.rawLocationToUILo
cation(rawLocation) : null; | |
| 464 if (!uiLocation && this._backupMappings) { | |
| 465 for (var i = this._backupMappings.length - 1; !uiLocation && i >= 0; --i) | |
| 466 uiLocation = this._backupMappings[i].rawLocationToUILocation(rawLocation
); | |
| 467 } | |
| 468 console.assert(uiLocation, 'Script raw location cannot be mapped to any UI l
ocation.'); | |
| 469 return /** @type {!Workspace.UILocation} */ (uiLocation); | |
| 470 } | |
| 471 }; | 400 }; |
| 472 | 401 |
| 473 /** | 402 /** |
| 474 * @unrestricted | 403 * @unrestricted |
| 475 */ | 404 */ |
| 476 Bindings.DebuggerWorkspaceBinding.Location = class extends Bindings.LiveLocation
WithPool { | 405 Bindings.DebuggerWorkspaceBinding.Location = class extends Bindings.LiveLocation
WithPool { |
| 477 /** | 406 /** |
| 478 * @param {!SDK.Script} script | 407 * @param {!SDK.Script} script |
| 479 * @param {!SDK.DebuggerModel.Location} rawLocation | 408 * @param {!SDK.DebuggerModel.Location} rawLocation |
| 480 * @param {!Bindings.DebuggerWorkspaceBinding} binding | 409 * @param {!Bindings.DebuggerWorkspaceBinding} binding |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 */ | 521 */ |
| 593 rawLocationToUILocation(rawLocation) {}, | 522 rawLocationToUILocation(rawLocation) {}, |
| 594 | 523 |
| 595 /** | 524 /** |
| 596 * @param {!Workspace.UISourceCode} uiSourceCode | 525 * @param {!Workspace.UISourceCode} uiSourceCode |
| 597 * @param {number} lineNumber | 526 * @param {number} lineNumber |
| 598 * @param {number} columnNumber | 527 * @param {number} columnNumber |
| 599 * @return {?SDK.DebuggerModel.Location} | 528 * @return {?SDK.DebuggerModel.Location} |
| 600 */ | 529 */ |
| 601 uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber) {}, | 530 uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber) {}, |
| 602 | |
| 603 /** | |
| 604 * @return {boolean} | |
| 605 */ | |
| 606 isIdentity() {}, | |
| 607 | |
| 608 /** | |
| 609 * @param {!Workspace.UISourceCode} uiSourceCode | |
| 610 * @param {number} lineNumber | |
| 611 * @return {boolean} | |
| 612 */ | |
| 613 uiLineHasMapping(uiSourceCode, lineNumber) {} | |
| 614 }; | 531 }; |
| 615 | 532 |
| 616 /** | 533 /** |
| 617 * @type {!Bindings.DebuggerWorkspaceBinding} | 534 * @type {!Bindings.DebuggerWorkspaceBinding} |
| 618 */ | 535 */ |
| 619 Bindings.debuggerWorkspaceBinding; | 536 Bindings.debuggerWorkspaceBinding; |
| OLD | NEW |