mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-11 06:04:55 +08:00
Typecheck sources/JavaScriptBreakpointsSidebarPane.js with TypeScript
R=szuend@chromium.org Bug: 1011811 Change-Id: Ia028fe9189fe55d77b636d7d60fc4dbc5714c5bf Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2450036 Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org> Reviewed-by: Paul Lewis <aerotwist@chromium.org>
This commit is contained in:
committed by
Commit Bot
parent
49ff36be1c
commit
8a7ceda7a7
@@ -2,11 +2,9 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @ts-nocheck
|
||||
// TODO(crbug.com/1011811): Enable TypeScript compiler checks
|
||||
|
||||
import * as Bindings from '../bindings/bindings.js';
|
||||
import * as Common from '../common/common.js';
|
||||
import * as Platform from '../platform/platform.js';
|
||||
import * as SDK from '../sdk/sdk.js';
|
||||
import * as TextUtils from '../text_utils/text_utils.js';
|
||||
import * as UI from '../ui/ui.js';
|
||||
@@ -14,8 +12,7 @@ import * as Workspace from '../workspace/workspace.js';
|
||||
|
||||
/**
|
||||
* @implements {UI.ContextFlavorListener.ContextFlavorListener}
|
||||
* @implements {UI.ListControl.ListDelegate}
|
||||
* @unrestricted
|
||||
* @implements {UI.ListControl.ListDelegate<!BreakpointItem>}
|
||||
*/
|
||||
export class JavaScriptBreakpointsSidebarPane extends UI.ThrottledWidget.ThrottledWidget {
|
||||
constructor() {
|
||||
@@ -277,8 +274,8 @@ export class JavaScriptBreakpointsSidebarPane extends UI.ThrottledWidget.Throttl
|
||||
lineText.substring(item.showColumn ? uiLocation.columnNumber : 0).trimEndWithMaxLength(maxSnippetLength);
|
||||
}
|
||||
|
||||
element[breakpointLocationsSymbol] = item.locations;
|
||||
element[locationSymbol] = uiLocation;
|
||||
elementToBreakpointMap.set(element, item.locations);
|
||||
elementToUILocationMap.set(element, uiLocation);
|
||||
return element;
|
||||
}
|
||||
|
||||
@@ -304,8 +301,8 @@ export class JavaScriptBreakpointsSidebarPane extends UI.ThrottledWidget.Throttl
|
||||
* @override
|
||||
* @param {?BreakpointItem} from
|
||||
* @param {?BreakpointItem} to
|
||||
* @param {?Element} fromElement
|
||||
* @param {?Element} toElement
|
||||
* @param {?HTMLElement} fromElement
|
||||
* @param {?HTMLElement} toElement
|
||||
*/
|
||||
selectedItemChanged(from, to, fromElement, toElement) {
|
||||
if (fromElement) {
|
||||
@@ -350,7 +347,7 @@ export class JavaScriptBreakpointsSidebarPane extends UI.ThrottledWidget.Throttl
|
||||
if (!node) {
|
||||
return [];
|
||||
}
|
||||
return node[breakpointLocationsSymbol] || [];
|
||||
return elementToBreakpointMap.get(node) || [];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -359,7 +356,7 @@ export class JavaScriptBreakpointsSidebarPane extends UI.ThrottledWidget.Throttl
|
||||
_breakpointCheckboxClicked(event) {
|
||||
const hadFocus = this.hasFocus();
|
||||
const breakpoints = this._breakpointLocations(event).map(breakpointLocation => breakpointLocation.breakpoint);
|
||||
const newState = event.target.checkboxElement.checked;
|
||||
const newState = /** @type {!UI.UIUtils.CheckboxLabel} */ (event.target).checkboxElement.checked;
|
||||
for (const breakpoint of breakpoints) {
|
||||
breakpoint.setEnabled(newState);
|
||||
const item =
|
||||
@@ -523,16 +520,19 @@ class BreakpointItem {
|
||||
}
|
||||
}
|
||||
|
||||
export const locationSymbol = Symbol('location');
|
||||
/** @type {!WeakMap<!Element, !Workspace.UISourceCode.UILocation>} */
|
||||
const elementToUILocationMap = new WeakMap();
|
||||
|
||||
/**
|
||||
* @param {!Element} element
|
||||
*/
|
||||
export function retrieveLocationForElement(element) {
|
||||
return element[locationSymbol];
|
||||
return elementToUILocationMap.get(element);
|
||||
}
|
||||
export const checkboxLabelSymbol = Symbol('checkbox-label');
|
||||
export const snippetElementSymbol = Symbol('snippet-element');
|
||||
export const breakpointLocationsSymbol = Symbol('locations');
|
||||
|
||||
/** @type {!WeakMap<!Element, !Array<!BreakpointLocation>>} */
|
||||
const elementToBreakpointMap = new WeakMap();
|
||||
|
||||
/** @typedef {{breakpoint: !Bindings.BreakpointManager.Breakpoint, uiLocation: !Workspace.UISourceCode.UILocation}} */
|
||||
// @ts-ignore typedef
|
||||
export let BreakpointLocation;
|
||||
|
||||
Reference in New Issue
Block a user