[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
This commit is contained in:
Luna Ruan
2022-06-29 13:38:27 -04:00
committed by GitHub
parent f01e119b7d
commit cd80d3274d
4 changed files with 13 additions and 13 deletions

View File

@@ -255,8 +255,8 @@ function createPanelIfReactLoaded() {
}
};
const viewSourceLineFunction = (url, line) => {
chrome.devtools.panels.openResource(url, line);
const viewUrlSourceFunction = (url, line, col) => {
chrome.devtools.panels.openResource(url, line, col);
};
let debugIDCounter = 0;
@@ -395,7 +395,7 @@ function createPanelIfReactLoaded() {
warnIfUnsupportedVersionDetected: true,
viewAttributeSourceFunction,
viewElementSourceFunction,
viewSourceLineFunction,
viewUrlSourceFunction,
}),
);
};

View File

@@ -9,10 +9,10 @@
import {createContext} from 'react';
import type {ViewSourceLine} from 'react-devtools-shared/src/devtools/views/DevTools';
import type {ViewUrlSource} from 'react-devtools-shared/src/devtools/views/DevTools';
export type Context = {|
viewSourceLineFunction: ViewSourceLine | null,
viewUrlSourceFunction: ViewUrlSource | null,
|};
const ViewSourceContext = createContext<Context>(((null: any): Context));

View File

@@ -58,7 +58,7 @@ export type ViewElementSource = (
id: number,
inspectedElement: InspectedElement,
) => void;
export type ViewSourceLine = (url: string, row: number, column: number) => void;
export type ViewUrlSource = (url: string, row: number, column: number) => void;
export type ViewAttributeSource = (
id: number,
path: Array<string | number>,
@@ -79,7 +79,7 @@ export type Props = {|
warnIfUnsupportedVersionDetected?: boolean,
viewAttributeSourceFunction?: ?ViewAttributeSource,
viewElementSourceFunction?: ?ViewElementSource,
viewSourceLineFunction?: ?ViewSourceLine,
viewUrlSourceFunction?: ?ViewUrlSource,
readOnly?: boolean,
hideSettings?: boolean,
hideToggleErrorAction?: boolean,
@@ -139,7 +139,7 @@ export default function DevTools({
warnIfUnsupportedVersionDetected = false,
viewAttributeSourceFunction,
viewElementSourceFunction,
viewSourceLineFunction,
viewUrlSourceFunction,
readOnly,
hideSettings,
hideToggleErrorAction,
@@ -205,11 +205,11 @@ export default function DevTools({
const viewSource = useMemo(
() => ({
viewSourceLineFunction: viewSourceLineFunction || null,
viewUrlSourceFunction: viewUrlSourceFunction || null,
// todo(blakef): Add inspect(...) method here and remove viewElementSource
// to consolidate source code inspection.
}),
[viewSourceLineFunction],
[viewUrlSourceFunction],
);
const contextMenu = useMemo(

View File

@@ -22,7 +22,7 @@ export type Props = {||};
export default function SidebarEventInfo(_: Props) {
const {profilingData, selectedCommitIndex} = useContext(ProfilerContext);
const {viewSourceLineFunction} = useContext(ViewSourceContext);
const {viewUrlSourceFunction} = useContext(ViewSourceContext);
const {stack} = useMemo(() => {
if (
@@ -55,8 +55,8 @@ export default function SidebarEventInfo(_: Props) {
const hasSource = source != null;
const onClick = () => {
if (viewSourceLineFunction != null && source != null) {
viewSourceLineFunction(...source);
if (viewUrlSourceFunction != null && source != null) {
viewUrlSourceFunction(...source);
}
};