OLD | NEW |
1 | 1 |
2 // Copyright 2014 The Chromium Authors. All rights reserved. | 2 // Copyright 2014 The Chromium Authors. All rights reserved. |
3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
5 | 5 |
6 /** | 6 /** |
7 * @constructor | 7 * @constructor |
8 * @implements {WebInspector.SourcesView.EditorAction} | 8 * @implements {WebInspector.SourcesView.EditorAction} |
9 */ | 9 */ |
10 WebInspector.InplaceFormatterEditorAction = function() | 10 WebInspector.InplaceFormatterEditorAction = function() |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 | 76 |
77 _formatSourceInPlace: function() | 77 _formatSourceInPlace: function() |
78 { | 78 { |
79 var uiSourceCode = this._sourcesView.currentUISourceCode(); | 79 var uiSourceCode = this._sourcesView.currentUISourceCode(); |
80 if (!this._isFormattable(uiSourceCode)) | 80 if (!this._isFormattable(uiSourceCode)) |
81 return; | 81 return; |
82 | 82 |
83 if (uiSourceCode.isDirty()) | 83 if (uiSourceCode.isDirty()) |
84 contentLoaded.call(this, uiSourceCode.workingCopy()); | 84 contentLoaded.call(this, uiSourceCode.workingCopy()); |
85 else | 85 else |
86 uiSourceCode.requestContent(contentLoaded.bind(this)); | 86 uiSourceCode.requestContent().then(contentLoaded.bind(this)); |
87 | 87 |
88 /** | 88 /** |
89 * @this {WebInspector.InplaceFormatterEditorAction} | 89 * @this {WebInspector.InplaceFormatterEditorAction} |
90 * @param {?string} content | 90 * @param {?string} content |
91 */ | 91 */ |
92 function contentLoaded(content) | 92 function contentLoaded(content) |
93 { | 93 { |
94 var highlighterType = WebInspector.NetworkProject.uiSourceCodeMimeTy
pe(uiSourceCode); | 94 var highlighterType = WebInspector.NetworkProject.uiSourceCodeMimeTy
pe(uiSourceCode); |
95 WebInspector.Formatter.format(uiSourceCode.contentType(), highlighte
rType, content || "", innerCallback.bind(this)); | 95 WebInspector.Formatter.format(uiSourceCode.contentType(), highlighte
rType, content || "", innerCallback.bind(this)); |
96 } | 96 } |
(...skipping 11 matching lines...) Expand all Loading... |
108 var start = [0, 0]; | 108 var start = [0, 0]; |
109 if (sourceFrame) { | 109 if (sourceFrame) { |
110 var selection = sourceFrame.selection(); | 110 var selection = sourceFrame.selection(); |
111 start = formatterMapping.originalToFormatted(selection.startLine
, selection.startColumn); | 111 start = formatterMapping.originalToFormatted(selection.startLine
, selection.startColumn); |
112 } | 112 } |
113 uiSourceCode.setWorkingCopy(formattedContent); | 113 uiSourceCode.setWorkingCopy(formattedContent); |
114 this._sourcesView.showSourceLocation(uiSourceCode, start[0], start[1
]); | 114 this._sourcesView.showSourceLocation(uiSourceCode, start[0], start[1
]); |
115 } | 115 } |
116 }, | 116 }, |
117 } | 117 } |
OLD | NEW |