Created openInIDE API inside Layout Plugin
Summary: Created a communication between Layout Plugin and Flipper Desktop. The API allows users to open given file in a selected IDE. The openInIDE function returns true if the connection with Flipper is established, otherwise returns false. Reviewed By: adityasharat Differential Revision: D22625829 fbshipit-source-id: feaf186c107d62b1a75dfc6bbe2c1d66ffd7fd78
This commit is contained in:
committed by
Facebook GitHub Bot
parent
3e4d92aad0
commit
cf6df492ee
@@ -31,6 +31,12 @@ import ProxyArchiveClient from './ProxyArchiveClient';
|
||||
import React from 'react';
|
||||
import {VisualizerPortal} from 'flipper';
|
||||
import {getFlipperMediaCDN} from 'flipper';
|
||||
import {
|
||||
resolveFullPathsFromMyles,
|
||||
getBestPath,
|
||||
IDE,
|
||||
openInIDE,
|
||||
} from '../../app/src/fb-stubs/FileResolver';
|
||||
|
||||
type State = {
|
||||
init: boolean;
|
||||
@@ -57,6 +63,15 @@ export type PersistedState = {
|
||||
type ClientGetNodesCalls = 'getNodes' | 'getAXNodes';
|
||||
type ClientMethodCalls = 'getRoot' | 'getAXRoot' | ClientGetNodesCalls;
|
||||
|
||||
type ClassFileParams = {
|
||||
fileName: string;
|
||||
className: string;
|
||||
dirRoot: string;
|
||||
repo: string;
|
||||
lineNumber: number;
|
||||
ide: IDE;
|
||||
};
|
||||
|
||||
export default class LayoutPlugin extends FlipperPlugin<
|
||||
State,
|
||||
any,
|
||||
@@ -205,6 +220,10 @@ export default class LayoutPlugin extends FlipperPlugin<
|
||||
}
|
||||
});
|
||||
|
||||
this.client.subscribe('openInIDE', (params: ClassFileParams) => {
|
||||
this.openInIDE(params);
|
||||
});
|
||||
|
||||
if (this.props.isArchivedDevice) {
|
||||
this.getDevice()
|
||||
.then((d) => {
|
||||
@@ -229,6 +248,19 @@ export default class LayoutPlugin extends FlipperPlugin<
|
||||
});
|
||||
}
|
||||
|
||||
openInIDE = async (params: ClassFileParams) => {
|
||||
const paths = await resolveFullPathsFromMyles(
|
||||
params.fileName,
|
||||
params.dirRoot,
|
||||
);
|
||||
const selectedPath = getBestPath(paths, params.className);
|
||||
let ide: IDE = Number(IDE[params.ide]);
|
||||
if (Number.isNaN(ide)) {
|
||||
ide = IDE.AS; // default value
|
||||
}
|
||||
openInIDE(selectedPath, ide, params.repo, params.lineNumber);
|
||||
};
|
||||
|
||||
onToggleTargetMode = () => {
|
||||
const inTargetMode = !this.state.inTargetMode;
|
||||
this.setState({inTargetMode});
|
||||
|
||||
Reference in New Issue
Block a user