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 {Bindings.DebuggerSourceMapping} | 5 * @implements {Bindings.DebuggerSourceMapping} |
6 * @unrestricted | 6 * @unrestricted |
7 */ | 7 */ |
8 Sources.FormatterScriptMapping = class { | 8 Sources.FormatterScriptMapping = class { |
9 /** | 9 /** |
10 * @param {!SDK.DebuggerModel} debuggerModel | 10 * @param {!SDK.DebuggerModel} debuggerModel |
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 */ | 187 */ |
188 button(sourcesView) { | 188 button(sourcesView) { |
189 if (this._button) | 189 if (this._button) |
190 return this._button; | 190 return this._button; |
191 | 191 |
192 this._sourcesView = sourcesView; | 192 this._sourcesView = sourcesView; |
193 this._sourcesView.addEventListener(Sources.SourcesView.Events.EditorSelected
, this._editorSelected.bind(this)); | 193 this._sourcesView.addEventListener(Sources.SourcesView.Events.EditorSelected
, this._editorSelected.bind(this)); |
194 this._sourcesView.addEventListener(Sources.SourcesView.Events.EditorClosed,
this._editorClosed.bind(this)); | 194 this._sourcesView.addEventListener(Sources.SourcesView.Events.EditorClosed,
this._editorClosed.bind(this)); |
195 | 195 |
196 this._button = new UI.ToolbarButton(Common.UIString('Pretty print'), 'largei
con-pretty-print'); | 196 this._button = new UI.ToolbarButton(Common.UIString('Pretty print'), 'largei
con-pretty-print'); |
197 this._button.addEventListener('click', this._toggleFormatScriptSource, this)
; | 197 this._button.addEventListener(UI.ToolbarButton.Events.Click, this._toggleFor
matScriptSource, this); |
198 this._updateButton(sourcesView.currentUISourceCode()); | 198 this._updateButton(sourcesView.currentUISourceCode()); |
199 | 199 |
200 return this._button; | 200 return this._button; |
201 } | 201 } |
202 | 202 |
203 /** | 203 /** |
204 * @param {?Workspace.UISourceCode} uiSourceCode | 204 * @param {?Workspace.UISourceCode} uiSourceCode |
205 * @return {boolean} | 205 * @return {boolean} |
206 */ | 206 */ |
207 _isFormatableScript(uiSourceCode) { | 207 _isFormatableScript(uiSourceCode) { |
208 if (!uiSourceCode) | 208 if (!uiSourceCode) |
209 return false; | 209 return false; |
210 if (uiSourceCode.project().canSetFileContent()) | 210 if (uiSourceCode.project().canSetFileContent()) |
211 return false; | 211 return false; |
212 if (uiSourceCode.project().type() === Workspace.projectTypes.Formatter) | 212 if (uiSourceCode.project().type() === Workspace.projectTypes.Formatter) |
213 return false; | 213 return false; |
214 if (Persistence.persistence.binding(uiSourceCode)) | 214 if (Persistence.persistence.binding(uiSourceCode)) |
215 return false; | 215 return false; |
216 return uiSourceCode.contentType().hasScripts(); | 216 return uiSourceCode.contentType().hasScripts(); |
217 } | 217 } |
218 | 218 |
219 _toggleFormatScriptSource() { | 219 /** |
| 220 * @param {!Common.Event} event |
| 221 */ |
| 222 _toggleFormatScriptSource(event) { |
220 var uiSourceCode = this._sourcesView.currentUISourceCode(); | 223 var uiSourceCode = this._sourcesView.currentUISourceCode(); |
221 if (this._isFormatableScript(uiSourceCode)) | 224 if (this._isFormatableScript(uiSourceCode)) |
222 this._formatUISourceCodeScript(uiSourceCode); | 225 this._formatUISourceCodeScript(uiSourceCode); |
223 } | 226 } |
224 | 227 |
225 /** | 228 /** |
226 * @param {!Workspace.UISourceCode} uiSourceCode | 229 * @param {!Workspace.UISourceCode} uiSourceCode |
227 * @param {!Workspace.UISourceCode} formattedUISourceCode | 230 * @param {!Workspace.UISourceCode} formattedUISourceCode |
228 * @param {!Sources.FormatterSourceMapping} mapping | 231 * @param {!Sources.FormatterSourceMapping} mapping |
229 * @private | 232 * @private |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 var targets = SDK.targetManager.targets(); | 381 var targets = SDK.targetManager.targets(); |
379 for (var i = 0; i < targets.length; ++i) { | 382 for (var i = 0; i < targets.length; ++i) { |
380 var scriptMapping = | 383 var scriptMapping = |
381 /** @type {!Sources.FormatterScriptMapping} */ (this._scriptMappingB
yTarget.get(targets[i])); | 384 /** @type {!Sources.FormatterScriptMapping} */ (this._scriptMappingB
yTarget.get(targets[i])); |
382 Bindings.debuggerWorkspaceBinding.setSourceMapping(targets[i], formatted
UISourceCode, scriptMapping); | 385 Bindings.debuggerWorkspaceBinding.setSourceMapping(targets[i], formatted
UISourceCode, scriptMapping); |
383 } | 386 } |
384 this._showIfNeeded(uiSourceCode, formattedUISourceCode, formatterMapping); | 387 this._showIfNeeded(uiSourceCode, formattedUISourceCode, formatterMapping); |
385 } | 388 } |
386 } | 389 } |
387 }; | 390 }; |
OLD | NEW |