Chromium Code Reviews| 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 {WebInspector.SourcesView.EditorAction} | 5 * @implements {WebInspector.SourcesView.EditorAction} |
| 6 * @unrestricted | 6 * @unrestricted |
| 7 */ | 7 */ |
| 8 WebInspector.InplaceFormatterEditorAction = class { | 8 WebInspector.InplaceFormatterEditorAction = class { |
| 9 /** | 9 /** |
| 10 * @param {!WebInspector.Event} event | 10 * @param {!WebInspector.Event} event |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 */ | 92 */ |
| 93 function innerCallback(formattedContent, formatterMapping) { | 93 function innerCallback(formattedContent, formatterMapping) { |
| 94 if (uiSourceCode.workingCopy() === formattedContent) | 94 if (uiSourceCode.workingCopy() === formattedContent) |
| 95 return; | 95 return; |
| 96 var sourceFrame = this._sourcesView.viewForFile(uiSourceCode); | 96 var sourceFrame = this._sourcesView.viewForFile(uiSourceCode); |
| 97 var start = [0, 0]; | 97 var start = [0, 0]; |
| 98 if (sourceFrame) { | 98 if (sourceFrame) { |
| 99 var selection = sourceFrame.selection(); | 99 var selection = sourceFrame.selection(); |
| 100 start = formatterMapping.originalToFormatted(selection.startLine, select ion.startColumn); | 100 start = formatterMapping.originalToFormatted(selection.startLine, select ion.startColumn); |
| 101 } | 101 } |
| 102 | |
| 103 mapCoverageDecorations(formatterMapping); | |
| 104 | |
| 102 uiSourceCode.setWorkingCopy(formattedContent); | 105 uiSourceCode.setWorkingCopy(formattedContent); |
| 103 this._sourcesView.showSourceLocation(uiSourceCode, start[0], start[1]); | 106 this._sourcesView.showSourceLocation(uiSourceCode, start[0], start[1]); |
| 104 } | 107 } |
| 108 | |
| 109 /** | |
| 110 * @param {!WebInspector.FormatterSourceMapping} formatterMapping | |
| 111 */ | |
| 112 function mapCoverageDecorations(formatterMapping) { | |
| 113 | |
| 114 var markers = uiSourceCode._typeDecorations.get('coverage'); | |
|
caseq
2016/11/11 23:23:39
We treat names starting with underscore as private
lushnikov
2016/11/11 23:28:01
why coverage only? this code should go in Coverage
| |
| 115 if (!markers) | |
| 116 return; | |
| 117 | |
| 118 var needToAdd = []; | |
| 119 | |
| 120 for (var decoration of markers) { | |
| 121 uiSourceCode._typeDecorations.remove('coverage', decoration); | |
| 122 uiSourceCode._lineDecorations.remove(decoration.line(), decoration); | |
| 123 | |
| 124 var startLine = formatterMapping.originalToFormatted(decoration.line(), decoration.data().startColumn)[0]; | |
| 125 var endLine = formatterMapping.originalToFormatted(decoration.line(), de coration.data().endColumn)[0]; | |
| 126 | |
| 127 for (var line = startLine; line <= endLine; ++line) | |
| 128 needToAdd.push({line : line, type : 'coverage', data : decoration.data ()}); | |
| 129 } | |
| 130 | |
| 131 needToAdd.forEach(decoration => uiSourceCode.addLineDecoration(decoration. line, decoration.type, decoration.data)); | |
| 132 } | |
| 105 } | 133 } |
| 106 }; | 134 }; |
| OLD | NEW |