microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
1.3.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/extension/debuggingConfiguration/configurationProviders/debugConfigProvider.ts

80lines · modecode

1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for details.
3
4import { BaseConfigProvider } from "./baseConfigProvider";
5import { MultiStepInput, InputStep } from "../multiStepInput";
6import {
7 DebugConfigurationState,
8 platformTypeDebugPickConfig,
9 DEBUG_TYPES,
10 DebugScenarioType,
11} from "../debugConfigTypesAndConstants";
12import { PlatformType } from "../../launchArgs";
13import { ILaunchRequestArgs } from "../../../debugger/debugSessionBase";
14
15export class DebugConfigProvider extends BaseConfigProvider {
16 constructor() {
17 super();
18 this.maxStepCount = 2;
19 }
20
21 public async buildConfiguration(
22 input: MultiStepInput<DebugConfigurationState>,
23 state: DebugConfigurationState,
24 ): Promise<InputStep<DebugConfigurationState> | void> {
25 state.config = {};
26 const config: Partial<ILaunchRequestArgs> = {
27 name: "Debug application",
28 request: "launch",
29 type: DEBUG_TYPES.REACT_NATIVE,
30 cwd: "${workspaceFolder}",
31 };
32
33 state.scenarioType = DebugScenarioType.DebugApp;
34
35 await this.configurationProviderHelper.selectPlatform(
36 input,
37 config,
38 platformTypeDebugPickConfig,
39 1,
40 this.maxStepCount,
41 );
42
43 Object.assign(state.config, config);
44
45 if (
46 state.config.platform === PlatformType.iOS ||
47 state.config.platform === PlatformType.Android
48 ) {
49 return () => this.configureApplicationType(input, state.config);
50 } else if (state.config.platform === PlatformType.Exponent) {
51 return () => this.configureExpoHostType(input, state.config);
52 } else {
53 return;
54 }
55 }
56
57 private async configureApplicationType(
58 input: MultiStepInput<DebugConfigurationState>,
59 config: Partial<ILaunchRequestArgs>,
60 ): Promise<InputStep<DebugConfigurationState> | void> {
61 await this.configurationProviderHelper.selectApplicationType(
62 input,
63 config,
64 2,
65 this.maxStepCount,
66 );
67 }
68
69 private async configureExpoHostType(
70 input: MultiStepInput<DebugConfigurationState>,
71 config: Partial<ILaunchRequestArgs>,
72 ): Promise<InputStep<DebugConfigurationState> | void> {
73 await this.configurationProviderHelper.selectExpoHostType(
74 input,
75 config,
76 2,
77 this.maxStepCount,
78 );
79 }
80}
81