| 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 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @implements {WebInspector.DebuggerSourceMapping} | 7 * @implements {WebInspector.DebuggerSourceMapping} |
| 8 * @param {!WebInspector.DebuggerModel} debuggerModel | 8 * @param {!WebInspector.DebuggerModel} debuggerModel |
| 9 * @param {!WebInspector.ScriptFormatterEditorAction} editorAction | 9 * @param {!WebInspector.ScriptFormatterEditorAction} editorAction |
| 10 */ | 10 */ |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 } | 96 } |
| 97 | 97 |
| 98 /** | 98 /** |
| 99 * @constructor | 99 * @constructor |
| 100 * @implements {WebInspector.SourcesView.EditorAction} | 100 * @implements {WebInspector.SourcesView.EditorAction} |
| 101 * @implements {WebInspector.TargetManager.Observer} | 101 * @implements {WebInspector.TargetManager.Observer} |
| 102 */ | 102 */ |
| 103 WebInspector.ScriptFormatterEditorAction = function() | 103 WebInspector.ScriptFormatterEditorAction = function() |
| 104 { | 104 { |
| 105 this._projectId = "formatter:"; | 105 this._projectId = "formatter:"; |
| 106 this._project = new WebInspector.ContentProviderBasedProject(WebInspector.wo
rkspace, this._projectId, WebInspector.projectTypes.Formatter, "", "formatter"); | 106 this._project = new WebInspector.ContentProviderBasedProject(WebInspector.wo
rkspace, this._projectId, WebInspector.projectTypes.Formatter, "formatter"); |
| 107 | 107 |
| 108 /** @type {!Map.<!WebInspector.Script, !WebInspector.UISourceCode>} */ | 108 /** @type {!Map.<!WebInspector.Script, !WebInspector.UISourceCode>} */ |
| 109 this._uiSourceCodes = new Map(); | 109 this._uiSourceCodes = new Map(); |
| 110 /** @type {!Map.<string, string>} */ | 110 /** @type {!Map.<string, string>} */ |
| 111 this._formattedPaths = new Map(); | 111 this._formattedPaths = new Map(); |
| 112 /** @type {!Map.<!WebInspector.UISourceCode, !WebInspector.FormatterScriptMa
pping.FormatData>} */ | 112 /** @type {!Map.<!WebInspector.UISourceCode, !WebInspector.FormatterScriptMa
pping.FormatData>} */ |
| 113 this._formatData = new Map(); | 113 this._formatData = new Map(); |
| 114 | 114 |
| 115 /** @type {!Set.<string>} */ | 115 /** @type {!Set.<string>} */ |
| 116 this._pathsToFormatOnLoad = new Set(); | 116 this._pathsToFormatOnLoad = new Set(); |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 363 } | 363 } |
| 364 | 364 |
| 365 /** | 365 /** |
| 366 * @this {WebInspector.ScriptFormatterEditorAction} | 366 * @this {WebInspector.ScriptFormatterEditorAction} |
| 367 * @param {string} formattedContent | 367 * @param {string} formattedContent |
| 368 * @param {!WebInspector.FormatterSourceMapping} formatterMapping | 368 * @param {!WebInspector.FormatterSourceMapping} formatterMapping |
| 369 */ | 369 */ |
| 370 function innerCallback(formattedContent, formatterMapping) | 370 function innerCallback(formattedContent, formatterMapping) |
| 371 { | 371 { |
| 372 var scripts = this._scriptsForUISourceCode(uiSourceCode); | 372 var scripts = this._scriptsForUISourceCode(uiSourceCode); |
| 373 var name; | |
| 374 if (uiSourceCode.contentType() === WebInspector.resourceTypes.Docume
nt) | |
| 375 name = uiSourceCode.displayName(); | |
| 376 else | |
| 377 name = uiSourceCode.name() || (scripts.length ? scripts[0].scrip
tId : ""); | |
| 378 | |
| 379 var networkURL = WebInspector.networkMapping.networkURL(uiSourceCode
); | |
| 380 | |
| 381 var contentProvider = new WebInspector.StaticContentProvider(uiSourc
eCode.contentType(), formattedContent); | 373 var contentProvider = new WebInspector.StaticContentProvider(uiSourc
eCode.contentType(), formattedContent); |
| 382 var formattedUISourceCode = this._project.addContentProvider(network
URL, name + ":formatted", networkURL, contentProvider); | 374 var formattedUISourceCode = this._project.addContentProvider(uiSourc
eCode.path() + ":formatted", contentProvider); |
| 383 var formattedPath = formattedUISourceCode.path(); | 375 var formattedPath = formattedUISourceCode.path(); |
| 384 var formatData = new WebInspector.FormatterScriptMapping.FormatData(
uiSourceCode.project().id(), uiSourceCode.path(), formatterMapping, scripts); | 376 var formatData = new WebInspector.FormatterScriptMapping.FormatData(
uiSourceCode.project().id(), uiSourceCode.path(), formatterMapping, scripts); |
| 385 this._formatData.set(formattedUISourceCode, formatData); | 377 this._formatData.set(formattedUISourceCode, formatData); |
| 386 var path = uiSourceCode.project().id() + ":" + uiSourceCode.path(); | 378 var path = uiSourceCode.project().id() + ":" + uiSourceCode.path(); |
| 387 this._formattedPaths.set(path, formattedPath); | 379 this._formattedPaths.set(path, formattedPath); |
| 388 this._pathsToFormatOnLoad.add(path); | 380 this._pathsToFormatOnLoad.add(path); |
| 389 for (var i = 0; i < scripts.length; ++i) { | 381 for (var i = 0; i < scripts.length; ++i) { |
| 390 this._uiSourceCodes.set(scripts[i], formattedUISourceCode); | 382 this._uiSourceCodes.set(scripts[i], formattedUISourceCode); |
| 391 var scriptMapping = /** @type {!WebInspector.FormatterScriptMapp
ing} */(this._scriptMappingByTarget.get(scripts[i].target())); | 383 var scriptMapping = /** @type {!WebInspector.FormatterScriptMapp
ing} */(this._scriptMappingByTarget.get(scripts[i].target())); |
| 392 WebInspector.debuggerWorkspaceBinding.pushSourceMapping(scripts[
i], scriptMapping); | 384 WebInspector.debuggerWorkspaceBinding.pushSourceMapping(scripts[
i], scriptMapping); |
| 393 } | 385 } |
| 394 | 386 |
| 395 var targets = WebInspector.targetManager.targets(); | 387 var targets = WebInspector.targetManager.targets(); |
| 396 for (var i = 0; i < targets.length; ++i) { | 388 for (var i = 0; i < targets.length; ++i) { |
| 397 var scriptMapping = /** @type {!WebInspector.FormatterScriptMapp
ing} */(this._scriptMappingByTarget.get(targets[i])); | 389 var scriptMapping = /** @type {!WebInspector.FormatterScriptMapp
ing} */(this._scriptMappingByTarget.get(targets[i])); |
| 398 WebInspector.debuggerWorkspaceBinding.setSourceMapping(targets[i
], formattedUISourceCode, scriptMapping); | 390 WebInspector.debuggerWorkspaceBinding.setSourceMapping(targets[i
], formattedUISourceCode, scriptMapping); |
| 399 } | 391 } |
| 400 this._showIfNeeded(uiSourceCode, formattedUISourceCode, formatterMap
ping); | 392 this._showIfNeeded(uiSourceCode, formattedUISourceCode, formatterMap
ping); |
| 401 } | 393 } |
| 402 } | 394 } |
| 403 } | 395 } |
| OLD | NEW |