Cargo.lock 🔗
@@ -4156,9 +4156,7 @@ dependencies = [
"log",
"node_runtime",
"paths",
- "regex",
"reqwest_client",
- "schemars",
"serde",
"serde_json",
"settings",
Cole Miller created
Cargo.lock | 2
crates/dap_adapters/Cargo.toml | 6
crates/dap_adapters/schemas/JavaScript.json | 498 +++++++++++-----------
crates/dap_adapters/src/dap_adapters.rs | 10
crates/dap_adapters/src/javascript.rs | 183 +++++++
crates/dap_adapters/src/update_schemas.rs | 159 ------
6 files changed, 432 insertions(+), 426 deletions(-)
@@ -4156,9 +4156,7 @@ dependencies = [
"log",
"node_runtime",
"paths",
- "regex",
"reqwest_client",
- "schemars",
"serde",
"serde_json",
"settings",
@@ -16,9 +16,7 @@ test-support = [
]
update-schemas = [
"dep:node_runtime",
- "dep:regex",
"dep:reqwest_client",
- "dep:schemars",
"dep:settings",
"dep:tempfile",
]
@@ -56,11 +54,7 @@ util.workspace = true
workspace-hack.workspace = true
node_runtime = { workspace = true, optional = true }
-# FIXME do we still need this
-regex = { workspace = true, optional = true }
reqwest_client = { workspace = true, optional = true }
-# FIXME do we still need this
-schemars = { workspace = true, optional = true }
settings = { workspace = true, optional = true }
tempfile = { workspace = true, optional = true }
@@ -18,50 +18,49 @@
"then": {
"properties": {
"args": {
- "description": "Command line arguments passed to the program.\n\nCan be an array of strings or a single string. When the program is launched in a terminal, setting this property to a single string will result in the arguments not being escaped for the shell.",
- "type": [
- "array",
- "string"
- ],
"default": [],
+ "description": "Command line arguments passed to the program.\n\nCan be an array of strings or a single string. When the program is launched in a terminal, setting this property to a single string will result in the arguments not being escaped for the shell.",
"items": {
"type": "string"
},
"tags": [
"setup"
+ ],
+ "type": [
+ "array",
+ "string"
]
},
"attachSimplePort": {
- "description": "If set, attaches to the process via the given port. This is generally no longer necessary for Node.js programs and loses the ability to debug child processes, but can be useful in more esoteric scenarios such as with Deno and Docker launches. If set to 0, a random port will be chosen and --inspect-brk added to the launch arguments automatically.",
"default": 9229,
+ "description": "If set, attaches to the process via the given port. This is generally no longer necessary for Node.js programs and loses the ability to debug child processes, but can be useful in more esoteric scenarios such as with Deno and Docker launches. If set to 0, a random port will be chosen and --inspect-brk added to the launch arguments automatically.",
"oneOf": [
{
"type": "integer"
},
{
- "type": "string",
- "pattern": "^\\${.*}$"
+ "pattern": "^\\${.*}$",
+ "type": "string"
}
]
},
"autoAttachChildProcesses": {
+ "default": true,
"description": "Attach debugger to new child processes automatically.",
- "type": "boolean",
- "default": true
+ "type": "boolean"
},
"cascadeTerminateToConfigurations": {
- "description": "A list of debug sessions which, when this debug session is terminated, will also be stopped.",
- "type": "array",
"default": [],
+ "description": "A list of debug sessions which, when this debug session is terminated, will also be stopped.",
"items": {
"type": "string",
"uniqueItems": true
- }
+ },
+ "type": "array"
},
"console": {
- "description": "Where to launch the debug target.",
- "type": "string",
"default": "internalConsole",
+ "description": "Where to launch the debug target.",
"enum": [
"internalConsole",
"integratedTerminal",
@@ -71,37 +70,37 @@
"VS Code Debug Console (which doesn't support to read input from a program)",
"VS Code's integrated terminal",
"External terminal that can be configured via user settings"
- ]
+ ],
+ "type": "string"
},
"customDescriptionGenerator": {
"description": "Customize the textual description the debugger shows for objects (local variables, etc...). Samples:\n 1. this.toString() // will call toString to print all objects\n 2. this.customDescription ? this.customDescription() : defaultValue // Use customDescription method if available, if not return defaultValue\n 3. function (def) { return this.customDescription ? this.customDescription() : def } // Use customDescription method if available, if not return defaultValue\n ",
"type": "string"
},
"customPropertiesGenerator": {
+ "deprecated": true,
"description": "Customize the properties shown for an object in the debugger (local variables, etc...). Samples:\n 1. { ...this, extraProperty: '12345' } // Add an extraProperty 12345 to all objects\n 2. this.customProperties ? this.customProperties() : this // Use customProperties method if available, if not use the properties in this (the default properties)\n 3. function () { return this.customProperties ? this.customProperties() : this } // Use customDescription method if available, if not return the default properties\n\n Deprecated: This is a temporary implementation of this feature until we have time to implement it in the way described here: https://github.com/microsoft/vscode/issues/102181",
- "type": "string",
- "deprecated": true
+ "type": "string"
},
"cwd": {
- "description": "Absolute path to the working directory of the program being debugged. If you've set localRoot then cwd will match that value otherwise it falls back to your workspaceFolder",
- "type": "string",
"default": "${ZED_WORKTREE_ROOT}",
+ "description": "Absolute path to the working directory of the program being debugged. If you've set localRoot then cwd will match that value otherwise it falls back to your workspaceFolder",
"tags": [
"setup"
- ]
+ ],
+ "type": "string"
},
"enableContentValidation": {
+ "default": true,
"description": "Toggles whether we verify the contents of files on disk match the ones loaded in the runtime. This is useful in a variety of scenarios and required in some, but can cause issues if you have server-side transformation of scripts, for example.",
- "type": "boolean",
- "default": true
+ "type": "boolean"
},
"enableDWARF": {
- "type": "boolean",
"default": true,
- "markdownDescription": "Toggles whether the debugger will try to read DWARF debug symbols from WebAssembly, which can be resource intensive. Requires the `ms-vscode.wasm-dwarf-debugging` extension to function."
+ "markdownDescription": "Toggles whether the debugger will try to read DWARF debug symbols from WebAssembly, which can be resource intensive. Requires the `ms-vscode.wasm-dwarf-debugging` extension to function.",
+ "type": "boolean"
},
"env": {
- "type": "object",
"additionalProperties": {
"type": [
"string",
@@ -112,61 +111,62 @@
"markdownDescription": "Environment variables passed to the program. The value `null` removes the variable from the environment.",
"tags": [
"setup"
- ]
+ ],
+ "type": "object"
},
"envFile": {
+ "default": "${ZED_WORKTREE_ROOT}/.env",
"description": "Absolute path to a file containing environment variable definitions.",
- "type": "string",
- "default": "${ZED_WORKTREE_ROOT}/.env"
+ "type": "string"
},
"experimentalNetworking": {
- "description": "Enable experimental inspection in Node.js. When set to `auto` this is enabled for versions of Node.js that support it. It can be set to `on` or `off` to enable or disable it explicitly.",
- "type": "string",
"default": "auto",
+ "description": "Enable experimental inspection in Node.js. When set to `auto` this is enabled for versions of Node.js that support it. It can be set to `on` or `off` to enable or disable it explicitly.",
"enum": [
"auto",
"on",
"off"
- ]
+ ],
+ "type": "string"
},
"killBehavior": {
- "type": "string",
"default": "forceful",
"enum": [
"forceful",
"polite",
"none"
],
- "markdownDescription": "Configures how debug processes are killed when stopping the session. Can be:\n\n- forceful (default): forcefully tears down the process tree. Sends SIGKILL on posix, or `taskkill.exe /F` on Windows.\n- polite: gracefully tears down the process tree. It's possible that misbehaving processes continue to run after shutdown in this way. Sends SIGTERM on posix, or `taskkill.exe` with no `/F` (force) flag on Windows.\n- none: no termination will happen."
+ "markdownDescription": "Configures how debug processes are killed when stopping the session. Can be:\n\n- forceful (default): forcefully tears down the process tree. Sends SIGKILL on posix, or `taskkill.exe /F` on Windows.\n- polite: gracefully tears down the process tree. It's possible that misbehaving processes continue to run after shutdown in this way. Sends SIGTERM on posix, or `taskkill.exe` with no `/F` (force) flag on Windows.\n- none: no termination will happen.",
+ "type": "string"
},
"localRoot": {
+ "default": null,
"description": "Path to the local directory containing the program.",
"type": [
"string",
"null"
- ],
- "default": null
+ ]
},
"nodeVersionHint": {
- "description": "Allows you to explicitly specify the Node version that's running, which can be used to disable or enable certain behaviors in cases where the automatic version detection does not work.",
- "type": "number",
"default": 12,
- "minimum": 8
+ "description": "Allows you to explicitly specify the Node version that's running, which can be used to disable or enable certain behaviors in cases where the automatic version detection does not work.",
+ "minimum": 8,
+ "type": "number"
},
"outFiles": {
- "description": "If source maps are enabled, these glob patterns specify the generated JavaScript files. If a pattern starts with `!` the files are excluded. If not specified, the generated code is expected in the same directory as its source.",
- "type": [
- "array"
- ],
"default": [
"${ZED_WORKTREE_ROOT}/**/*.(m|c|)js",
"!**/node_modules/**"
],
+ "description": "If source maps are enabled, these glob patterns specify the generated JavaScript files. If a pattern starts with `!` the files are excluded. If not specified, the generated code is expected in the same directory as its source.",
"items": {
"type": "string"
},
"tags": [
"setup"
+ ],
+ "type": [
+ "array"
]
},
"outputCapture": {
@@ -178,212 +178,212 @@
"markdownDescription": "From where to capture output messages: the default debug API if set to `console`, or stdout/stderr streams if set to `std`."
},
"pauseForSourceMap": {
- "type": "boolean",
"default": false,
- "markdownDescription": "Whether to wait for source maps to load for each incoming script. This has a performance overhead, and might be safely disabled when running off of disk, so long as `rootPath` is not disabled."
+ "markdownDescription": "Whether to wait for source maps to load for each incoming script. This has a performance overhead, and might be safely disabled when running off of disk, so long as `rootPath` is not disabled.",
+ "type": "boolean"
},
"profileStartup": {
+ "default": true,
"description": "If true, will start profiling as soon as the process launches",
- "type": "boolean",
- "default": true
+ "type": "boolean"
},
"program": {
- "description": "Absolute path to the program. Generated value is guessed by looking at package.json and opened files. Edit this attribute.",
- "type": "string",
"default": "",
+ "description": "Absolute path to the program. Generated value is guessed by looking at package.json and opened files. Edit this attribute.",
"tags": [
"setup"
- ]
+ ],
+ "type": "string"
},
"remoteRoot": {
+ "default": null,
"description": "Absolute path to the remote directory containing the program.",
"type": [
"string",
"null"
- ],
- "default": null
+ ]
},
"resolveSourceMapLocations": {
- "description": "A list of minimatch patterns for locations (folders and URLs) in which source maps can be used to resolve local files. This can be used to avoid incorrectly breaking in external source mapped code. Patterns can be prefixed with \"!\" to exclude them. May be set to an empty array or null to avoid restriction.",
- "type": [
- "array",
- "null"
- ],
"default": [
"${ZED_WORKTREE_ROOT}/**",
"!**/node_modules/**"
],
+ "description": "A list of minimatch patterns for locations (folders and URLs) in which source maps can be used to resolve local files. This can be used to avoid incorrectly breaking in external source mapped code. Patterns can be prefixed with \"!\" to exclude them. May be set to an empty array or null to avoid restriction.",
"items": {
"type": "string"
- }
+ },
+ "type": [
+ "array",
+ "null"
+ ]
},
"restart": {
- "description": "Try to reconnect to the program if we lose connection. If set to `true`, we'll try once a second, forever. You can customize the interval and maximum number of attempts by specifying the `delay` and `maxAttempts` in an object instead.",
"default": true,
+ "description": "Try to reconnect to the program if we lose connection. If set to `true`, we'll try once a second, forever. You can customize the interval and maximum number of attempts by specifying the `delay` and `maxAttempts` in an object instead.",
"oneOf": [
{
"type": "boolean"
},
{
- "type": "object",
"properties": {
"delay": {
- "type": "number",
"default": 1000,
- "minimum": 0
+ "minimum": 0,
+ "type": "number"
},
"maxAttempts": {
- "type": "number",
"default": 10,
- "minimum": 0
+ "minimum": 0,
+ "type": "number"
}
- }
+ },
+ "type": "object"
}
]
},
"runtimeArgs": {
- "description": "Optional arguments passed to the runtime executable.",
- "type": "array",
"default": [],
+ "description": "Optional arguments passed to the runtime executable.",
"items": {
"type": "string"
},
"tags": [
"setup"
- ]
+ ],
+ "type": "array"
},
"runtimeExecutable": {
+ "default": "node",
+ "markdownDescription": "Runtime to use. Either an absolute path or the name of a runtime available on the PATH. If omitted `node` is assumed.",
"type": [
"string",
"null"
- ],
- "default": "node",
- "markdownDescription": "Runtime to use. Either an absolute path or the name of a runtime available on the PATH. If omitted `node` is assumed."
+ ]
},
"runtimeSourcemapPausePatterns": {
- "type": "array",
"default": [],
"items": {
"type": "string"
},
- "markdownDescription": "A list of patterns at which to manually insert entrypoint breakpoints. This can be useful to give the debugger an opportunity to set breakpoints when using sourcemaps that don't exist or can't be detected before launch, such as [with the Serverless framework](https://github.com/microsoft/vscode-js-debug/issues/492)."
+ "markdownDescription": "A list of patterns at which to manually insert entrypoint breakpoints. This can be useful to give the debugger an opportunity to set breakpoints when using sourcemaps that don't exist or can't be detected before launch, such as [with the Serverless framework](https://github.com/microsoft/vscode-js-debug/issues/492).",
+ "type": "array"
},
"runtimeVersion": {
- "type": "string",
"default": "default",
- "markdownDescription": "Version of `node` runtime to use. Requires `nvm`."
+ "markdownDescription": "Version of `node` runtime to use. Requires `nvm`.",
+ "type": "string"
},
"showAsyncStacks": {
- "description": "Show the async calls that led to the current call stack.",
"default": true,
+ "description": "Show the async calls that led to the current call stack.",
"oneOf": [
{
"type": "boolean"
},
{
- "type": "object",
"properties": {
"onAttach": {
- "type": "number",
- "default": 32
+ "default": 32,
+ "type": "number"
}
},
"required": [
"onAttach"
- ]
+ ],
+ "type": "object"
},
{
- "type": "object",
"properties": {
"onceBreakpointResolved": {
- "type": "number",
- "default": 32
+ "default": 32,
+ "type": "number"
}
},
"required": [
"onceBreakpointResolved"
- ]
+ ],
+ "type": "object"
}
]
},
"skipFiles": {
- "description": "An array of file or folder names, or path globs, to skip when debugging. Star patterns and negations are allowed, for example, `[\"**/node_modules/**\", \"!**/node_modules/my-module/**\"]`",
- "type": "array",
"default": [
"${/**"
- ]
+ ],
+ "description": "An array of file or folder names, or path globs, to skip when debugging. Star patterns and negations are allowed, for example, `[\"**/node_modules/**\", \"!**/node_modules/my-module/**\"]`",
+ "type": "array"
},
"smartStep": {
+ "default": true,
"description": "Automatically step through generated code that cannot be mapped back to the original source.",
- "type": "boolean",
- "default": true
+ "type": "boolean"
},
"sourceMapPathOverrides": {
- "description": "A set of mappings for rewriting the locations of source files from what the sourcemap says, to their locations on disk.",
- "type": "object",
"default": {
"meteor://💻app/*": "${ZED_WORKTREE_ROOT}/*",
"webpack:///./~/*": "${ZED_WORKTREE_ROOT}/node_modules/*",
"webpack://?:*/*": "${ZED_WORKTREE_ROOT}/*"
- }
+ },
+ "description": "A set of mappings for rewriting the locations of source files from what the sourcemap says, to their locations on disk.",
+ "type": "object"
},
"sourceMapRenames": {
+ "default": true,
"description": "Whether to use the \"names\" mapping in sourcemaps. This requires requesting source content, which can be slow with certain debuggers.",
- "type": "boolean",
- "default": true
+ "type": "boolean"
},
"sourceMaps": {
+ "default": true,
"description": "Use JavaScript source maps (if they exist).",
- "type": "boolean",
- "default": true
+ "type": "boolean"
},
"stopOnEntry": {
+ "default": true,
"description": "Automatically stop program after launch.",
"type": [
"boolean",
"string"
- ],
- "default": true
+ ]
},
"timeout": {
+ "default": 10000,
"description": "Retry for this number of milliseconds to connect to Node.js. Default is 10000 ms.",
- "type": "number",
- "default": 10000
+ "type": "number"
},
"timeouts": {
+ "additionalProperties": false,
+ "default": {},
"description": "Timeouts for several debugger operations.",
- "type": "object",
+ "markdownDescription": "Timeouts for several debugger operations.",
"properties": {
"hoverEvaluation": {
+ "default": 500,
"description": "Time until value evaluation for hovered symbols is aborted. If set to 0, hover evaluation does never time out.",
- "type": "number",
- "default": 500
+ "type": "number"
},
"sourceMapCumulativePause": {
+ "default": 1000,
"description": "Extra time in milliseconds allowed per session to be spent waiting for source-maps to be processed, after the minimum time (sourceMapMinPause) has been exhausted",
- "type": "number",
- "default": 1000
+ "type": "number"
},
"sourceMapMinPause": {
+ "default": 1000,
"description": "Minimum time in milliseconds spent waiting for each source-map to be processed when a script is being parsed",
- "type": "number",
- "default": 1000
+ "type": "number"
}
},
- "additionalProperties": false,
- "default": {},
- "markdownDescription": "Timeouts for several debugger operations."
+ "type": "object"
},
"trace": {
- "description": "Configures what diagnostic output is produced.",
"default": true,
+ "description": "Configures what diagnostic output is produced.",
"oneOf": [
{
"description": "Trace may be set to 'true' to write diagnostic logs to the disk.",
"type": "boolean"
},
{
- "type": "object",
+ "additionalProperties": false,
"properties": {
"logFile": {
"description": "Configures where on disk logs are written.",
@@ -397,7 +397,7 @@
"type": "boolean"
}
},
- "additionalProperties": false
+ "type": "object"
}
]
}
@@ -422,63 +422,62 @@
"then": {
"properties": {
"address": {
+ "default": "localhost",
"description": "TCP/IP address of process to be debugged. Default is 'localhost'.",
- "type": "string",
- "default": "localhost"
+ "type": "string"
},
"attachExistingChildren": {
+ "default": false,
"description": "Whether to attempt to attach to already-spawned child processes.",
- "type": "boolean",
- "default": false
+ "type": "boolean"
},
"autoAttachChildProcesses": {
+ "default": true,
"description": "Attach debugger to new child processes automatically.",
- "type": "boolean",
- "default": true
+ "type": "boolean"
},
"cascadeTerminateToConfigurations": {
- "description": "A list of debug sessions which, when this debug session is terminated, will also be stopped.",
- "type": "array",
"default": [],
+ "description": "A list of debug sessions which, when this debug session is terminated, will also be stopped.",
"items": {
"type": "string",
"uniqueItems": true
- }
+ },
+ "type": "array"
},
"continueOnAttach": {
- "type": "boolean",
"default": true,
- "markdownDescription": "If true, we'll automatically resume programs launched and waiting on `--inspect-brk`"
+ "markdownDescription": "If true, we'll automatically resume programs launched and waiting on `--inspect-brk`",
+ "type": "boolean"
},
"customDescriptionGenerator": {
"description": "Customize the textual description the debugger shows for objects (local variables, etc...). Samples:\n 1. this.toString() // will call toString to print all objects\n 2. this.customDescription ? this.customDescription() : defaultValue // Use customDescription method if available, if not return defaultValue\n 3. function (def) { return this.customDescription ? this.customDescription() : def } // Use customDescription method if available, if not return defaultValue\n ",
"type": "string"
},
"customPropertiesGenerator": {
+ "deprecated": true,
"description": "Customize the properties shown for an object in the debugger (local variables, etc...). Samples:\n 1. { ...this, extraProperty: '12345' } // Add an extraProperty 12345 to all objects\n 2. this.customProperties ? this.customProperties() : this // Use customProperties method if available, if not use the properties in this (the default properties)\n 3. function () { return this.customProperties ? this.customProperties() : this } // Use customDescription method if available, if not return the default properties\n\n Deprecated: This is a temporary implementation of this feature until we have time to implement it in the way described here: https://github.com/microsoft/vscode/issues/102181",
- "type": "string",
- "deprecated": true
+ "type": "string"
},
"cwd": {
- "description": "Absolute path to the working directory of the program being debugged. If you've set localRoot then cwd will match that value otherwise it falls back to your workspaceFolder",
- "type": "string",
"default": "${ZED_WORKTREE_ROOT}",
+ "description": "Absolute path to the working directory of the program being debugged. If you've set localRoot then cwd will match that value otherwise it falls back to your workspaceFolder",
"tags": [
"setup"
- ]
+ ],
+ "type": "string"
},
"enableContentValidation": {
+ "default": true,
"description": "Toggles whether we verify the contents of files on disk match the ones loaded in the runtime. This is useful in a variety of scenarios and required in some, but can cause issues if you have server-side transformation of scripts, for example.",
- "type": "boolean",
- "default": true
+ "type": "boolean"
},
"enableDWARF": {
- "type": "boolean",
"default": true,
- "markdownDescription": "Toggles whether the debugger will try to read DWARF debug symbols from WebAssembly, which can be resource intensive. Requires the `ms-vscode.wasm-dwarf-debugging` extension to function."
+ "markdownDescription": "Toggles whether the debugger will try to read DWARF debug symbols from WebAssembly, which can be resource intensive. Requires the `ms-vscode.wasm-dwarf-debugging` extension to function.",
+ "type": "boolean"
},
"env": {
- "type": "object",
"additionalProperties": {
"type": [
"string",
@@ -489,41 +488,42 @@
"markdownDescription": "Environment variables passed to the program. The value `null` removes the variable from the environment.",
"tags": [
"setup"
- ]
+ ],
+ "type": "object"
},
"envFile": {
+ "default": "${ZED_WORKTREE_ROOT}/.env",
"description": "Absolute path to a file containing environment variable definitions.",
- "type": "string",
- "default": "${ZED_WORKTREE_ROOT}/.env"
+ "type": "string"
},
"localRoot": {
+ "default": null,
"description": "Path to the local directory containing the program.",
"type": [
"string",
"null"
- ],
- "default": null
+ ]
},
"nodeVersionHint": {
- "description": "Allows you to explicitly specify the Node version that's running, which can be used to disable or enable certain behaviors in cases where the automatic version detection does not work.",
- "type": "number",
"default": 12,
- "minimum": 8
+ "description": "Allows you to explicitly specify the Node version that's running, which can be used to disable or enable certain behaviors in cases where the automatic version detection does not work.",
+ "minimum": 8,
+ "type": "number"
},
"outFiles": {
- "description": "If source maps are enabled, these glob patterns specify the generated JavaScript files. If a pattern starts with `!` the files are excluded. If not specified, the generated code is expected in the same directory as its source.",
- "type": [
- "array"
- ],
"default": [
"${ZED_WORKTREE_ROOT}/**/*.(m|c|)js",
"!**/node_modules/**"
],
+ "description": "If source maps are enabled, these glob patterns specify the generated JavaScript files. If a pattern starts with `!` the files are excluded. If not specified, the generated code is expected in the same directory as its source.",
"items": {
"type": "string"
},
"tags": [
"setup"
+ ],
+ "type": [
+ "array"
]
},
"outputCapture": {
@@ -535,20 +535,20 @@
"markdownDescription": "From where to capture output messages: the default debug API if set to `console`, or stdout/stderr streams if set to `std`."
},
"pauseForSourceMap": {
- "type": "boolean",
"default": false,
- "markdownDescription": "Whether to wait for source maps to load for each incoming script. This has a performance overhead, and might be safely disabled when running off of disk, so long as `rootPath` is not disabled."
+ "markdownDescription": "Whether to wait for source maps to load for each incoming script. This has a performance overhead, and might be safely disabled when running off of disk, so long as `rootPath` is not disabled.",
+ "type": "boolean"
},
"port": {
- "description": "Debug port to attach to. Default is 9229.",
"default": 9229,
+ "description": "Debug port to attach to. Default is 9229.",
"oneOf": [
{
"type": "integer"
},
{
- "type": "string",
- "pattern": "^\\${.*}$"
+ "pattern": "^\\${.*}$",
+ "type": "string"
}
],
"tags": [
@@ -556,171 +556,171 @@
]
},
"processId": {
+ "default": "${command:PickProcess}",
"description": "ID of process to attach to.",
- "type": "string",
- "default": "${command:PickProcess}"
+ "type": "string"
},
"remoteHostHeader": {
"description": "Explicit Host header to use when connecting to the websocket of inspector. If unspecified, the host header will be set to 'localhost'. This is useful when the inspector is running behind a proxy that only accept particular Host header.",
"type": "string"
},
"remoteRoot": {
+ "default": null,
"description": "Absolute path to the remote directory containing the program.",
"type": [
"string",
"null"
- ],
- "default": null
+ ]
},
"resolveSourceMapLocations": {
- "description": "A list of minimatch patterns for locations (folders and URLs) in which source maps can be used to resolve local files. This can be used to avoid incorrectly breaking in external source mapped code. Patterns can be prefixed with \"!\" to exclude them. May be set to an empty array or null to avoid restriction.",
- "type": [
- "array",
- "null"
- ],
"default": [
"${ZED_WORKTREE_ROOT}/**",
"!**/node_modules/**"
],
+ "description": "A list of minimatch patterns for locations (folders and URLs) in which source maps can be used to resolve local files. This can be used to avoid incorrectly breaking in external source mapped code. Patterns can be prefixed with \"!\" to exclude them. May be set to an empty array or null to avoid restriction.",
"items": {
"type": "string"
- }
+ },
+ "type": [
+ "array",
+ "null"
+ ]
},
"restart": {
- "description": "Try to reconnect to the program if we lose connection. If set to `true`, we'll try once a second, forever. You can customize the interval and maximum number of attempts by specifying the `delay` and `maxAttempts` in an object instead.",
"default": true,
+ "description": "Try to reconnect to the program if we lose connection. If set to `true`, we'll try once a second, forever. You can customize the interval and maximum number of attempts by specifying the `delay` and `maxAttempts` in an object instead.",
"oneOf": [
{
"type": "boolean"
},
{
- "type": "object",
"properties": {
"delay": {
- "type": "number",
"default": 1000,
- "minimum": 0
+ "minimum": 0,
+ "type": "number"
},
"maxAttempts": {
- "type": "number",
"default": 10,
- "minimum": 0
+ "minimum": 0,
+ "type": "number"
}
- }
+ },
+ "type": "object"
}
]
},
"runtimeSourcemapPausePatterns": {
- "type": "array",
"default": [],
"items": {
"type": "string"
},
- "markdownDescription": "A list of patterns at which to manually insert entrypoint breakpoints. This can be useful to give the debugger an opportunity to set breakpoints when using sourcemaps that don't exist or can't be detected before launch, such as [with the Serverless framework](https://github.com/microsoft/vscode-js-debug/issues/492)."
+ "markdownDescription": "A list of patterns at which to manually insert entrypoint breakpoints. This can be useful to give the debugger an opportunity to set breakpoints when using sourcemaps that don't exist or can't be detected before launch, such as [with the Serverless framework](https://github.com/microsoft/vscode-js-debug/issues/492).",
+ "type": "array"
},
"showAsyncStacks": {
- "description": "Show the async calls that led to the current call stack.",
"default": true,
+ "description": "Show the async calls that led to the current call stack.",
"oneOf": [
{
"type": "boolean"
},
{
- "type": "object",
"properties": {
"onAttach": {
- "type": "number",
- "default": 32
+ "default": 32,
+ "type": "number"
}
},
"required": [
"onAttach"
- ]
+ ],
+ "type": "object"
},
{
- "type": "object",
"properties": {
"onceBreakpointResolved": {
- "type": "number",
- "default": 32
+ "default": 32,
+ "type": "number"
}
},
"required": [
"onceBreakpointResolved"
- ]
+ ],
+ "type": "object"
}
]
},
"skipFiles": {
- "description": "An array of file or folder names, or path globs, to skip when debugging. Star patterns and negations are allowed, for example, `[\"**/node_modules/**\", \"!**/node_modules/my-module/**\"]`",
- "type": "array",
"default": [
"${/**"
- ]
+ ],
+ "description": "An array of file or folder names, or path globs, to skip when debugging. Star patterns and negations are allowed, for example, `[\"**/node_modules/**\", \"!**/node_modules/my-module/**\"]`",
+ "type": "array"
},
"smartStep": {
+ "default": true,
"description": "Automatically step through generated code that cannot be mapped back to the original source.",
- "type": "boolean",
- "default": true
+ "type": "boolean"
},
"sourceMapPathOverrides": {
- "description": "A set of mappings for rewriting the locations of source files from what the sourcemap says, to their locations on disk.",
- "type": "object",
"default": {
"meteor://💻app/*": "${ZED_WORKTREE_ROOT}/*",
"webpack:///./~/*": "${ZED_WORKTREE_ROOT}/node_modules/*",
"webpack://?:*/*": "${ZED_WORKTREE_ROOT}/*"
- }
+ },
+ "description": "A set of mappings for rewriting the locations of source files from what the sourcemap says, to their locations on disk.",
+ "type": "object"
},
"sourceMapRenames": {
+ "default": true,
"description": "Whether to use the \"names\" mapping in sourcemaps. This requires requesting source content, which can be slow with certain debuggers.",
- "type": "boolean",
- "default": true
+ "type": "boolean"
},
"sourceMaps": {
+ "default": true,
"description": "Use JavaScript source maps (if they exist).",
- "type": "boolean",
- "default": true
+ "type": "boolean"
},
"timeout": {
+ "default": 10000,
"description": "Retry for this number of milliseconds to connect to Node.js. Default is 10000 ms.",
- "type": "number",
- "default": 10000
+ "type": "number"
},
"timeouts": {
+ "additionalProperties": false,
+ "default": {},
"description": "Timeouts for several debugger operations.",
- "type": "object",
+ "markdownDescription": "Timeouts for several debugger operations.",
"properties": {
"hoverEvaluation": {
+ "default": 500,
"description": "Time until value evaluation for hovered symbols is aborted. If set to 0, hover evaluation does never time out.",
- "type": "number",
- "default": 500
+ "type": "number"
},
"sourceMapCumulativePause": {
+ "default": 1000,
"description": "Extra time in milliseconds allowed per session to be spent waiting for source-maps to be processed, after the minimum time (sourceMapMinPause) has been exhausted",
- "type": "number",
- "default": 1000
+ "type": "number"
},
"sourceMapMinPause": {
+ "default": 1000,
"description": "Minimum time in milliseconds spent waiting for each source-map to be processed when a script is being parsed",
- "type": "number",
- "default": 1000
+ "type": "number"
}
},
- "additionalProperties": false,
- "default": {},
- "markdownDescription": "Timeouts for several debugger operations."
+ "type": "object"
},
"trace": {
- "description": "Configures what diagnostic output is produced.",
"default": true,
+ "description": "Configures what diagnostic output is produced.",
"oneOf": [
{
"description": "Trace may be set to 'true' to write diagnostic logs to the disk.",
"type": "boolean"
},
{
- "type": "object",
+ "additionalProperties": false,
"properties": {
"logFile": {
"description": "Configures where on disk logs are written.",
@@ -734,7 +734,7 @@
"type": "boolean"
}
},
- "additionalProperties": false
+ "type": "object"
}
]
},
@@ -763,50 +763,49 @@
"then": {
"properties": {
"args": {
- "description": "Command line arguments passed to the program.\n\nCan be an array of strings or a single string. When the program is launched in a terminal, setting this property to a single string will result in the arguments not being escaped for the shell.",
- "type": [
- "array",
- "string"
- ],
"default": [],
+ "description": "Command line arguments passed to the program.\n\nCan be an array of strings or a single string. When the program is launched in a terminal, setting this property to a single string will result in the arguments not being escaped for the shell.",
"items": {
"type": "string"
},
"tags": [
"setup"
+ ],
+ "type": [
+ "array",
+ "string"
]
},
"attachSimplePort": {
- "description": "If set, attaches to the process via the given port. This is generally no longer necessary for Node.js programs and loses the ability to debug child processes, but can be useful in more esoteric scenarios such as with Deno and Docker launches. If set to 0, a random port will be chosen and --inspect-brk added to the launch arguments automatically.",
"default": 9229,
+ "description": "If set, attaches to the process via the given port. This is generally no longer necessary for Node.js programs and loses the ability to debug child processes, but can be useful in more esoteric scenarios such as with Deno and Docker launches. If set to 0, a random port will be chosen and --inspect-brk added to the launch arguments automatically.",
"oneOf": [
{
"type": "integer"
},
{
- "type": "string",
- "pattern": "^\\${.*}$"
+ "pattern": "^\\${.*}$",
+ "type": "string"
}
]
},
"autoAttachChildProcesses": {
+ "default": true,
"description": "Attach debugger to new child processes automatically.",
- "type": "boolean",
- "default": true
+ "type": "boolean"
},
"cascadeTerminateToConfigurations": {
- "description": "A list of debug sessions which, when this debug session is terminated, will also be stopped.",
- "type": "array",
"default": [],
+ "description": "A list of debug sessions which, when this debug session is terminated, will also be stopped.",
"items": {
"type": "string",
"uniqueItems": true
- }
+ },
+ "type": "array"
},
"console": {
- "description": "Where to launch the debug target.",
- "type": "string",
"default": "internalConsole",
+ "description": "Where to launch the debug target.",
"enum": [
"internalConsole",
"integratedTerminal",
@@ -816,37 +815,37 @@
"VS Code Debug Console (which doesn't support to read input from a program)",
"VS Code's integrated terminal",
"External terminal that can be configured via user settings"
- ]
+ ],
+ "type": "string"
},
"customDescriptionGenerator": {
"description": "Customize the textual description the debugger shows for objects (local variables, etc...). Samples:\n 1. this.toString() // will call toString to print all objects\n 2. this.customDescription ? this.customDescription() : defaultValue // Use customDescription method if available, if not return defaultValue\n 3. function (def) { return this.customDescription ? this.customDescription() : def } // Use customDescription method if available, if not return defaultValue\n ",
"type": "string"
},
"customPropertiesGenerator": {
+ "deprecated": true,
"description": "Customize the properties shown for an object in the debugger (local variables, etc...). Samples:\n 1. { ...this, extraProperty: '12345' } // Add an extraProperty 12345 to all objects\n 2. this.customProperties ? this.customProperties() : this // Use customProperties method if available, if not use the properties in this (the default properties)\n 3. function () { return this.customProperties ? this.customProperties() : this } // Use customDescription method if available, if not return the default properties\n\n Deprecated: This is a temporary implementation of this feature until we have time to implement it in the way described here: https://github.com/microsoft/vscode/issues/102181",
- "type": "string",
- "deprecated": true
+ "type": "string"
},
"cwd": {
- "description": "Absolute path to the working directory of the program being debugged. If you've set localRoot then cwd will match that value otherwise it falls back to your workspaceFolder",
- "type": "string",
"default": "${ZED_WORKTREE_ROOT}",
+ "description": "Absolute path to the working directory of the program being debugged. If you've set localRoot then cwd will match that value otherwise it falls back to your workspaceFolder",
"tags": [
"setup"
- ]
+ ],
+ "type": "string"
},
"enableContentValidation": {
+ "default": true,
"description": "Toggles whether we verify the contents of files on disk match the ones loaded in the runtime. This is useful in a variety of scenarios and required in some, but can cause issues if you have server-side transformation of scripts, for example.",
- "type": "boolean",
- "default": true
+ "type": "boolean"
},
"enableDWARF": {
- "type": "boolean",
"default": true,
- "markdownDescription": "Toggles whether the debugger will try to read DWARF debug symbols from WebAssembly, which can be resource intensive. Requires the `ms-vscode.wasm-dwarf-debugging` extension to function."
+ "markdownDescription": "Toggles whether the debugger will try to read DWARF debug symbols from WebAssembly, which can be resource intensive. Requires the `ms-vscode.wasm-dwarf-debugging` extension to function.",
+ "type": "boolean"
},
"env": {
- "type": "object",
"additionalProperties": {
"type": [
"string",
@@ -857,61 +856,62 @@
"markdownDescription": "Environment variables passed to the program. The value `null` removes the variable from the environment.",
"tags": [
"setup"
- ]
+ ],
+ "type": "object"
},
"envFile": {
+ "default": "${ZED_WORKTREE_ROOT}/.env",
"description": "Absolute path to a file containing environment variable definitions.",
- "type": "string",
- "default": "${ZED_WORKTREE_ROOT}/.env"
+ "type": "string"
},
"experimentalNetworking": {
- "description": "Enable experimental inspection in Node.js. When set to `auto` this is enabled for versions of Node.js that support it. It can be set to `on` or `off` to enable or disable it explicitly.",
- "type": "string",
"default": "auto",
+ "description": "Enable experimental inspection in Node.js. When set to `auto` this is enabled for versions of Node.js that support it. It can be set to `on` or `off` to enable or disable it explicitly.",
"enum": [
"auto",
"on",
"off"
- ]
+ ],
+ "type": "string"
},
"killBehavior": {
- "type": "string",
"default": "forceful",
"enum": [
"forceful",
"polite",
"none"
],
- "markdownDescription": "Configures how debug processes are killed when stopping the session. Can be:\n\n- forceful (default): forcefully tears down the process tree. Sends SIGKILL on posix, or `taskkill.exe /F` on Windows.\n- polite: gracefully tears down the process tree. It's possible that misbehaving processes continue to run after shutdown in this way. Sends SIGTERM on posix, or `taskkill.exe` with no `/F` (force) flag on Windows.\n- none: no termination will happen."
+ "markdownDescription": "Configures how debug processes are killed when stopping the session. Can be:\n\n- forceful (default): forcefully tears down the process tree. Sends SIGKILL on posix, or `taskkill.exe /F` on Windows.\n- polite: gracefully tears down the process tree. It's possible that misbehaving processes continue to run after shutdown in this way. Sends SIGTERM on posix, or `taskkill.exe` with no `/F` (force) flag on Windows.\n- none: no termination will happen.",
+ "type": "string"
},
"localRoot": {
+ "default": null,
"description": "Path to the local directory containing the program.",
"type": [
"string",
"null"
- ],
- "default": null
+ ]
},
"nodeVersionHint": {
- "description": "Allows you to explicitly specify the Node version that's running, which can be used to disable or enable certain behaviors in cases where the automatic version detection does not work.",
- "type": "number",
"default": 12,
- "minimum": 8
+ "description": "Allows you to explicitly specify the Node version that's running, which can be used to disable or enable certain behaviors in cases where the automatic version detection does not work.",
+ "minimum": 8,
+ "type": "number"
},
"outFiles": {
- "description": "If source maps are enabled, these glob patterns specify the generated JavaScript files. If a pattern starts with `!` the files are excluded. If not specified, the generated code is expected in the same directory as its source.",
- "type": [
- "array"
- ],
"default": [
"${ZED_WORKTREE_ROOT}/**/*.(m|c|)js",
"!**/node_modules/**"
],
+ "description": "If source maps are enabled, these glob patterns specify the generated JavaScript files. If a pattern starts with `!` the files are excluded. If not specified, the generated code is expected in the same directory as its source.",
"items": {
"type": "string"
},
"tags": [
"setup"
+ ],
+ "type": [
+ "array"
]
},
"outputCapture": {
@@ -49,6 +49,16 @@ struct UpdateSchemasDapDelegate {
fs: std::sync::Arc<fs::RealFs>,
}
+#[cfg(feature = "update-schemas")]
+impl UpdateSchemasDapDelegate {
+ fn new(executor: gpui::BackgroundExecutor) -> Self {
+ // FIXME
+ let client = Arc::new(reqwest_client::ReqwestClient::user_agent("Cole").unwrap());
+ let fs = Arc::new(fs::RealFs::new(None, executor.clone()));
+ Self { client, fs }
+ }
+}
+
#[cfg(feature = "update-schemas")]
#[async_trait]
impl dap::adapters::DapDelegate for UpdateSchemasDapDelegate {
@@ -1,8 +1,9 @@
use adapters::latest_github_release;
use anyhow::Context as _;
use dap::{StartDebuggingRequestArguments, adapters::DebugTaskDefinition};
-use fs::{Fs, RealFs};
-use gpui::{AsyncApp, background_executor};
+use fs::Fs;
+use gpui::{AsyncApp, BackgroundExecutor};
+use serde::{Deserialize, Serialize};
use serde_json::Value;
use std::{
borrow::Cow,
@@ -10,7 +11,8 @@ use std::{
path::{Path, PathBuf},
sync::{LazyLock, OnceLock},
};
-use task::DebugRequest;
+use task::{DebugRequest, EnvVariableReplacer, VariableName};
+use tempfile::TempDir;
use util::{ResultExt, maybe};
use crate::*;
@@ -276,18 +278,44 @@ impl DebugAdapter for JsDebugAdapter {
}
}
+#[cfg(feature = "update-schemas")]
impl JsDebugAdapter {
- pub fn fetch_schema(dir: &Path) -> anyhow::Result<(String, String)> {
- let executor = background_executor();
- // FIXME
- let client = Arc::new(reqwest_client::ReqwestClient::user_agent("Cole").unwrap());
- let fs = Arc::new(RealFs::new(None, executor.clone()));
- let delegate = UpdateSchemasDapDelegate {
- client: client.clone(),
- fs: fs.clone(),
- };
+ pub fn get_schema(
+ temp_dir: &TempDir,
+ output_dir: &Path,
+ executor: BackgroundExecutor,
+ ) -> anyhow::Result<()> {
+ #[derive(Serialize, Deserialize)]
+ struct PackageJsonConfigurationAttributes {
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ launch: Option<serde_json::Value>,
+ #[serde(default, skip_serializing_if = "Option::is_none")]
+ attach: Option<serde_json::Value>,
+ }
+
+ #[derive(Serialize, Deserialize)]
+ #[serde(rename_all = "camelCase")]
+ struct PackageJsonDebugger {
+ r#type: String,
+ configuration_attributes: PackageJsonConfigurationAttributes,
+ }
- executor.block(async move {
+ #[derive(Serialize, Deserialize)]
+ struct PackageJsonContributes {
+ debuggers: Vec<PackageJsonDebugger>,
+ }
+
+ #[derive(Serialize, Deserialize)]
+ struct PackageJson {
+ contributes: PackageJsonContributes,
+ }
+
+ let temp_dir = std::fs::canonicalize(temp_dir.path())?;
+ let delegate = UpdateSchemasDapDelegate::new(executor.clone());
+ let fs = delegate.fs.clone();
+ let client = delegate.client.clone();
+
+ let (package_json, package_nls_json) = executor.block(async move {
let release = latest_github_release(
&format!("microsoft/{}", Self::ADAPTER_NPM_NAME),
true,
@@ -296,7 +324,10 @@ impl JsDebugAdapter {
)
.await?;
- let version = release.tag_name.strip_prefix("v").unwrap();
+ let version = release
+ .tag_name
+ .strip_prefix("v")
+ .context("parse version")?;
let asset_name = format!("ms-vscode.js-debug.{version}.vsix",);
let version = AdapterVersion {
tag_name: release.tag_name,
@@ -313,18 +344,132 @@ impl JsDebugAdapter {
DebugAdapterName(Self::ADAPTER_NAME.into()),
version,
adapters::DownloadedFileType::Vsix,
- dir,
+ &temp_dir,
&delegate,
)
.await?;
- let package_json_content = fs
+ let package_json = fs
.load(&path.join("extension").join("package.json"))
.await?;
- let package_nls_json_content = fs
+ let package_nls_json = fs
.load(&path.join("extension").join("package.nls.json"))
.await?;
- Ok((package_json_content, package_nls_json_content))
- })
+ anyhow::Ok((package_json, package_nls_json))
+ })?;
+
+ let package_nls_json =
+ serde_json::from_str::<HashMap<String, serde_json::Value>>(&package_nls_json)?
+ .into_iter()
+ .filter_map(|(k, v)| {
+ let v = v.as_str()?;
+ Some((k, v.to_owned()))
+ })
+ .collect();
+
+ let package_json: serde_json::Value = serde_json::from_str(&package_json)?;
+
+ struct Replacer {
+ package_nls_json: HashMap<String, String>,
+ env: EnvVariableReplacer,
+ }
+
+ impl Replacer {
+ fn replace(&self, input: serde_json::Value) -> serde_json::Value {
+ match input {
+ serde_json::Value::String(s) => {
+ if s.starts_with("%") && s.ends_with("%") {
+ self.package_nls_json
+ .get(s.trim_matches('%'))
+ .map(|s| s.as_str().into())
+ .unwrap_or("(missing)".into())
+ } else {
+ self.env.replace(&s).into()
+ }
+ }
+ serde_json::Value::Array(arr) => {
+ serde_json::Value::Array(arr.into_iter().map(|v| self.replace(v)).collect())
+ }
+ serde_json::Value::Object(obj) => serde_json::Value::Object(
+ obj.into_iter().map(|(k, v)| (k, self.replace(v))).collect(),
+ ),
+ _ => input,
+ }
+ }
+ }
+
+ let env = EnvVariableReplacer::new(HashMap::from_iter([(
+ "workspaceFolder".to_owned(),
+ VariableName::WorktreeRoot.to_string(),
+ )]));
+ let replacer = Replacer {
+ env,
+ package_nls_json,
+ };
+ let package_json = replacer.replace(package_json);
+
+ let package_json: PackageJson = serde_json::from_value(package_json)?;
+
+ let types = package_json
+ .contributes
+ .debuggers
+ .iter()
+ .map(|debugger| debugger.r#type.clone())
+ .collect::<Vec<_>>();
+ let mut conjuncts = package_json
+ .contributes
+ .debuggers
+ .into_iter()
+ .flat_map(|debugger| {
+ let r#type = debugger.r#type;
+ let configuration_attributes = debugger.configuration_attributes;
+ configuration_attributes
+ .launch
+ .map(|schema| ("launch", schema))
+ .into_iter()
+ .chain(
+ configuration_attributes
+ .attach
+ .map(|schema| ("attach", schema)),
+ )
+ .map(|(request, schema)| {
+ json!({
+ "if": {
+ "properties": {
+ "type": {
+ "const": r#type
+ },
+ "request": {
+ "const": request
+ }
+ },
+ "required": ["type", "request"]
+ },
+ "then": schema
+ })
+ })
+ .collect::<Vec<_>>()
+ })
+ .collect::<Vec<_>>();
+ conjuncts.push(json!({
+ "properties": {
+ "type": {
+ "enum": types
+ }
+ },
+ "required": ["type"]
+ }));
+ let schema = json!({
+ "allOf": conjuncts
+ });
+
+ // FIXME figure out what to do about formatting
+ let mut schema = serde_json::to_string_pretty(&schema)?;
+ schema.push('\n');
+ std::fs::write(
+ output_dir.join(Self::ADAPTER_NAME).with_extension("json"),
+ schema,
+ )?;
+ Ok(())
}
}
@@ -1,154 +1,13 @@
-use collections::HashMap;
+use std::path::Path;
+
use dap_adapters::JsDebugAdapter;
-use schemars::{Schema, json_schema};
-use serde::{Deserialize, Serialize};
-use task::{EnvVariableReplacer, VariableName};
+use gpui::background_executor;
use tempfile::TempDir;
-fn main() {
- #[derive(Serialize, Deserialize)]
- struct PackageJsonConfigurationAttributes {
- #[serde(default, skip_serializing_if = "Option::is_none")]
- launch: Option<Schema>,
- #[serde(default, skip_serializing_if = "Option::is_none")]
- attach: Option<Schema>,
- }
-
- #[derive(Serialize, Deserialize)]
- #[serde(rename_all = "camelCase")]
- struct PackageJsonDebugger {
- r#type: String,
- configuration_attributes: PackageJsonConfigurationAttributes,
- }
-
- #[derive(Serialize, Deserialize)]
- struct PackageJsonContributes {
- debuggers: Vec<PackageJsonDebugger>,
- }
-
- #[derive(Serialize, Deserialize)]
- struct PackageJson {
- contributes: PackageJsonContributes,
- }
-
- let dir = TempDir::new().unwrap();
- let path = std::fs::canonicalize(dir.path()).unwrap();
- let (package_json, package_nls_json) =
- dap_adapters::JsDebugAdapter::fetch_schema(&path).unwrap();
- let package_nls_json =
- serde_json::from_str::<HashMap<String, serde_json::Value>>(&package_nls_json)
- .unwrap()
- .into_iter()
- .filter_map(|(k, v)| {
- let v = v.as_str()?;
- Some((k, v.to_owned()))
- })
- .collect::<HashMap<_, _>>();
-
- let package_json: serde_json::Value = serde_json::from_str(&package_json).unwrap();
-
- struct Replacer {
- package_nls_json: HashMap<String, String>,
- env: EnvVariableReplacer,
- }
-
- impl Replacer {
- fn replace(&self, input: serde_json::Value) -> serde_json::Value {
- match input {
- serde_json::Value::String(s) => {
- if s.starts_with("%") && s.ends_with("%") {
- self.package_nls_json
- .get(s.trim_matches('%'))
- .map(|s| s.as_str().into())
- .unwrap_or("(missing)".into())
- } else {
- self.env.replace(&s).into()
- }
- }
- serde_json::Value::Array(arr) => {
- serde_json::Value::Array(arr.into_iter().map(|v| self.replace(v)).collect())
- }
- serde_json::Value::Object(obj) => serde_json::Value::Object(
- obj.into_iter().map(|(k, v)| (k, self.replace(v))).collect(),
- ),
- _ => input,
- }
- }
- }
-
- let env = EnvVariableReplacer::new(HashMap::from_iter([(
- "workspaceFolder".to_owned(),
- VariableName::WorktreeRoot.to_string(),
- )]));
- let replacer = Replacer {
- env,
- package_nls_json,
- };
- let package_json = replacer.replace(package_json);
-
- let package_json: PackageJson = serde_json::from_value(package_json).unwrap();
-
- let types = package_json
- .contributes
- .debuggers
- .iter()
- .map(|debugger| debugger.r#type.clone())
- .collect::<Vec<_>>();
- let mut conjuncts = package_json
- .contributes
- .debuggers
- .into_iter()
- .flat_map(|debugger| {
- let r#type = debugger.r#type;
- let configuration_attributes = debugger.configuration_attributes;
- configuration_attributes
- .launch
- .map(|schema| ("launch", schema))
- .into_iter()
- .chain(
- configuration_attributes
- .attach
- .map(|schema| ("attach", schema)),
- )
- .map(|(request, schema)| {
- json_schema!({
- "if": {
- "properties": {
- "type": {
- "const": r#type
- },
- "request": {
- "const": request
- }
- },
- "required": ["type", "request"]
- },
- "then": schema
- })
- })
- .collect::<Vec<_>>()
- })
- .collect::<Vec<_>>();
- conjuncts.push(json_schema!({
- "properties": {
- "type": {
- "enum": types
- }
- },
- "required": ["type"]
- }));
- let schema = json_schema!({
- "allOf": conjuncts
- });
-
- let mut schema = serde_json::to_string_pretty(&schema.to_value()).unwrap();
- schema.push('\n');
- std::fs::write(
- format!(
- "crates/dap_adapters/schemas/{}.json",
- JsDebugAdapter::ADAPTER_NAME
- ),
- schema,
- )
- .unwrap();
+fn main() -> anyhow::Result<()> {
+ let temp_dir = TempDir::new()?;
+ let output_dir = Path::new("crates/dap_adapters/schemas");
+ let executor = background_executor();
+ JsDebugAdapter::get_schema(&temp_dir, output_dir, executor.clone())?;
+ Ok(())
}