microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
1.8.0

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/extension/debuggingConfiguration/configurationProviders/attachConfigProvider.ts

103lines · 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 { ILaunchRequestArgs } from "../../../debugger/debugSessionBase";
7import {
8DebugConfigurationState,
9platformTypeDirectPickConfig,
10DEBUG_TYPES,
11DebugScenarioType,
12} from "../debugConfigTypesAndConstants";
13
14export class AttachConfigProvider extends BaseConfigProvider {
15private readonly defaultAddress: string;
16
17constructor() {
18super();
19this.defaultAddress = "localhost";
20this.maxStepCount = 3;
21}
22
23public async buildConfiguration(
24input: MultiStepInput<DebugConfigurationState>,
25state: DebugConfigurationState,
26): Promise<InputStep<DebugConfigurationState> | void> {
27this.maxStepCount = 3;
28state.config = {};
29const config: Partial<ILaunchRequestArgs> = {
30name: "Attach to application",
31request: "attach",
32type: DEBUG_TYPES.REACT_NATIVE,
33cwd: "${workspaceFolder}",
34};
35
36state.scenarioType = DebugScenarioType.AttachApp;
37
38await this.configurationProviderHelper.selectApplicationType(
39input,
40config,
411,
42this.maxStepCount,
43);
44
45Object.assign(state.config, config);
46
47if (state.config.type === DEBUG_TYPES.REACT_NATIVE_DIRECT) {
48this.maxStepCount++;
49return () => this.configureDirectPlatform(input, state.config);
50} else {
51return () => this.configureAddress(input, state.config);
52}
53}
54
55private async configureDirectPlatform(
56input: MultiStepInput<DebugConfigurationState>,
57config: Partial<ILaunchRequestArgs>,
58): Promise<InputStep<DebugConfigurationState> | void> {
59delete config.platform;
60await this.configurationProviderHelper.selectPlatform(
61input,
62config,
63platformTypeDirectPickConfig,
642,
65this.maxStepCount,
66);
67
6f9a0779JiglioNero5 years ago68if (!config.platform) {
69delete config.platform;
70delete config.useHermesEngine;
71} else {
72config.useHermesEngine = false;
73}
74
5471436aRedMickey5 years ago75return () => this.configureAddress(input, config);
76}
77
78private async configureAddress(
79input: MultiStepInput<DebugConfigurationState>,
80config: Partial<ILaunchRequestArgs>,
81): Promise<InputStep<DebugConfigurationState> | void> {
e7a2c40dRedMickey4 years ago82await this.configurationProviderHelper.configureAddress(
83input,
84config,
85config.type === DEBUG_TYPES.REACT_NATIVE_DIRECT ? 3 : 2,
86this.maxStepCount,
87this.defaultAddress,
88);
5471436aRedMickey5 years ago89return () => this.configurePort(input, config);
90}
91
92private async configurePort(
93input: MultiStepInput<DebugConfigurationState>,
94config: Partial<ILaunchRequestArgs>,
95): Promise<InputStep<DebugConfigurationState> | void> {
e7a2c40dRedMickey4 years ago96await this.configurationProviderHelper.configurePort(
97input,
98config,
99config.type === DEBUG_TYPES.REACT_NATIVE_DIRECT ? 4 : 3,
100this.maxStepCount,
5471436aRedMickey5 years ago101);
102}
103}