microsoft/vscode-react-native
Publicmirrored from https://github.com/microsoft/vscode-react-nativeAvailable
src/extension/commands/debugScenario.ts
320lines · 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 | |
| 4 | import * as assert from "assert"; |
| 5 | import * as nls from "vscode-nls"; |
| 6 | import * as vscode from "vscode"; |
| 7 | import { ErrorHelper } from "../../common/error/errorHelper"; |
| 8 | import { InternalErrorCode } from "../../common/error/internalErrorCode"; |
| 9 | import { AppLauncher } from "../appLauncher"; |
| 10 | import { |
| 11 | debugConfigurations, |
| 12 | DEBUG_CONFIGURATION_NAMES, |
| 13 | } from "../debuggingConfiguration/debugConfigTypesAndConstants"; |
| 14 | import { Command } from "./util/command"; |
| 15 | |
| 16 | nls.config({ |
| 17 | messageFormat: nls.MessageFormat.bundle, |
| 18 | bundleFormat: nls.BundleFormat.standalone, |
| 19 | })(); |
| 20 | const localize = nls.loadMessageBundle(); |
| 21 | |
| 22 | const startDebug = (debugConfig: typeof debugConfigurations[string], project: AppLauncher) => { |
| 23 | assert( |
| 24 | debugConfig, |
| 25 | new Error( |
| 26 | localize( |
| 27 | "CouldNotFindPredefinedDebugConfig", |
| 28 | "Couldn't find predefined debugging configuration by name '{0}'", |
| 29 | debugConfig.name, |
| 30 | ), |
| 31 | ), |
| 32 | ); |
| 33 | |
| 34 | debugConfig.isDynamic = true; |
| 35 | void vscode.debug.startDebugging(project.getWorkspaceFolder(), debugConfig); |
| 36 | }; |
| 37 | |
| 38 | export class AttachHermesApplicationExperimental extends Command { |
| 39 | codeName = "debugScenario.attachHermesApplicationExperimental"; |
| 40 | label = ""; |
| 41 | error = ErrorHelper.getInternalError( |
| 42 | InternalErrorCode.DebuggingCommandFailed, |
| 43 | DEBUG_CONFIGURATION_NAMES.ATTACH_TO_HERMES_APPLICATION_EXPERIMENTAL, |
| 44 | ); |
| 45 | |
| 46 | async baseFn(): Promise<void> { |
| 47 | assert(this.project); |
| 48 | startDebug( |
| 49 | debugConfigurations[ |
| 50 | DEBUG_CONFIGURATION_NAMES.ATTACH_TO_HERMES_APPLICATION_EXPERIMENTAL |
| 51 | ], |
| 52 | this.project, |
| 53 | ); |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | export class AttachDirectIosExperimental extends Command { |
| 58 | codeName = "debugScenario.attachDirectIosExperimental"; |
| 59 | label = ""; |
| 60 | error = ErrorHelper.getInternalError( |
| 61 | InternalErrorCode.DebuggingCommandFailed, |
| 62 | DEBUG_CONFIGURATION_NAMES.ATTACH_TO_DIRECT_IOS_EXPERIMENTAL, |
| 63 | ); |
| 64 | |
| 65 | async baseFn(): Promise<void> { |
| 66 | assert(this.project); |
| 67 | startDebug( |
| 68 | debugConfigurations[DEBUG_CONFIGURATION_NAMES.ATTACH_TO_DIRECT_IOS_EXPERIMENTAL], |
| 69 | this.project, |
| 70 | ); |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | export class AttachToPackager extends Command { |
| 75 | codeName = "debugScenario.attachToPackager"; |
| 76 | label = ""; |
| 77 | error = ErrorHelper.getInternalError( |
| 78 | InternalErrorCode.DebuggingCommandFailed, |
| 79 | DEBUG_CONFIGURATION_NAMES.ATTACH_TO_PACKAGER, |
| 80 | ); |
| 81 | |
| 82 | async baseFn(): Promise<void> { |
| 83 | assert(this.project); |
| 84 | startDebug(debugConfigurations[DEBUG_CONFIGURATION_NAMES.ATTACH_TO_PACKAGER], this.project); |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | export class DebugAndroid extends Command { |
| 89 | codeName = "debugScenario.debugAndroid"; |
| 90 | label = ""; |
| 91 | error = ErrorHelper.getInternalError( |
| 92 | InternalErrorCode.DebuggingCommandFailed, |
| 93 | DEBUG_CONFIGURATION_NAMES.DEBUG_ANDROID, |
| 94 | ); |
| 95 | |
| 96 | async baseFn(): Promise<void> { |
| 97 | assert(this.project); |
| 98 | startDebug(debugConfigurations[DEBUG_CONFIGURATION_NAMES.DEBUG_ANDROID], this.project); |
| 99 | } |
| 100 | } |
| 101 | |
| 102 | export class DebugIos extends Command { |
| 103 | codeName = "debugScenario.debugIos"; |
| 104 | label = ""; |
| 105 | error = ErrorHelper.getInternalError( |
| 106 | InternalErrorCode.DebuggingCommandFailed, |
| 107 | DEBUG_CONFIGURATION_NAMES.DEBUG_IOS, |
| 108 | ); |
| 109 | |
| 110 | async baseFn(): Promise<void> { |
| 111 | assert(this.project); |
| 112 | startDebug(debugConfigurations[DEBUG_CONFIGURATION_NAMES.DEBUG_IOS], this.project); |
| 113 | } |
| 114 | } |
| 115 | |
| 116 | export class DebugWindows extends Command { |
| 117 | codeName = "debugScenario.debugWindows"; |
| 118 | label = ""; |
| 119 | error = ErrorHelper.getInternalError( |
| 120 | InternalErrorCode.DebuggingCommandFailed, |
| 121 | DEBUG_CONFIGURATION_NAMES.DEBUG_WINDOWS, |
| 122 | ); |
| 123 | |
| 124 | async baseFn(): Promise<void> { |
| 125 | assert(this.project); |
| 126 | startDebug(debugConfigurations[DEBUG_CONFIGURATION_NAMES.DEBUG_WINDOWS], this.project); |
| 127 | } |
| 128 | } |
| 129 | |
| 130 | export class DebugMacos extends Command { |
| 131 | codeName = "debugScenario.debugMacos"; |
| 132 | label = ""; |
| 133 | error = ErrorHelper.getInternalError( |
| 134 | InternalErrorCode.DebuggingCommandFailed, |
| 135 | DEBUG_CONFIGURATION_NAMES.DEBUG_MACOS, |
| 136 | ); |
| 137 | |
| 138 | async baseFn(): Promise<void> { |
| 139 | assert(this.project); |
| 140 | startDebug(debugConfigurations[DEBUG_CONFIGURATION_NAMES.DEBUG_MACOS], this.project); |
| 141 | } |
| 142 | } |
| 143 | |
| 144 | export class DebugInExponent extends Command { |
| 145 | codeName = "debugScenario.debugInExponent"; |
| 146 | label = ""; |
| 147 | error = ErrorHelper.getInternalError( |
| 148 | InternalErrorCode.DebuggingCommandFailed, |
| 149 | DEBUG_CONFIGURATION_NAMES.DEBUG_IN_EXPONENT, |
| 150 | ); |
| 151 | |
| 152 | async baseFn(): Promise<void> { |
| 153 | assert(this.project); |
| 154 | startDebug(debugConfigurations[DEBUG_CONFIGURATION_NAMES.DEBUG_IN_EXPONENT], this.project); |
| 155 | } |
| 156 | } |
| 157 | |
| 158 | export class DebugAndroidHermesExperimental extends Command { |
| 159 | codeName = "debugScenario.debugAndroidHermesExperimental"; |
| 160 | label = ""; |
| 161 | error = ErrorHelper.getInternalError( |
| 162 | InternalErrorCode.DebuggingCommandFailed, |
| 163 | DEBUG_CONFIGURATION_NAMES.DEBUG_ANDROID_HERMES_EXPERIMENTAL, |
| 164 | ); |
| 165 | |
| 166 | async baseFn(): Promise<void> { |
| 167 | assert(this.project); |
| 168 | startDebug( |
| 169 | debugConfigurations[DEBUG_CONFIGURATION_NAMES.DEBUG_ANDROID_HERMES_EXPERIMENTAL], |
| 170 | this.project, |
| 171 | ); |
| 172 | } |
| 173 | } |
| 174 | |
| 175 | export class DebugDirectIosExperimental extends Command { |
| 176 | codeName = "debugScenario.debugDirectIosExperimental"; |
| 177 | label = ""; |
| 178 | error = ErrorHelper.getInternalError( |
| 179 | InternalErrorCode.DebuggingCommandFailed, |
| 180 | DEBUG_CONFIGURATION_NAMES.DEBUG_DIRECT_IOS_EXPERIMENTAL, |
| 181 | ); |
| 182 | |
| 183 | async baseFn(): Promise<void> { |
| 184 | assert(this.project); |
| 185 | startDebug( |
| 186 | debugConfigurations[DEBUG_CONFIGURATION_NAMES.DEBUG_DIRECT_IOS_EXPERIMENTAL], |
| 187 | this.project, |
| 188 | ); |
| 189 | } |
| 190 | } |
| 191 | |
| 192 | export class DebugIosHermesExperimental extends Command { |
| 193 | codeName = "debugScenario.debugIosHermesExperimental"; |
| 194 | label = ""; |
| 195 | error = ErrorHelper.getInternalError( |
| 196 | InternalErrorCode.DebuggingCommandFailed, |
| 197 | DEBUG_CONFIGURATION_NAMES.DEBUG_IOS_HERMES_EXPERIMENTAL, |
| 198 | ); |
| 199 | |
| 200 | async baseFn(): Promise<void> { |
| 201 | assert(this.project); |
| 202 | startDebug( |
| 203 | debugConfigurations[DEBUG_CONFIGURATION_NAMES.DEBUG_IOS_HERMES_EXPERIMENTAL], |
| 204 | this.project, |
| 205 | ); |
| 206 | } |
| 207 | } |
| 208 | |
| 209 | export class DebugMacosHermesExperimental extends Command { |
| 210 | codeName = "debugScenario.debugMacosHermesExperimental"; |
| 211 | label = ""; |
| 212 | error = ErrorHelper.getInternalError( |
| 213 | InternalErrorCode.DebuggingCommandFailed, |
| 214 | DEBUG_CONFIGURATION_NAMES.DEBUG_MACOS_HERMES_EXPERIMENTAL, |
| 215 | ); |
| 216 | |
| 217 | async baseFn(): Promise<void> { |
| 218 | assert(this.project); |
| 219 | startDebug( |
| 220 | debugConfigurations[DEBUG_CONFIGURATION_NAMES.DEBUG_MACOS_HERMES_EXPERIMENTAL], |
| 221 | this.project, |
| 222 | ); |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | export class DebugWindowsHermesExperimental extends Command { |
| 227 | codeName = "debugScenario.debugWindowsHermesExperimental"; |
| 228 | label = ""; |
| 229 | error = ErrorHelper.getInternalError( |
| 230 | InternalErrorCode.DebuggingCommandFailed, |
| 231 | DEBUG_CONFIGURATION_NAMES.DEBUG_WINDOWS_HERMES_EXPERIMENTAL, |
| 232 | ); |
| 233 | |
| 234 | async baseFn(): Promise<void> { |
| 235 | assert(this.project); |
| 236 | startDebug( |
| 237 | debugConfigurations[DEBUG_CONFIGURATION_NAMES.DEBUG_WINDOWS_HERMES_EXPERIMENTAL], |
| 238 | this.project, |
| 239 | ); |
| 240 | } |
| 241 | } |
| 242 | |
| 243 | export class RunAndroid extends Command { |
| 244 | codeName = "debugScenario.runAndroid"; |
| 245 | label = ""; |
| 246 | error = ErrorHelper.getInternalError( |
| 247 | InternalErrorCode.DebuggingCommandFailed, |
| 248 | DEBUG_CONFIGURATION_NAMES.RUN_ANDROID, |
| 249 | ); |
| 250 | |
| 251 | async baseFn(): Promise<void> { |
| 252 | assert(this.project); |
| 253 | startDebug(debugConfigurations[DEBUG_CONFIGURATION_NAMES.RUN_ANDROID], this.project); |
| 254 | } |
| 255 | } |
| 256 | |
| 257 | export class RunIos extends Command { |
| 258 | codeName = "debugScenario.runIos"; |
| 259 | label = ""; |
| 260 | error = ErrorHelper.getInternalError( |
| 261 | InternalErrorCode.DebuggingCommandFailed, |
| 262 | DEBUG_CONFIGURATION_NAMES.RUN_IOS, |
| 263 | ); |
| 264 | |
| 265 | async baseFn(): Promise<void> { |
| 266 | assert(this.project); |
| 267 | startDebug(debugConfigurations[DEBUG_CONFIGURATION_NAMES.RUN_IOS], this.project); |
| 268 | } |
| 269 | } |
| 270 | |
| 271 | export class RunAndroidHermesExperimental extends Command { |
| 272 | codeName = "debugScenario.runAndroidHermesExperimental"; |
| 273 | label = ""; |
| 274 | error = ErrorHelper.getInternalError( |
| 275 | InternalErrorCode.DebuggingCommandFailed, |
| 276 | DEBUG_CONFIGURATION_NAMES.RUN_ANDROID_HERMES_EXPERIMENTAL, |
| 277 | ); |
| 278 | |
| 279 | async baseFn(): Promise<void> { |
| 280 | assert(this.project); |
| 281 | startDebug( |
| 282 | debugConfigurations[DEBUG_CONFIGURATION_NAMES.RUN_ANDROID_HERMES_EXPERIMENTAL], |
| 283 | this.project, |
| 284 | ); |
| 285 | } |
| 286 | } |
| 287 | |
| 288 | export class RunIosHermesExperimental extends Command { |
| 289 | codeName = "debugScenario.runIosHermesExperimental"; |
| 290 | label = ""; |
| 291 | error = ErrorHelper.getInternalError( |
| 292 | InternalErrorCode.DebuggingCommandFailed, |
| 293 | DEBUG_CONFIGURATION_NAMES.RUN_IOS_HERMES_EXPERIMENTAL, |
| 294 | ); |
| 295 | |
| 296 | async baseFn(): Promise<void> { |
| 297 | assert(this.project); |
| 298 | startDebug( |
| 299 | debugConfigurations[DEBUG_CONFIGURATION_NAMES.RUN_IOS_HERMES_EXPERIMENTAL], |
| 300 | this.project, |
| 301 | ); |
| 302 | } |
| 303 | } |
| 304 | |
| 305 | export class RunDirectIosExperimental extends Command { |
| 306 | codeName = "debugScenario.runDirectIosExperimental"; |
| 307 | label = ""; |
| 308 | error = ErrorHelper.getInternalError( |
| 309 | InternalErrorCode.DebuggingCommandFailed, |
| 310 | DEBUG_CONFIGURATION_NAMES.RUN_DIRECT_IOS_EXPERIMENTAL, |
| 311 | ); |
| 312 | |
| 313 | async baseFn(): Promise<void> { |
| 314 | assert(this.project); |
| 315 | startDebug( |
| 316 | debugConfigurations[DEBUG_CONFIGURATION_NAMES.RUN_DIRECT_IOS_EXPERIMENTAL], |
| 317 | this.project, |
| 318 | ); |
| 319 | } |
| 320 | } |
| 321 | |