microsoft/vscode-react-native

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
1.9.2

Branches

Tags

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

Clone

HTTPS

Download ZIP

src/extension/debuggingConfiguration/configurationProviders/attachConfigProvider.ts

102lines · 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 { MultiStepInput, InputStep } from "../multiStepInput";
5import { ILaunchRequestArgs } from "../../../debugger/debugSessionBase";
6import {
7DebugConfigurationState,
8platformTypeDirectPickConfig,
9DEBUG_TYPES,
10DebugScenarioType,
11} from "../debugConfigTypesAndConstants";
09f6024fHeniker4 years ago12import { BaseConfigProvider } from "./baseConfigProvider";
5471436aRedMickey5 years ago13
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}
09f6024fHeniker4 years ago51return () => this.configureAddress(input, state.config);
5471436aRedMickey5 years ago52}
53
54private async configureDirectPlatform(
55input: MultiStepInput<DebugConfigurationState>,
56config: Partial<ILaunchRequestArgs>,
57): Promise<InputStep<DebugConfigurationState> | void> {
58delete config.platform;
59await this.configurationProviderHelper.selectPlatform(
60input,
61config,
62platformTypeDirectPickConfig,
632,
64this.maxStepCount,
65);
66
6f9a0779JiglioNero5 years ago67if (!config.platform) {
68delete config.platform;
69delete config.useHermesEngine;
70} else {
71config.useHermesEngine = false;
72}
73
5471436aRedMickey5 years ago74return () => this.configureAddress(input, config);
75}
76
77private async configureAddress(
78input: MultiStepInput<DebugConfigurationState>,
79config: Partial<ILaunchRequestArgs>,
80): Promise<InputStep<DebugConfigurationState> | void> {
e7a2c40dRedMickey4 years ago81await this.configurationProviderHelper.configureAddress(
82input,
83config,
84config.type === DEBUG_TYPES.REACT_NATIVE_DIRECT ? 3 : 2,
85this.maxStepCount,
86this.defaultAddress,
87);
5471436aRedMickey5 years ago88return () => this.configurePort(input, config);
89}
90
91private async configurePort(
92input: MultiStepInput<DebugConfigurationState>,
93config: Partial<ILaunchRequestArgs>,
94): Promise<InputStep<DebugConfigurationState> | void> {
e7a2c40dRedMickey4 years ago95await this.configurationProviderHelper.configurePort(
96input,
97config,
98config.type === DEBUG_TYPES.REACT_NATIVE_DIRECT ? 4 : 3,
99this.maxStepCount,
5471436aRedMickey5 years ago100);
101}
102}