Expose IDEFileResolver from 'flipper' module to properly import it from 'layout' plugin (#1442)
Summary: Pull Request resolved: https://github.com/facebook/flipper/pull/1442 Layout plugin cannot be bundled as a standalone package because it imports a file from outside of its folder. This change exposes IDEFileResolver in a proper way so now it's possible to import it from 'flipper'. Reviewed By: passy Differential Revision: D22975515 fbshipit-source-id: 8af6d2ca1ceb8627a449e055c8773549dd681b7a
This commit is contained in:
committed by
Facebook GitHub Bot
parent
95ae98d925
commit
dcd1c08dea
@@ -1,35 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
||||||
*
|
|
||||||
* This source code is licensed under the MIT license found in the
|
|
||||||
* LICENSE file in the root directory of this source tree.
|
|
||||||
*
|
|
||||||
* @format
|
|
||||||
*/
|
|
||||||
|
|
||||||
export enum IDE {
|
|
||||||
'DIFFUSION',
|
|
||||||
'AS',
|
|
||||||
'VSCODE',
|
|
||||||
'XCODE',
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function resolveFullPathsFromMyles(
|
|
||||||
_fileName: string,
|
|
||||||
_dirRoot: string,
|
|
||||||
): Promise<string[]> {
|
|
||||||
throw new Error('Method not implemented.');
|
|
||||||
}
|
|
||||||
|
|
||||||
export function openInIDE(
|
|
||||||
_filePath: string,
|
|
||||||
_ide: IDE,
|
|
||||||
_repo: string,
|
|
||||||
_lineNumber = 0,
|
|
||||||
) {
|
|
||||||
throw new Error('Method not implemented.');
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getBestPath(_paths: string[], _className: string): string {
|
|
||||||
throw new Error('Method not implemented.');
|
|
||||||
}
|
|
||||||
37
desktop/app/src/fb-stubs/IDEFileResolver.tsx
Normal file
37
desktop/app/src/fb-stubs/IDEFileResolver.tsx
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
||||||
|
*
|
||||||
|
* This source code is licensed under the MIT license found in the
|
||||||
|
* LICENSE file in the root directory of this source tree.
|
||||||
|
*
|
||||||
|
* @format
|
||||||
|
*/
|
||||||
|
|
||||||
|
export enum IDEType {
|
||||||
|
'DIFFUSION',
|
||||||
|
'AS',
|
||||||
|
'VSCODE',
|
||||||
|
'XCODE',
|
||||||
|
}
|
||||||
|
|
||||||
|
export abstract class IDEFileResolver {
|
||||||
|
static async resolveFullPathsFromMyles(
|
||||||
|
_fileName: string,
|
||||||
|
_dirRoot: string,
|
||||||
|
): Promise<string[]> {
|
||||||
|
throw new Error('Method not implemented.');
|
||||||
|
}
|
||||||
|
|
||||||
|
static openInIDE(
|
||||||
|
_filePath: string,
|
||||||
|
_ide: IDEType,
|
||||||
|
_repo: string,
|
||||||
|
_lineNumber = 0,
|
||||||
|
) {
|
||||||
|
throw new Error('Method not implemented.');
|
||||||
|
}
|
||||||
|
|
||||||
|
static getBestPath(_paths: string[], _className: string): string {
|
||||||
|
throw new Error('Method not implemented.');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -195,3 +195,4 @@ export {useLocalStorage} from './utils/useLocalStorage';
|
|||||||
export {checkIdbIsInstalled} from './utils/iOSContainerUtility';
|
export {checkIdbIsInstalled} from './utils/iOSContainerUtility';
|
||||||
// Sidebar extensions should be last so they can import anything from here.
|
// Sidebar extensions should be last so they can import anything from here.
|
||||||
export {default as SidebarExtensions} from './fb-stubs/LayoutInspectorSidebarExtensions';
|
export {default as SidebarExtensions} from './fb-stubs/LayoutInspectorSidebarExtensions';
|
||||||
|
export {IDEFileResolver, IDEType} from './fb-stubs/IDEFileResolver';
|
||||||
|
|||||||
@@ -29,14 +29,12 @@ import InspectorSidebar from './InspectorSidebar';
|
|||||||
import Search from './Search';
|
import Search from './Search';
|
||||||
import ProxyArchiveClient from './ProxyArchiveClient';
|
import ProxyArchiveClient from './ProxyArchiveClient';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {VisualizerPortal} from 'flipper';
|
|
||||||
import {getFlipperMediaCDN} from 'flipper';
|
|
||||||
import {
|
import {
|
||||||
resolveFullPathsFromMyles,
|
VisualizerPortal,
|
||||||
getBestPath,
|
getFlipperMediaCDN,
|
||||||
IDE,
|
IDEFileResolver,
|
||||||
openInIDE,
|
IDEType,
|
||||||
} from '../../app/src/fb-stubs/FileResolver';
|
} from 'flipper';
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
init: boolean;
|
init: boolean;
|
||||||
@@ -69,7 +67,7 @@ type ClassFileParams = {
|
|||||||
dirRoot: string;
|
dirRoot: string;
|
||||||
repo: string;
|
repo: string;
|
||||||
lineNumber: number;
|
lineNumber: number;
|
||||||
ide: IDE;
|
ide: IDEType;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default class LayoutPlugin extends FlipperPlugin<
|
export default class LayoutPlugin extends FlipperPlugin<
|
||||||
@@ -250,16 +248,21 @@ export default class LayoutPlugin extends FlipperPlugin<
|
|||||||
}
|
}
|
||||||
|
|
||||||
openInIDE = async (params: ClassFileParams) => {
|
openInIDE = async (params: ClassFileParams) => {
|
||||||
const paths = await resolveFullPathsFromMyles(
|
const paths = await IDEFileResolver.resolveFullPathsFromMyles(
|
||||||
params.fileName,
|
params.fileName,
|
||||||
params.dirRoot,
|
params.dirRoot,
|
||||||
);
|
);
|
||||||
const selectedPath = getBestPath(paths, params.className);
|
const selectedPath = IDEFileResolver.getBestPath(paths, params.className);
|
||||||
let ide: IDE = Number(IDE[params.ide]);
|
let ide: IDEType = Number(IDEType[params.ide]);
|
||||||
if (Number.isNaN(ide)) {
|
if (Number.isNaN(ide)) {
|
||||||
ide = IDE.AS; // default value
|
ide = IDEType.AS; // default value
|
||||||
}
|
}
|
||||||
openInIDE(selectedPath, ide, params.repo, params.lineNumber);
|
IDEFileResolver.openInIDE(
|
||||||
|
selectedPath,
|
||||||
|
ide,
|
||||||
|
params.repo,
|
||||||
|
params.lineNumber,
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
onToggleTargetMode = () => {
|
onToggleTargetMode = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user