microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
4cd259621ddfbd348fade892a2f3ee87fd1924c5

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/extension/debuggingConfiguration/configurationProviders/debugConfigProvider.ts

107lines · 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 { BaseConfigProvider } from "./baseConfigProvider";
5import { MultiStepInput, InputStep } from "../multiStepInput";
6import {
7DebugConfigurationState,
8platformTypeDebugPickConfig,
9DEBUG_TYPES,
10DebugScenarioType,
11} from "../debugConfigTypesAndConstants";
12import { PlatformType } from "../../launchArgs";
13import { ILaunchRequestArgs } from "../../../debugger/debugSessionBase";
14
15export class DebugConfigProvider extends BaseConfigProvider {
16constructor() {
17super();
18this.maxStepCount = 2;
19}
20
21public async buildConfiguration(
22input: MultiStepInput<DebugConfigurationState>,
23state: DebugConfigurationState,
24): Promise<InputStep<DebugConfigurationState> | void> {
25state.config = {};
26const config: Partial<ILaunchRequestArgs> = {
27name: "Debug application",
28request: "launch",
29type: DEBUG_TYPES.REACT_NATIVE,
30cwd: "${workspaceFolder}",
31};
32
33state.scenarioType = DebugScenarioType.DebugApp;
34
35await this.configurationProviderHelper.selectPlatform(
36input,
37config,
38platformTypeDebugPickConfig,
391,
40this.maxStepCount,
41);
42
43Object.assign(state.config, config);
44
008d88e5RedMickey4 years ago45if (state.config.platform !== PlatformType.Exponent) {
0d77292aJiglioNero4 years ago46return async () => {
47await this.configureApplicationType(input, state.config);
48if (
49state.config.platform === PlatformType.iOS &&
50state.config.type === DEBUG_TYPES.REACT_NATIVE_DIRECT
51) {
52this.maxStepCount = 3;
53await this.configureUseHermesEngine(input, state.config);
54// Direct iOS debugging using ios-webkit-debug-proxy is supported
55// only with applications running on the device
56if (state.config.useHermesEngine === false) {
57state.config.target = "device";
6f9a0779JiglioNero5 years ago58}
0d77292aJiglioNero4 years ago59}
60};
5471436aRedMickey5 years ago61} else if (state.config.platform === PlatformType.Exponent) {
62return () => this.configureExpoHostType(input, state.config);
63} else {
64return;
65}
66}
67
68private async configureApplicationType(
69input: MultiStepInput<DebugConfigurationState>,
70config: Partial<ILaunchRequestArgs>,
71): Promise<InputStep<DebugConfigurationState> | void> {
72await this.configurationProviderHelper.selectApplicationType(
73input,
74config,
752,
76this.maxStepCount,
77);
78}
79
80private async configureExpoHostType(
81input: MultiStepInput<DebugConfigurationState>,
82config: Partial<ILaunchRequestArgs>,
83): Promise<InputStep<DebugConfigurationState> | void> {
84await this.configurationProviderHelper.selectExpoHostType(
85input,
86config,
872,
88this.maxStepCount,
89);
90}
6f9a0779JiglioNero5 years ago91
92private async configureUseHermesEngine(
93input: MultiStepInput<DebugConfigurationState>,
94config: Partial<ILaunchRequestArgs>,
95): Promise<InputStep<DebugConfigurationState> | void> {
96delete config.useHermesEngine;
97await this.configurationProviderHelper.shouldUseHermesEngine(
98input,
99config,
1003,
101this.maxStepCount,
102);
103if (config.useHermesEngine) {
104delete config.useHermesEngine;
105}
106}
5471436aRedMickey5 years ago107}