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 * @implements {SDK.TargetManager.Observer} | 5 * @implements {SDK.TargetManager.Observer} |
6 * @unrestricted | 6 * @unrestricted |
7 */ | 7 */ |
8 Bindings.DebuggerWorkspaceBinding = class extends Common.Object { | 8 Bindings.DebuggerWorkspaceBinding = class extends Common.Object { |
9 /** | 9 /** |
10 * @param {!SDK.TargetManager} targetManager | 10 * @param {!SDK.TargetManager} targetManager |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 pushSourceMapping(script, sourceMapping) { | 79 pushSourceMapping(script, sourceMapping) { |
80 var info = this._ensureInfoForScript(script); | 80 var info = this._ensureInfoForScript(script); |
81 info._pushSourceMapping(sourceMapping); | 81 info._pushSourceMapping(sourceMapping); |
82 } | 82 } |
83 | 83 |
84 /** | 84 /** |
85 * @param {!SDK.Script} script | 85 * @param {!SDK.Script} script |
86 * @return {!Bindings.DebuggerSourceMapping} | 86 * @return {!Bindings.DebuggerSourceMapping} |
87 */ | 87 */ |
88 popSourceMapping(script) { | 88 popSourceMapping(script) { |
89 var info = this._infoForScript(script.target(), script.scriptId); | 89 var info = this._infoForScript(script); |
90 console.assert(info); | 90 console.assert(info); |
91 return info._popSourceMapping(); | 91 return info._popSourceMapping(); |
92 } | 92 } |
93 | 93 |
94 /** | 94 /** |
95 * @param {!SDK.Target} target | 95 * @param {!SDK.Target} target |
96 * @param {!Workspace.UISourceCode} uiSourceCode | 96 * @param {!Workspace.UISourceCode} uiSourceCode |
97 * @param {?Bindings.DebuggerSourceMapping} sourceMapping | 97 * @param {?Bindings.DebuggerSourceMapping} sourceMapping |
98 */ | 98 */ |
99 setSourceMapping(target, uiSourceCode, sourceMapping) { | 99 setSourceMapping(target, uiSourceCode, sourceMapping) { |
100 var data = this._targetToData.get(target); | 100 var data = this._targetToData.get(target); |
101 if (data) | 101 if (data) |
102 data._setSourceMapping(uiSourceCode, sourceMapping); | 102 data._setSourceMapping(uiSourceCode, sourceMapping); |
103 } | 103 } |
104 | 104 |
105 /** | 105 /** |
106 * @param {!SDK.Script} script | 106 * @param {!SDK.Script} script |
107 */ | 107 */ |
108 updateLocations(script) { | 108 updateLocations(script) { |
109 var info = this._infoForScript(script.target(), script.scriptId); | 109 var info = this._infoForScript(script); |
110 if (info) | 110 if (info) |
111 info._updateLocations(); | 111 info._updateLocations(); |
112 } | 112 } |
113 | 113 |
114 /** | 114 /** |
115 * @param {!SDK.DebuggerModel.Location} rawLocation | 115 * @param {!SDK.DebuggerModel.Location} rawLocation |
116 * @param {function(!Bindings.LiveLocation)} updateDelegate | 116 * @param {function(!Bindings.LiveLocation)} updateDelegate |
117 * @param {!Bindings.LiveLocationPool} locationPool | 117 * @param {!Bindings.LiveLocationPool} locationPool |
118 * @return {!Bindings.DebuggerWorkspaceBinding.Location} | 118 * @return {!Bindings.DebuggerWorkspaceBinding.Location} |
119 */ | 119 */ |
120 createLiveLocation(rawLocation, updateDelegate, locationPool) { | 120 createLiveLocation(rawLocation, updateDelegate, locationPool) { |
121 var info = this._infoForScript(rawLocation.target(), rawLocation.scriptId); | 121 var info = this._infoForScript(rawLocation.script()); |
122 console.assert(info); | 122 console.assert(info); |
123 var location = | 123 var location = |
124 new Bindings.DebuggerWorkspaceBinding.Location(info._script, rawLocation , this, updateDelegate, locationPool); | 124 new Bindings.DebuggerWorkspaceBinding.Location(info._script, rawLocation , this, updateDelegate, locationPool); |
125 info._addLocation(location); | 125 info._addLocation(location); |
126 return location; | 126 return location; |
127 } | 127 } |
128 | 128 |
129 /** | 129 /** |
130 * @param {!Array<!SDK.DebuggerModel.Location>} rawLocations | 130 * @param {!Array<!SDK.DebuggerModel.Location>} rawLocations |
131 * @param {function(!Bindings.LiveLocation)} updateDelegate | 131 * @param {function(!Bindings.LiveLocation)} updateDelegate |
(...skipping 23 matching lines...) Expand all Loading... | |
155 var liveLocation = this.createLiveLocation(location, updateDelegate, locatio nPool); | 155 var liveLocation = this.createLiveLocation(location, updateDelegate, locatio nPool); |
156 this._registerCallFrameLiveLocation(target, liveLocation); | 156 this._registerCallFrameLiveLocation(target, liveLocation); |
157 return liveLocation; | 157 return liveLocation; |
158 } | 158 } |
159 | 159 |
160 /** | 160 /** |
161 * @param {!SDK.DebuggerModel.Location} rawLocation | 161 * @param {!SDK.DebuggerModel.Location} rawLocation |
162 * @return {!Workspace.UILocation} | 162 * @return {!Workspace.UILocation} |
163 */ | 163 */ |
164 rawLocationToUILocation(rawLocation) { | 164 rawLocationToUILocation(rawLocation) { |
165 var info = this._infoForScript(rawLocation.target(), rawLocation.scriptId); | 165 var info = this._infoForScript(rawLocation.script()); |
166 console.assert(info); | 166 console.assert(info); |
167 return info._rawLocationToUILocation(rawLocation); | 167 return info._rawLocationToUILocation(rawLocation); |
168 } | 168 } |
169 | 169 |
170 /** | 170 /** |
171 * @param {!SDK.Target} target | 171 * @param {!SDK.Target} target |
172 * @param {!Workspace.UISourceCode} uiSourceCode | 172 * @param {!Workspace.UISourceCode} uiSourceCode |
173 * @param {number} lineNumber | 173 * @param {number} lineNumber |
174 * @param {number} columnNumber | 174 * @param {number} columnNumber |
175 * @return {?SDK.DebuggerModel.Location} | 175 * @return {?SDK.DebuggerModel.Location} |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
273 var targetData = this._targetToData.get(target); | 273 var targetData = this._targetToData.get(target); |
274 targetData.callFrameLocations.valuesArray().forEach((location) => this._remo veLiveLocation(location)); | 274 targetData.callFrameLocations.valuesArray().forEach((location) => this._remo veLiveLocation(location)); |
275 targetData.callFrameLocations.clear(); | 275 targetData.callFrameLocations.clear(); |
276 } | 276 } |
277 | 277 |
278 /** | 278 /** |
279 * @param {!SDK.Script} script | 279 * @param {!SDK.Script} script |
280 * @return {!Bindings.DebuggerWorkspaceBinding.ScriptInfo} | 280 * @return {!Bindings.DebuggerWorkspaceBinding.ScriptInfo} |
281 */ | 281 */ |
282 _ensureInfoForScript(script) { | 282 _ensureInfoForScript(script) { |
283 var scriptDataMap = this._targetToData.get(script.target()).scriptDataMap; | 283 var info = script[Bindings.DebuggerWorkspaceBinding._scriptInfoSymbol]; |
284 var info = scriptDataMap.get(script.scriptId); | |
285 if (!info) { | 284 if (!info) { |
286 info = new Bindings.DebuggerWorkspaceBinding.ScriptInfo(script); | 285 info = new Bindings.DebuggerWorkspaceBinding.ScriptInfo(script); |
287 scriptDataMap.set(script.scriptId, info); | 286 script[Bindings.DebuggerWorkspaceBinding._scriptInfoSymbol] = info; |
288 } | 287 } |
289 return info; | 288 return info; |
290 } | 289 } |
291 | 290 |
292 /** | 291 /** |
293 * @param {!SDK.Target} target | 292 * @param {?SDK.Script} script |
294 * @param {string} scriptId | |
295 * @return {?Bindings.DebuggerWorkspaceBinding.ScriptInfo} | 293 * @return {?Bindings.DebuggerWorkspaceBinding.ScriptInfo} |
296 */ | 294 */ |
297 _infoForScript(target, scriptId) { | 295 _infoForScript(script) { |
298 var data = this._targetToData.get(target); | 296 if (!script) |
299 if (!data) | |
300 return null; | 297 return null; |
301 return data.scriptDataMap.get(scriptId) || null; | 298 return script[Bindings.DebuggerWorkspaceBinding._scriptInfoSymbol] || null; |
302 } | 299 } |
303 | 300 |
304 /** | 301 /** |
305 * @param {!SDK.Target} target | 302 * @param {!SDK.Target} target |
306 * @param {!Bindings.DebuggerWorkspaceBinding.Location} location | 303 * @param {!Bindings.DebuggerWorkspaceBinding.Location} location |
307 */ | 304 */ |
308 _registerCallFrameLiveLocation(target, location) { | 305 _registerCallFrameLiveLocation(target, location) { |
309 var locations = this._targetToData.get(target).callFrameLocations; | 306 var locations = this._targetToData.get(target).callFrameLocations; |
310 locations.add(location); | 307 locations.add(location); |
311 } | 308 } |
312 | 309 |
313 /** | 310 /** |
314 * @param {!Bindings.DebuggerWorkspaceBinding.Location} location | 311 * @param {!Bindings.DebuggerWorkspaceBinding.Location} location |
315 */ | 312 */ |
316 _removeLiveLocation(location) { | 313 _removeLiveLocation(location) { |
317 var info = this._infoForScript(location._script.target(), location._script.s criptId); | 314 var info = this._infoForScript(location._script); |
318 if (info) | 315 if (info) |
319 info._removeLocation(location); | 316 info._removeLocation(location); |
320 } | 317 } |
321 | 318 |
322 /** | 319 /** |
323 * @param {!Common.Event} event | 320 * @param {!Common.Event} event |
324 */ | 321 */ |
325 _debuggerResumed(event) { | 322 _debuggerResumed(event) { |
326 var debuggerModel = /** @type {!SDK.DebuggerModel} */ (event.data); | 323 var debuggerModel = /** @type {!SDK.DebuggerModel} */ (event.data); |
327 this._reset(debuggerModel.target()); | 324 this._reset(debuggerModel.target()); |
328 } | 325 } |
329 }; | 326 }; |
330 | 327 |
328 Bindings.DebuggerWorkspaceBinding._scriptInfoSymbol = Symbol('scriptDataMap'); | |
329 Bindings.DebuggerWorkspaceBinding._sourceMappingSymbol = Symbol('sourceMapping') ; | |
330 | |
331 /** | 331 /** |
332 * @unrestricted | 332 * @unrestricted |
333 */ | 333 */ |
334 Bindings.DebuggerWorkspaceBinding.TargetData = class { | 334 Bindings.DebuggerWorkspaceBinding.TargetData = class { |
335 /** | 335 /** |
336 * @param {!SDK.DebuggerModel} debuggerModel | 336 * @param {!SDK.DebuggerModel} debuggerModel |
337 * @param {!Bindings.DebuggerWorkspaceBinding} debuggerWorkspaceBinding | 337 * @param {!Bindings.DebuggerWorkspaceBinding} debuggerWorkspaceBinding |
338 */ | 338 */ |
339 constructor(debuggerModel, debuggerWorkspaceBinding) { | 339 constructor(debuggerModel, debuggerWorkspaceBinding) { |
340 this._debuggerModel = debuggerModel; | 340 this._debuggerModel = debuggerModel; |
341 this._debuggerWorkspaceBinding = debuggerWorkspaceBinding; | 341 this._debuggerWorkspaceBinding = debuggerWorkspaceBinding; |
342 | 342 |
343 /** @type {!Map.<string, !Bindings.DebuggerWorkspaceBinding.ScriptInfo>} */ | |
344 this.scriptDataMap = new Map(); | |
345 | |
346 /** @type {!Set.<!Bindings.DebuggerWorkspaceBinding.Location>} */ | 343 /** @type {!Set.<!Bindings.DebuggerWorkspaceBinding.Location>} */ |
347 this.callFrameLocations = new Set(); | 344 this.callFrameLocations = new Set(); |
348 | 345 |
349 var workspace = debuggerWorkspaceBinding._workspace; | 346 var workspace = debuggerWorkspaceBinding._workspace; |
350 | 347 |
351 this._defaultMapping = new Bindings.DefaultScriptMapping(debuggerModel, work space, debuggerWorkspaceBinding); | 348 this._defaultMapping = new Bindings.DefaultScriptMapping(debuggerModel, work space, debuggerWorkspaceBinding); |
352 this._resourceMapping = new Bindings.ResourceScriptMapping(debuggerModel, wo rkspace, debuggerWorkspaceBinding); | 349 this._resourceMapping = new Bindings.ResourceScriptMapping(debuggerModel, wo rkspace, debuggerWorkspaceBinding); |
353 this._compilerMapping = new Bindings.CompilerScriptMapping( | 350 this._compilerMapping = new Bindings.CompilerScriptMapping( |
354 debuggerModel, workspace, Bindings.NetworkProject.forTarget(this._debugg erModel.target()), | 351 debuggerModel, workspace, Bindings.NetworkProject.forTarget(this._debugg erModel.target()), |
355 debuggerWorkspaceBinding); | 352 debuggerWorkspaceBinding); |
356 | 353 |
357 /** @type {!Map.<!Workspace.UISourceCode, !Bindings.DebuggerSourceMapping>} */ | |
358 this._uiSourceCodeToSourceMapping = new Map(); | |
359 | |
360 debuggerModel.setBeforePausedCallback(this._beforePaused.bind(this)); | 354 debuggerModel.setBeforePausedCallback(this._beforePaused.bind(this)); |
361 this._eventListeners = [ | 355 this._eventListeners = [ |
362 debuggerModel.addEventListener(SDK.DebuggerModel.Events.ParsedScriptSource , this._parsedScriptSource, this), | 356 debuggerModel.addEventListener(SDK.DebuggerModel.Events.ParsedScriptSource , this._parsedScriptSource, this), |
363 debuggerModel.addEventListener(SDK.DebuggerModel.Events.FailedToParseScrip tSource, this._parsedScriptSource, this) | 357 debuggerModel.addEventListener( |
358 SDK.DebuggerModel.Events.FailedToParseScriptSource, this._parsedScript Source, this), | |
364 ]; | 359 ]; |
365 } | 360 } |
366 | 361 |
367 /** | 362 /** |
368 * @param {!SDK.DebuggerPausedDetails} debuggerPausedDetails | 363 * @param {!SDK.DebuggerPausedDetails} debuggerPausedDetails |
369 * @return {boolean} | 364 * @return {boolean} |
370 */ | 365 */ |
371 _beforePaused(debuggerPausedDetails) { | 366 _beforePaused(debuggerPausedDetails) { |
372 return !!this._compilerMapping.mapsToSourceCode(debuggerPausedDetails.callFr ames[0].location()); | 367 return !!this._compilerMapping.mapsToSourceCode(debuggerPausedDetails.callFr ames[0].location()); |
373 } | 368 } |
374 | 369 |
375 /** | 370 /** |
376 * @param {!Common.Event} event | 371 * @param {!Common.Event} event |
377 */ | 372 */ |
378 _parsedScriptSource(event) { | 373 _parsedScriptSource(event) { |
379 var script = /** @type {!SDK.Script} */ (event.data); | 374 var script = /** @type {!SDK.Script} */ (event.data); |
380 this._defaultMapping.addScript(script); | 375 this._defaultMapping.addScript(script); |
381 this._resourceMapping.addScript(script); | 376 this._resourceMapping.addScript(script); |
382 | 377 |
383 if (Common.moduleSetting('jsSourceMapsEnabled').get()) | 378 if (Common.moduleSetting('jsSourceMapsEnabled').get()) |
384 this._compilerMapping.addScript(script); | 379 this._compilerMapping.addScript(script); |
385 } | 380 } |
386 | 381 |
387 /** | 382 /** |
388 * @param {!Workspace.UISourceCode} uiSourceCode | 383 * @param {!Workspace.UISourceCode} uiSourceCode |
389 * @param {?Bindings.DebuggerSourceMapping} sourceMapping | 384 * @param {?Bindings.DebuggerSourceMapping} sourceMapping |
390 */ | 385 */ |
391 _setSourceMapping(uiSourceCode, sourceMapping) { | 386 _setSourceMapping(uiSourceCode, sourceMapping) { |
392 if (this._uiSourceCodeToSourceMapping.get(uiSourceCode) === sourceMapping) | 387 if (uiSourceCode[Bindings.DebuggerWorkspaceBinding._sourceMappingSymbol] === sourceMapping) |
393 return; | 388 return; |
394 | 389 |
395 if (sourceMapping) | 390 if (sourceMapping) |
396 this._uiSourceCodeToSourceMapping.set(uiSourceCode, sourceMapping); | 391 uiSourceCode[Bindings.DebuggerWorkspaceBinding._sourceMappingSymbol] = sou rceMapping; |
397 else | 392 else |
398 this._uiSourceCodeToSourceMapping.remove(uiSourceCode); | 393 delete uiSourceCode[Bindings.DebuggerWorkspaceBinding._sourceMappingSymbol ]; |
399 | 394 |
400 this._debuggerWorkspaceBinding.dispatchEventToListeners(Bindings.DebuggerWor kspaceBinding.Events.SourceMappingChanged, { | 395 this._debuggerWorkspaceBinding.dispatchEventToListeners( |
401 uiSourceCode: uiSourceCode, | 396 Bindings.DebuggerWorkspaceBinding.Events.SourceMappingChanged, { |
402 target: this._debuggerModel.target(), | 397 uiSourceCode: uiSourceCode, |
403 isIdentity: sourceMapping ? sourceMapping.isIdentity() : false | 398 target: this._debuggerModel.target(), |
404 }); | 399 isIdentity: sourceMapping ? sourceMapping.isIdentity() : false |
400 }); | |
405 } | 401 } |
406 | 402 |
407 /** | 403 /** |
408 * @param {!Workspace.UISourceCode} uiSourceCode | 404 * @param {!Workspace.UISourceCode} uiSourceCode |
409 * @param {number} lineNumber | 405 * @param {number} lineNumber |
410 * @param {number} columnNumber | 406 * @param {number} columnNumber |
411 * @return {?SDK.DebuggerModel.Location} | 407 * @return {?SDK.DebuggerModel.Location} |
412 */ | 408 */ |
413 _uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber) { | 409 _uiLocationToRawLocation(uiSourceCode, lineNumber, columnNumber) { |
414 var sourceMapping = this._uiSourceCodeToSourceMapping.get(uiSourceCode); | 410 var sourceMapping = uiSourceCode[Bindings.DebuggerWorkspaceBinding._sourceMa ppingSymbol]; |
415 return sourceMapping ? sourceMapping.uiLocationToRawLocation(uiSourceCode, l ineNumber, columnNumber) : null; | 411 return sourceMapping ? sourceMapping.uiLocationToRawLocation(uiSourceCode, l ineNumber, columnNumber) : null; |
416 } | 412 } |
417 | 413 |
418 /** | 414 /** |
419 * @param {!Workspace.UISourceCode} uiSourceCode | 415 * @param {!Workspace.UISourceCode} uiSourceCode |
420 * @param {number} lineNumber | 416 * @param {number} lineNumber |
421 * @return {boolean} | 417 * @return {boolean} |
422 */ | 418 */ |
423 _uiLineHasMapping(uiSourceCode, lineNumber) { | 419 _uiLineHasMapping(uiSourceCode, lineNumber) { |
424 var sourceMapping = this._uiSourceCodeToSourceMapping.get(uiSourceCode); | 420 var sourceMapping = uiSourceCode[Bindings.DebuggerWorkspaceBinding._sourceMa ppingSymbol]; |
425 return sourceMapping ? sourceMapping.uiLineHasMapping(uiSourceCode, lineNumb er) : true; | 421 return sourceMapping ? sourceMapping.uiLineHasMapping(uiSourceCode, lineNumb er) : true; |
426 } | 422 } |
427 | 423 |
428 /** | 424 /** |
429 * @param {!Workspace.UISourceCode} uiSourceCode | 425 * @param {!Workspace.UISourceCode} uiSourceCode |
430 */ | 426 */ |
431 _uiSourceCodeRemoved(uiSourceCode) { | 427 _uiSourceCodeRemoved(uiSourceCode) { |
432 this._uiSourceCodeToSourceMapping.remove(uiSourceCode); | 428 delete uiSourceCode[Bindings.DebuggerWorkspaceBinding._sourceMappingSymbol]; |
433 } | 429 } |
434 | 430 |
435 _dispose() { | 431 _dispose() { |
436 this._debuggerModel.setBeforePausedCallback(null); | 432 this._debuggerModel.setBeforePausedCallback(null); |
437 Common.EventTarget.removeEventListeners(this._eventListeners); | 433 Common.EventTarget.removeEventListeners(this._eventListeners); |
438 this._compilerMapping.dispose(); | 434 this._compilerMapping.dispose(); |
439 this._resourceMapping.dispose(); | 435 this._resourceMapping.dispose(); |
440 this._defaultMapping.dispose(); | 436 this._defaultMapping.dispose(); |
441 this._uiSourceCodeToSourceMapping.clear(); | |
442 } | 437 } |
443 }; | 438 }; |
444 | 439 |
445 /** @enum {symbol} */ | 440 /** @enum {symbol} */ |
446 Bindings.DebuggerWorkspaceBinding.Events = { | 441 Bindings.DebuggerWorkspaceBinding.Events = { |
447 SourceMappingChanged: Symbol('SourceMappingChanged'), | 442 SourceMappingChanged: Symbol('SourceMappingChanged'), |
448 }; | 443 }; |
449 | 444 |
450 | 445 |
451 /** | 446 /** |
452 * @unrestricted | 447 * @unrestricted |
453 */ | 448 */ |
454 Bindings.DebuggerWorkspaceBinding.ScriptInfo = class { | 449 Bindings.DebuggerWorkspaceBinding.ScriptInfo = class { |
455 /** | 450 /** |
456 * @param {!SDK.Script} script | 451 * @param {!SDK.Script} script |
457 */ | 452 */ |
458 constructor(script) { | 453 constructor(script) { |
459 this._script = script; | 454 this._script = script; |
460 | 455 // We create a lot of these, do not add arrays/collections/expensive data st ructures. |
461 /** @type {!Array.<!Bindings.DebuggerSourceMapping>} */ | |
462 this._sourceMappings = []; | |
463 | |
464 /** @type {!Set<!Bindings.LiveLocation>} */ | |
465 this._locations = new Set(); | |
466 } | 456 } |
467 | 457 |
468 /** | 458 /** |
469 * @param {!Bindings.DebuggerSourceMapping} sourceMapping | 459 * @param {!Bindings.DebuggerSourceMapping} sourceMapping |
470 */ | 460 */ |
471 _pushSourceMapping(sourceMapping) { | 461 _pushSourceMapping(sourceMapping) { |
472 this._sourceMappings.push(sourceMapping); | 462 if (this._sourceMapping) { |
463 if (!this._backupMappings) { | |
464 /** @type {!Array.<!Bindings.DebuggerSourceMapping>} */ | |
465 this._backupMappings = []; | |
466 } | |
467 this._backupMappings.push(this._sourceMapping); | |
468 } | |
469 this._sourceMapping = sourceMapping; | |
473 this._updateLocations(); | 470 this._updateLocations(); |
474 } | 471 } |
475 | 472 |
476 /** | 473 /** |
477 * @return {!Bindings.DebuggerSourceMapping} | 474 * @return {!Bindings.DebuggerSourceMapping} |
478 */ | 475 */ |
479 _popSourceMapping() { | 476 _popSourceMapping() { |
480 var sourceMapping = this._sourceMappings.pop(); | 477 var sourceMapping = this._sourceMapping; |
478 this._sourceMapping = this._backupMappings.pop(); | |
dgozman
2017/01/04 01:04:08
this._backupMappings could be undefined
pfeldman
2017/01/04 01:13:47
Done.
| |
481 this._updateLocations(); | 479 this._updateLocations(); |
482 return sourceMapping; | 480 return sourceMapping; |
483 } | 481 } |
484 | 482 |
485 /** | 483 /** |
486 * @param {!Bindings.LiveLocation} location | 484 * @param {!Bindings.LiveLocation} location |
487 */ | 485 */ |
488 _addLocation(location) { | 486 _addLocation(location) { |
487 if (!this._locations) { | |
488 /** @type {!Set<!Bindings.LiveLocation>} */ | |
489 this._locations = new Set(); | |
490 } | |
489 this._locations.add(location); | 491 this._locations.add(location); |
490 location.update(); | 492 location.update(); |
491 } | 493 } |
492 | 494 |
493 /** | 495 /** |
494 * @param {!Bindings.LiveLocation} location | 496 * @param {!Bindings.LiveLocation} location |
495 */ | 497 */ |
496 _removeLocation(location) { | 498 _removeLocation(location) { |
499 if (!this._locations) | |
500 return; | |
497 this._locations.delete(location); | 501 this._locations.delete(location); |
498 } | 502 } |
499 | 503 |
500 _updateLocations() { | 504 _updateLocations() { |
505 if (!this._locations) | |
506 return; | |
501 for (var location of this._locations) | 507 for (var location of this._locations) |
502 location.update(); | 508 location.update(); |
503 } | 509 } |
504 | 510 |
505 /** | 511 /** |
506 * @param {!SDK.DebuggerModel.Location} rawLocation | 512 * @param {!SDK.DebuggerModel.Location} rawLocation |
507 * @return {!Workspace.UILocation} | 513 * @return {!Workspace.UILocation} |
508 */ | 514 */ |
509 _rawLocationToUILocation(rawLocation) { | 515 _rawLocationToUILocation(rawLocation) { |
510 var uiLocation; | 516 var uiLocation = this._sourceMapping ? this._sourceMapping.rawLocationToUILo cation(rawLocation) : null; |
511 for (var i = this._sourceMappings.length - 1; !uiLocation && i >= 0; --i) | 517 if (!uiLocation && this._backupMappings) { |
512 uiLocation = this._sourceMappings[i].rawLocationToUILocation(rawLocation); | 518 for (var i = this._backupMappings.length - 1; !uiLocation && i >= 0; --i) |
519 uiLocation = this._backupMappings[i].rawLocationToUILocation(rawLocation ); | |
520 } | |
513 console.assert(uiLocation, 'Script raw location cannot be mapped to any UI l ocation.'); | 521 console.assert(uiLocation, 'Script raw location cannot be mapped to any UI l ocation.'); |
514 return /** @type {!Workspace.UILocation} */ (uiLocation); | 522 return /** @type {!Workspace.UILocation} */ (uiLocation); |
515 } | 523 } |
516 }; | 524 }; |
517 | 525 |
518 /** | 526 /** |
519 * @unrestricted | 527 * @unrestricted |
520 */ | 528 */ |
521 Bindings.DebuggerWorkspaceBinding.Location = class extends Bindings.LiveLocation WithPool { | 529 Bindings.DebuggerWorkspaceBinding.Location = class extends Bindings.LiveLocation WithPool { |
522 /** | 530 /** |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
655 * @param {number} lineNumber | 663 * @param {number} lineNumber |
656 * @return {boolean} | 664 * @return {boolean} |
657 */ | 665 */ |
658 uiLineHasMapping(uiSourceCode, lineNumber) {} | 666 uiLineHasMapping(uiSourceCode, lineNumber) {} |
659 }; | 667 }; |
660 | 668 |
661 /** | 669 /** |
662 * @type {!Bindings.DebuggerWorkspaceBinding} | 670 * @type {!Bindings.DebuggerWorkspaceBinding} |
663 */ | 671 */ |
664 Bindings.debuggerWorkspaceBinding; | 672 Bindings.debuggerWorkspaceBinding; |
OLD | NEW |