Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js b/third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js |
| index 60e4f4fe32593213ead4c32aca19740254c33b70..9b0121dcc7a183e85dafa3e69e878f0558c473fa 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/workspace/UISourceCode.js |
| @@ -60,8 +60,8 @@ Workspace.UISourceCode = class extends Common.Object { |
| this._requestContentCallback = null; |
| /** @type {?Promise<?string>} */ |
| this._requestContentPromise = null; |
| - /** @type {!Map<string, !Map<number, !Workspace.UISourceCode.LineMarker>>} */ |
| - this._lineDecorations = new Map(); |
| + /** @type {!Map<string, !Array<!Workspace.UISourceCode.LineMarker>>} */ |
|
lushnikov
2016/11/16 22:53:54
Map<string, Array<LineMarker>> is a... Multimap<st
|
| + this._decorations = new Map(); |
| /** @type {!Array.<!Workspace.Revision>} */ |
| this.history = []; |
| @@ -608,52 +608,55 @@ Workspace.UISourceCode = class extends Common.Object { |
| * @param {?} data |
| */ |
| addLineDecoration(lineNumber, type, data) { |
| - var markers = this._lineDecorations.get(type); |
| - if (!markers) { |
| - markers = new Map(); |
| - this._lineDecorations.set(type, markers); |
| - } |
| - var marker = new Workspace.UISourceCode.LineMarker(lineNumber, type, data); |
| - markers.set(lineNumber, marker); |
| - this.dispatchEventToListeners(Workspace.UISourceCode.Events.LineDecorationAdded, marker); |
| + this.addDecoration(Common.TextRange.createFromLocation(lineNumber, 0), type, data); |
| } |
| /** |
| - * @param {number} lineNumber |
| + * @param {!Common.TextRange} range |
| * @param {string} type |
| + * @param {?} data |
| */ |
| - removeLineDecoration(lineNumber, type) { |
| - var markers = this._lineDecorations.get(type); |
| - if (!markers) |
| - return; |
| - var marker = markers.get(lineNumber); |
| - if (!marker) |
| - return; |
| - markers.delete(lineNumber); |
| - this.dispatchEventToListeners(Workspace.UISourceCode.Events.LineDecorationRemoved, marker); |
| - if (!markers.size) |
| - this._lineDecorations.delete(type); |
| + addDecoration(range, type, data) { |
| + var markers = this._decorations.get(type); |
| + if (!markers) { |
| + markers = []; |
| + this._decorations.set(type, markers); |
| + } |
| + var marker = new Workspace.UISourceCode.LineMarker(range, type, data); |
| + markers.push(marker); |
| + this.dispatchEventToListeners(Workspace.UISourceCode.Events.LineDecorationAdded, marker); |
| } |
| /** |
| * @param {string} type |
| */ |
| - removeAllLineDecorations(type) { |
| - var markers = this._lineDecorations.get(type); |
| + removeAllTypeDecorations(type) { |
|
lushnikov
2016/11/16 22:53:54
removeDecorationsForType
|
| + var markers = this._decorations.get(type); |
| if (!markers) |
| return; |
| - this._lineDecorations.delete(type); |
| + this._decorations.delete(type); |
| markers.forEach(marker => { |
| this.dispatchEventToListeners(Workspace.UISourceCode.Events.LineDecorationRemoved, marker); |
| }); |
| } |
| /** |
| + * @return {!Map<string, !Array<!Workspace.UISourceCode.LineMarker>>} |
|
lushnikov
2016/11/16 22:53:54
why does it return a map? Let's just return an arr
|
| + */ |
| + get allDecorations() { |
|
lushnikov
2016/11/16 22:53:54
let's not use getters
|
| + return this._decorations; |
| + } |
| + |
| + removeAllDecorations() { |
| + this._decorations.clear(); |
|
lushnikov
2016/11/16 22:53:54
this should dispatch LineDecorationRemoved events
|
| + } |
| + |
| + /** |
| * @param {string} type |
| - * @return {?Map<number, !Workspace.UISourceCode.LineMarker>} |
| + * @return {!Array<!Workspace.UISourceCode.LineMarker>} |
| */ |
| - lineDecorations(type) { |
| - return this._lineDecorations.get(type) || null; |
| + decorations(type) { |
|
lushnikov
2016/11/16 22:53:54
decorationsForType
|
| + return this._decorations.get(type) || null; |
| } |
| }; |
| @@ -906,12 +909,12 @@ Workspace.UISourceCode.Message.Level = { |
| */ |
| Workspace.UISourceCode.LineMarker = class { |
| /** |
| - * @param {number} line |
| + * @param {!Common.TextRange} range |
| * @param {string} type |
| * @param {?} data |
| */ |
| - constructor(line, type, data) { |
| - this._line = line; |
| + constructor(range, type, data) { |
| + this._range = range; |
| this._type = type; |
| this._data = data; |
| } |
| @@ -920,7 +923,14 @@ Workspace.UISourceCode.LineMarker = class { |
| * @return {number} |
| */ |
| line() { |
|
lushnikov
2016/11/16 22:53:54
can we drop this method now?
|
| - return this._line; |
| + return this._range.startLine; |
| + } |
| + |
| + /** |
| + * @return {!Common.TextRange} |
| + */ |
| + range() { |
| + return this._range; |
| } |
| /** |