OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 * @param {!Promise<?string>} diffBaseline | 7 * @param {!Promise<?string>} diffBaseline |
8 * @param {!WebInspector.CodeMirrorTextEditor} textEditor | 8 * @param {!WebInspector.CodeMirrorTextEditor} textEditor |
9 */ | 9 */ |
10 WebInspector.SourceCodeDiff = function(diffBaseline, textEditor) | 10 WebInspector.SourceCodeDiff = function(diffBaseline, textEditor) |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 var diffEntry = diff[i]; | 217 var diffEntry = diff[i]; |
218 for (var lineNumber = diffEntry.from; lineNumber < diffEntry.to; ++l
ineNumber) | 218 for (var lineNumber = diffEntry.from; lineNumber < diffEntry.to; ++l
ineNumber) |
219 newDecorations.set(lineNumber, {lineNumber: lineNumber, type: di
ffEntry.type}); | 219 newDecorations.set(lineNumber, {lineNumber: lineNumber, type: di
ffEntry.type}); |
220 } | 220 } |
221 | 221 |
222 var decorationDiff = oldDecorations.diff(newDecorations, (e1, e2) => e1.
type === e2.type); | 222 var decorationDiff = oldDecorations.diff(newDecorations, (e1, e2) => e1.
type === e2.type); |
223 var addedDecorations = decorationDiff.added.map(entry => new WebInspecto
r.SourceCodeDiff.GutterDecoration(this._textEditor, entry.lineNumber, entry.type
)); | 223 var addedDecorations = decorationDiff.added.map(entry => new WebInspecto
r.SourceCodeDiff.GutterDecoration(this._textEditor, entry.lineNumber, entry.type
)); |
224 | 224 |
225 this._decorations = decorationDiff.equal.concat(addedDecorations); | 225 this._decorations = decorationDiff.equal.concat(addedDecorations); |
226 this._updateDecorations(decorationDiff.removed, addedDecorations); | 226 this._updateDecorations(decorationDiff.removed, addedDecorations); |
| 227 this._decorationsSetForTest(newDecorations); |
227 }, | 228 }, |
| 229 |
| 230 /** |
| 231 * @param {!Map<number, !{lineNumber: number, type: !WebInspector.SourceCode
Diff.GutterDecorationType}>} decorations |
| 232 */ |
| 233 _decorationsSetForTest: function(decorations) { } |
228 } | 234 } |
229 | 235 |
230 /** @enum {string} */ | 236 /** @enum {string} */ |
231 WebInspector.SourceCodeDiff.GutterDecorationType = { | 237 WebInspector.SourceCodeDiff.GutterDecorationType = { |
232 Insert: "Insert", | 238 Insert: "Insert", |
233 Delete: "Delete", | 239 Delete: "Delete", |
234 Modify: "Modify", | 240 Modify: "Modify", |
235 } | 241 } |
236 | 242 |
237 /** | 243 /** |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 | 285 |
280 remove: function() | 286 remove: function() |
281 { | 287 { |
282 var location = this._position.resolve(); | 288 var location = this._position.resolve(); |
283 if (!location) | 289 if (!location) |
284 return; | 290 return; |
285 this._textEditor.setGutterDecoration(location.lineNumber, WebInspector.S
ourceCodeDiff.DiffGutterType, null); | 291 this._textEditor.setGutterDecoration(location.lineNumber, WebInspector.S
ourceCodeDiff.DiffGutterType, null); |
286 this._textEditor.toggleLineClass(location.lineNumber, this._className, f
alse); | 292 this._textEditor.toggleLineClass(location.lineNumber, this._className, f
alse); |
287 } | 293 } |
288 } | 294 } |
OLD | NEW |