[DevTools] Add column number to viewSourceLineFunction (#24814)
Add column number for `viewSourceLineFunction` and renamed the function to `viewUrlSourceFunction` to match the other source function naming conventions
Luna Ruan committed
Jun 29, 2022 at 13:38 UTC
cd80d3274d48155d0f83347daab3eda57009f41b
4 files changed
+13
-13
packages/react-devtools-extensions/src/main.js
+3
-3
@@ -255,8 +255,8 @@ function createPanelIfReactLoaded() {
255
}
256
};
257
258
- const viewSourceLineFunction = (url, line) => {
259
- chrome.devtools.panels.openResource(url, line);
258
+ const viewUrlSourceFunction = (url, line, col) => {
259
+ chrome.devtools.panels.openResource(url, line, col);
260
};
261
262
let debugIDCounter = 0;
@@ -395,7 +395,7 @@ function createPanelIfReactLoaded() {
395
warnIfUnsupportedVersionDetected: true,
396
viewAttributeSourceFunction,
397
viewElementSourceFunction,
398
- viewSourceLineFunction,
398
+ viewUrlSourceFunction,
399
}),
400
);
401
};
packages/react-devtools-shared/src/devtools/views/Components/ViewSourceContext.js
+2
-2
@@ -9,10 +9,10 @@
9
10
import {createContext} from 'react';
11
12
-import type {ViewSourceLine} from 'react-devtools-shared/src/devtools/views/DevTools';
12
+import type {ViewUrlSource} from 'react-devtools-shared/src/devtools/views/DevTools';
13
14
export type Context = {|
15
- viewSourceLineFunction: ViewSourceLine | null,
15
+ viewUrlSourceFunction: ViewUrlSource | null,
16
|};
17
18
const ViewSourceContext = createContext<Context>(((null: any): Context));
packages/react-devtools-shared/src/devtools/views/DevTools.js
+5
-5
@@ -58,7 +58,7 @@ export type ViewElementSource = (
58
id: number,
59
inspectedElement: InspectedElement,
60
) => void;
61
-export type ViewSourceLine = (url: string, row: number, column: number) => void;
61
+export type ViewUrlSource = (url: string, row: number, column: number) => void;
62
export type ViewAttributeSource = (
63
id: number,
64
path: Array<string | number>,
@@ -79,7 +79,7 @@ export type Props = {|
79
warnIfUnsupportedVersionDetected?: boolean,
80
viewAttributeSourceFunction?: ?ViewAttributeSource,
81
viewElementSourceFunction?: ?ViewElementSource,
82
- viewSourceLineFunction?: ?ViewSourceLine,
82
+ viewUrlSourceFunction?: ?ViewUrlSource,
83
readOnly?: boolean,
84
hideSettings?: boolean,
85
hideToggleErrorAction?: boolean,
@@ -139,7 +139,7 @@ export default function DevTools({
139
warnIfUnsupportedVersionDetected = false,
140
viewAttributeSourceFunction,
141
viewElementSourceFunction,
142
- viewSourceLineFunction,
142
+ viewUrlSourceFunction,
143
readOnly,
144
hideSettings,
145
hideToggleErrorAction,
@@ -205,11 +205,11 @@ export default function DevTools({
205
206
const viewSource = useMemo(
207
() => ({
208
- viewSourceLineFunction: viewSourceLineFunction || null,
208
+ viewUrlSourceFunction: viewUrlSourceFunction || null,
209
// todo(blakef): Add inspect(...) method here and remove viewElementSource
210
// to consolidate source code inspection.
211
}),
212
- [viewSourceLineFunction],
212
+ [viewUrlSourceFunction],
213
);
214
215
const contextMenu = useMemo(
packages/react-devtools-shared/src/devtools/views/Profiler/SidebarEventInfo.js
+3
-3
@@ -22,7 +22,7 @@ export type Props = {||};
22
23
export default function SidebarEventInfo(_: Props) {
24
const {profilingData, selectedCommitIndex} = useContext(ProfilerContext);
25
- const {viewSourceLineFunction} = useContext(ViewSourceContext);
25
+ const {viewUrlSourceFunction} = useContext(ViewSourceContext);
26
27
const {stack} = useMemo(() => {
28
if (
@@ -55,8 +55,8 @@ export default function SidebarEventInfo(_: Props) {
55
const hasSource = source != null;
56
57
const onClick = () => {
58
- if (viewSourceLineFunction != null && source != null) {
59
- viewSourceLineFunction(...source);
58
+ if (viewUrlSourceFunction != null && source != null) {
59
+ viewUrlSourceFunction(...source);
60
}
61
};
62