Skip to content

Commit 34eea54

Browse files
danilsomsikovDevtools-frontend LUCI CQ
authored andcommitted
Use JavaScript private fields instead of the TypeScript private visibility annotation as per goo.gle/devtools-tsstyle
Bug: 390346490 Change-Id: Icf3f83e66efafeda784276290e8f0e3c109b9fec Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6175034 Commit-Queue: Danil Somsikov <[email protected]> Reviewed-by: Benedikt Meurer <[email protected]>
1 parent 9a8ce3e commit 34eea54

File tree

1 file changed

+47
-47
lines changed

1 file changed

+47
-47
lines changed

front_end/panels/developer_resources/DeveloperResourcesListView.ts

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -67,15 +67,15 @@ const str_ = i18n.i18n.registerUIStrings('panels/developer_resources/DeveloperRe
6767
const i18nString = i18n.i18n.getLocalizedString.bind(undefined, str_);
6868

6969
export class DeveloperResourcesListView extends UI.Widget.VBox {
70-
private readonly nodeForItem: Map<SDK.PageResourceLoader.PageResource, GridNode>;
71-
private readonly isVisibleFilter: (arg0: SDK.PageResourceLoader.PageResource) => boolean;
72-
private highlightRegExp: RegExp|null;
73-
private dataGrid: DataGrid.SortableDataGrid.SortableDataGrid<GridNode>;
70+
readonly #nodeForItem: Map<SDK.PageResourceLoader.PageResource, GridNode>;
71+
readonly #isVisibleFilter: (arg0: SDK.PageResourceLoader.PageResource) => boolean;
72+
#highlightRegExp: RegExp|null;
73+
#dataGrid: DataGrid.SortableDataGrid.SortableDataGrid<GridNode>;
7474
constructor(isVisibleFilter: (arg0: SDK.PageResourceLoader.PageResource) => boolean) {
7575
super(true);
76-
this.nodeForItem = new Map();
77-
this.isVisibleFilter = isVisibleFilter;
78-
this.highlightRegExp = null;
76+
this.#nodeForItem = new Map();
77+
this.#isVisibleFilter = isVisibleFilter;
78+
this.#highlightRegExp = null;
7979

8080
const columns = [
8181
{id: 'status', title: i18nString(UIStrings.status), width: '60px', fixedWidth: true, sortable: true},
@@ -97,39 +97,39 @@ export class DeveloperResourcesListView extends UI.Widget.VBox {
9797
sortable: true,
9898
},
9999
] as DataGrid.DataGrid.ColumnDescriptor[];
100-
this.dataGrid = new DataGrid.SortableDataGrid.SortableDataGrid({
100+
this.#dataGrid = new DataGrid.SortableDataGrid.SortableDataGrid({
101101
displayName: i18nString(UIStrings.developerResources),
102102
columns,
103103
editCallback: undefined,
104104
refreshCallback: undefined,
105105
deleteCallback: undefined,
106106
});
107-
this.dataGrid.setResizeMethod(DataGrid.DataGrid.ResizeMethod.LAST);
108-
this.dataGrid.setStriped(true);
109-
this.dataGrid.element.classList.add('flex-auto');
110-
this.dataGrid.addEventListener(DataGrid.DataGrid.Events.SORTING_CHANGED, this.sortingChanged, this);
111-
this.dataGrid.setRowContextMenuCallback(this.populateContextMenu.bind(this));
107+
this.#dataGrid.setResizeMethod(DataGrid.DataGrid.ResizeMethod.LAST);
108+
this.#dataGrid.setStriped(true);
109+
this.#dataGrid.element.classList.add('flex-auto');
110+
this.#dataGrid.addEventListener(DataGrid.DataGrid.Events.SORTING_CHANGED, this.#sortingChanged, this);
111+
this.#dataGrid.setRowContextMenuCallback(this.#populateContextMenu.bind(this));
112112

113-
const dataGridWidget = this.dataGrid.asWidget();
113+
const dataGridWidget = this.#dataGrid.asWidget();
114114
dataGridWidget.show(this.contentElement);
115115
this.setDefaultFocusedChild(dataGridWidget);
116116
}
117117

118118
select(item: SDK.PageResourceLoader.PageResource): void {
119-
const node = this.nodeForItem.get(item);
119+
const node = this.#nodeForItem.get(item);
120120
if (node) {
121121
node.select();
122122
}
123123
}
124124

125125
selectedItem(): SDK.PageResourceLoader.PageResource|null {
126-
if (!this.dataGrid.selectedNode) {
126+
if (!this.#dataGrid.selectedNode) {
127127
return null;
128128
}
129-
return (this.dataGrid.selectedNode as GridNode).item;
129+
return (this.#dataGrid.selectedNode as GridNode).item;
130130
}
131131

132-
private populateContextMenu(
132+
#populateContextMenu(
133133
contextMenu: UI.ContextMenu.ContextMenu,
134134
gridNode: DataGrid.DataGrid.DataGridNode<
135135
DataGrid.ViewportDataGrid.ViewportDataGridNode<DataGrid.SortableDataGrid.SortableDataGridNode<GridNode>>>):
@@ -147,40 +147,40 @@ export class DeveloperResourcesListView extends UI.Widget.VBox {
147147

148148
update(items: Iterable<SDK.PageResourceLoader.PageResource> = []): void {
149149
let hadUpdates = false;
150-
const rootNode = this.dataGrid.rootNode();
150+
const rootNode = this.#dataGrid.rootNode();
151151
for (const item of items) {
152-
let node = this.nodeForItem.get(item);
152+
let node = this.#nodeForItem.get(item);
153153
if (node) {
154-
if (this.isVisibleFilter(node.item)) {
154+
if (this.#isVisibleFilter(node.item)) {
155155
hadUpdates = node.refreshIfNeeded() || hadUpdates;
156156
}
157157
continue;
158158
}
159159
node = new GridNode(item);
160-
this.nodeForItem.set(item, node);
161-
if (this.isVisibleFilter(node.item)) {
160+
this.#nodeForItem.set(item, node);
161+
if (this.#isVisibleFilter(node.item)) {
162162
rootNode.appendChild(node);
163163
hadUpdates = true;
164164
}
165165
}
166166
if (hadUpdates) {
167-
this.sortingChanged();
167+
this.#sortingChanged();
168168
}
169169
}
170170

171171
reset(): void {
172-
this.nodeForItem.clear();
173-
this.dataGrid.rootNode().removeChildren();
172+
this.#nodeForItem.clear();
173+
this.#dataGrid.rootNode().removeChildren();
174174
}
175175

176176
updateFilterAndHighlight(highlightRegExp: RegExp|null): void {
177-
this.highlightRegExp = highlightRegExp;
177+
this.#highlightRegExp = highlightRegExp;
178178
let hadTreeUpdates = false;
179-
for (const node of this.nodeForItem.values()) {
180-
const shouldBeVisible = this.isVisibleFilter(node.item);
179+
for (const node of this.#nodeForItem.values()) {
180+
const shouldBeVisible = this.#isVisibleFilter(node.item);
181181
const isVisible = Boolean(node.parent);
182182
if (shouldBeVisible) {
183-
node.setHighlight(this.highlightRegExp);
183+
node.setHighlight(this.#highlightRegExp);
184184
}
185185
if (shouldBeVisible === isVisible) {
186186
continue;
@@ -189,20 +189,20 @@ export class DeveloperResourcesListView extends UI.Widget.VBox {
189189
if (!shouldBeVisible) {
190190
node.remove();
191191
} else {
192-
this.dataGrid.rootNode().appendChild(node);
192+
this.#dataGrid.rootNode().appendChild(node);
193193
}
194194
}
195195
if (hadTreeUpdates) {
196-
this.sortingChanged();
196+
this.#sortingChanged();
197197
}
198198
}
199199

200200
getNumberOfVisibleItems(): number {
201-
return this.dataGrid.rootNode().children.length;
201+
return this.#dataGrid.rootNode().children.length;
202202
}
203203

204-
private sortingChanged(): void {
205-
const columnId = this.dataGrid.sortColumnId();
204+
#sortingChanged(): void {
205+
const columnId = this.#dataGrid.sortColumnId();
206206
if (!columnId) {
207207
return;
208208
}
@@ -212,7 +212,7 @@ export class DeveloperResourcesListView extends UI.Widget.VBox {
212212
arg1: DataGrid.SortableDataGrid.SortableDataGridNode<GridNode>) => number) |
213213
null;
214214
if (sortFunction) {
215-
this.dataGrid.sortNodes(sortFunction, !this.dataGrid.isSortOrderAscending());
215+
this.#dataGrid.sortNodes(sortFunction, !this.#dataGrid.isSortOrderAscending());
216216
}
217217
}
218218
override wasShown(): void {
@@ -223,18 +223,18 @@ export class DeveloperResourcesListView extends UI.Widget.VBox {
223223

224224
class GridNode extends DataGrid.SortableDataGrid.SortableDataGridNode<GridNode> {
225225
item: SDK.PageResourceLoader.PageResource;
226-
private highlightRegExp: RegExp|null;
226+
#highlightRegExp: RegExp|null;
227227
constructor(item: SDK.PageResourceLoader.PageResource) {
228228
super();
229229
this.item = item;
230-
this.highlightRegExp = null;
230+
this.#highlightRegExp = null;
231231
}
232232

233233
setHighlight(highlightRegExp: RegExp|null): void {
234-
if (this.highlightRegExp === highlightRegExp) {
234+
if (this.#highlightRegExp === highlightRegExp) {
235235
return;
236236
}
237-
this.highlightRegExp = highlightRegExp;
237+
this.#highlightRegExp = highlightRegExp;
238238
this.refresh();
239239
}
240240

@@ -254,8 +254,8 @@ class GridNode extends DataGrid.SortableDataGrid.SortableDataGridNode<GridNode>
254254
const splitURL = /^(.*)(\/[^/]*)$/.exec(this.item.url);
255255
prefix.textContent = splitURL ? splitURL[1] : this.item.url;
256256
suffix.textContent = splitURL ? splitURL[2] : '';
257-
if (this.highlightRegExp) {
258-
this.highlight(outer, this.item.url);
257+
if (this.#highlightRegExp) {
258+
this.#highlight(outer, this.item.url);
259259
}
260260
this.setCellAccessibleName(this.item.url, cell, columnId);
261261
break;
@@ -297,8 +297,8 @@ class GridNode extends DataGrid.SortableDataGrid.SortableDataGridNode<GridNode>
297297
cell.classList.add('error-message');
298298
if (this.item.errorMessage) {
299299
cell.textContent = this.item.errorMessage;
300-
if (this.highlightRegExp) {
301-
this.highlight(cell, this.item.errorMessage);
300+
if (this.#highlightRegExp) {
301+
this.#highlight(cell, this.item.errorMessage);
302302
}
303303
}
304304
break;
@@ -307,11 +307,11 @@ class GridNode extends DataGrid.SortableDataGrid.SortableDataGridNode<GridNode>
307307
return cell;
308308
}
309309

310-
private highlight(element: Element, textContent: string): void {
311-
if (!this.highlightRegExp) {
310+
#highlight(element: Element, textContent: string): void {
311+
if (!this.#highlightRegExp) {
312312
return;
313313
}
314-
const matches = this.highlightRegExp.exec(textContent);
314+
const matches = this.#highlightRegExp.exec(textContent);
315315
if (!matches || !matches.length) {
316316
return;
317317
}

0 commit comments

Comments
 (0)