microsoft/vscode-react-native

Public

mirrored from https://github.com/microsoft/vscode-react-nativeAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
1.4.0

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

src/common/configurationProviderHelper.ts

141lines · modeblame

5471436aRedMickey5 years ago1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for details.
3
4import {
5MultiStepInput,
6IQuickPickParameters,
7} from "../extension/debuggingConfiguration/multiStepInput";
8import { ILaunchRequestArgs } from "../debugger/debugSessionBase";
9import { ExpoHostType } from "../extension/launchArgs";
10import {
11DebugConfigurationState,
12DebugConfigurationQuickPickItem,
13appTypePickConfig,
14expoHostTypePickConfig,
6f9a0779JiglioNero5 years ago15shouldUseHermesEngine,
5471436aRedMickey5 years ago16} from "../extension/debuggingConfiguration/debugConfigTypesAndConstants";
17import * as nls from "vscode-nls";
18nls.config({
19messageFormat: nls.MessageFormat.bundle,
20bundleFormat: nls.BundleFormat.standalone,
21})();
22const localize = nls.loadMessageBundle();
23
24export class ConfigurationProviderHelper {
25public async selectPlatform(
26input: MultiStepInput<DebugConfigurationState>,
27config: Partial<ILaunchRequestArgs>,
28platformTypePickConfig: DebugConfigurationQuickPickItem[],
29step: number,
30totalSteps: number,
31): Promise<Partial<ILaunchRequestArgs>> {
32let pick = await input.showQuickPick<
33DebugConfigurationQuickPickItem,
34IQuickPickParameters<DebugConfigurationQuickPickItem>
35>({
36title: localize("PlatformSelectionTitle", "Select platform"),
37placeholder: localize("PlatformSelectionPrompt", "Platform to run on"),
38step,
39totalSteps,
40items: platformTypePickConfig,
41activeItem: platformTypePickConfig[0],
42});
43
44if (!pick) {
45throw new Error("Platform is not selected");
46}
47
48config.platform = pick.type;
49return config;
50}
51
52public async selectApplicationType(
53input: MultiStepInput<DebugConfigurationState>,
54config: Partial<ILaunchRequestArgs>,
55step: number,
56totalSteps: number,
57): Promise<Partial<ILaunchRequestArgs>> {
58let pick = await input.showQuickPick<
59DebugConfigurationQuickPickItem,
60IQuickPickParameters<DebugConfigurationQuickPickItem>
61>({
62title: localize(
63"ApplicationTypeSelectionTitle",
64"Select type of React Native application",
65),
66placeholder: localize(
67"ApplicationTypeSelectionPrompt",
68"Type of React Native application",
69),
70step,
71totalSteps,
72items: appTypePickConfig,
73activeItem: appTypePickConfig[0],
74});
75
76if (!pick) {
77throw new Error("Application type is not selected");
78}
79
80config.type = pick.type;
81return config;
82}
83
6f9a0779JiglioNero5 years ago84public async shouldUseHermesEngine(
85input: MultiStepInput<DebugConfigurationState>,
86config: Partial<ILaunchRequestArgs>,
87step: number,
88totalSteps: number,
89): Promise<Partial<ILaunchRequestArgs>> {
90let shouldUseHermes = await input.showQuickPick<
91DebugConfigurationQuickPickItem,
92IQuickPickParameters<DebugConfigurationQuickPickItem>
93>({
94title: localize("UseHermesEngine", "Use Hermes engine"),
95placeholder: localize(
96"UseHermesEnginePrompt",
97"Use Hermes engine for direct debugging?",
98),
99step,
100totalSteps,
101items: shouldUseHermesEngine,
102activeItem: shouldUseHermesEngine[0],
103});
104
105if (!shouldUseHermes) {
106throw new Error(
107localize("UseHermesEngineInvalid", "Using Hermes engine is not confirmed"),
108);
109}
110
111config.useHermesEngine = shouldUseHermes.type === "yes";
112
113return config;
114}
115
5471436aRedMickey5 years ago116public async selectExpoHostType(
117input: MultiStepInput<DebugConfigurationState>,
118config: Partial<ILaunchRequestArgs>,
119step: number,
120totalSteps: number,
121): Promise<Partial<ILaunchRequestArgs>> {
122let pick = await input.showQuickPick<
123DebugConfigurationQuickPickItem,
124IQuickPickParameters<DebugConfigurationQuickPickItem>
125>({
126title: localize("ExpoHostTypeSelectionTitle", "Select type of Expo host parameter"),
127placeholder: localize("ExpoHostTypeSelectionPrompt", "Type of Expo host parameter"),
128step,
129totalSteps,
130items: expoHostTypePickConfig,
131activeItem: expoHostTypePickConfig[0],
132});
133
134if (!pick) {
135throw new Error("Expo host type is not selected");
136}
137
138config.expoHostType = pick.type as ExpoHostType;
139return config;
140}
141}