Path: blob/main/src/vs/workbench/contrib/debug/common/debugSchemas.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import * as extensionsRegistry from '../../../services/extensions/common/extensionsRegistry.js';6import * as nls from '../../../../nls.js';7import { IDebuggerContribution, ICompound, IBreakpointContribution } from './debug.js';8import { launchSchemaId } from '../../../services/configuration/common/configuration.js';9import { IJSONSchema } from '../../../../base/common/jsonSchema.js';10import { inputsSchema } from '../../../services/configurationResolver/common/configurationResolverSchema.js';11import { Disposable } from '../../../../base/common/lifecycle.js';12import { Extensions, IExtensionFeatureTableRenderer, IExtensionFeaturesRegistry, IRenderedData, IRowData, ITableData } from '../../../services/extensionManagement/common/extensionFeatures.js';13import { IExtensionManifest } from '../../../../platform/extensions/common/extensions.js';14import { SyncDescriptor } from '../../../../platform/instantiation/common/descriptors.js';15import { Registry } from '../../../../platform/registry/common/platform.js';1617// debuggers extension point18export const debuggersExtPoint = extensionsRegistry.ExtensionsRegistry.registerExtensionPoint<IDebuggerContribution[]>({19extensionPoint: 'debuggers',20defaultExtensionKind: ['workspace'],21jsonSchema: {22description: nls.localize('vscode.extension.contributes.debuggers', 'Contributes debug adapters.'),23type: 'array',24defaultSnippets: [{ body: [{ type: '' }] }],25items: {26additionalProperties: false,27type: 'object',28defaultSnippets: [{ body: { type: '', program: '', runtime: '' } }],29properties: {30type: {31description: nls.localize('vscode.extension.contributes.debuggers.type', "Unique identifier for this debug adapter."),32type: 'string'33},34label: {35description: nls.localize('vscode.extension.contributes.debuggers.label', "Display name for this debug adapter."),36type: 'string'37},38program: {39description: nls.localize('vscode.extension.contributes.debuggers.program', "Path to the debug adapter program. Path is either absolute or relative to the extension folder."),40type: 'string'41},42args: {43description: nls.localize('vscode.extension.contributes.debuggers.args', "Optional arguments to pass to the adapter."),44type: 'array'45},46runtime: {47description: nls.localize('vscode.extension.contributes.debuggers.runtime', "Optional runtime in case the program attribute is not an executable but requires a runtime."),48type: 'string'49},50runtimeArgs: {51description: nls.localize('vscode.extension.contributes.debuggers.runtimeArgs', "Optional runtime arguments."),52type: 'array'53},54variables: {55description: nls.localize('vscode.extension.contributes.debuggers.variables', "Mapping from interactive variables (e.g. ${action.pickProcess}) in `launch.json` to a command."),56type: 'object'57},58initialConfigurations: {59description: nls.localize('vscode.extension.contributes.debuggers.initialConfigurations', "Configurations for generating the initial \'launch.json\'."),60type: ['array', 'string'],61},62languages: {63description: nls.localize('vscode.extension.contributes.debuggers.languages', "List of languages for which the debug extension could be considered the \"default debugger\"."),64type: 'array'65},66configurationSnippets: {67description: nls.localize('vscode.extension.contributes.debuggers.configurationSnippets', "Snippets for adding new configurations in \'launch.json\'."),68type: 'array'69},70configurationAttributes: {71description: nls.localize('vscode.extension.contributes.debuggers.configurationAttributes', "JSON schema configurations for validating \'launch.json\'."),72type: 'object'73},74when: {75description: nls.localize('vscode.extension.contributes.debuggers.when', "Condition which must be true to enable this type of debugger. Consider using 'shellExecutionSupported', 'virtualWorkspace', 'resourceScheme' or an extension-defined context key as appropriate for this."),76type: 'string',77default: ''78},79hiddenWhen: {80description: nls.localize('vscode.extension.contributes.debuggers.hiddenWhen', "When this condition is true, this debugger type is hidden from the debugger list, but is still enabled."),81type: 'string',82default: ''83},84deprecated: {85description: nls.localize('vscode.extension.contributes.debuggers.deprecated', "Optional message to mark this debug type as being deprecated."),86type: 'string',87default: ''88},89windows: {90description: nls.localize('vscode.extension.contributes.debuggers.windows', "Windows specific settings."),91type: 'object',92properties: {93runtime: {94description: nls.localize('vscode.extension.contributes.debuggers.windows.runtime', "Runtime used for Windows."),95type: 'string'96}97}98},99osx: {100description: nls.localize('vscode.extension.contributes.debuggers.osx', "macOS specific settings."),101type: 'object',102properties: {103runtime: {104description: nls.localize('vscode.extension.contributes.debuggers.osx.runtime', "Runtime used for macOS."),105type: 'string'106}107}108},109linux: {110description: nls.localize('vscode.extension.contributes.debuggers.linux', "Linux specific settings."),111type: 'object',112properties: {113runtime: {114description: nls.localize('vscode.extension.contributes.debuggers.linux.runtime', "Runtime used for Linux."),115type: 'string'116}117}118},119strings: {120description: nls.localize('vscode.extension.contributes.debuggers.strings', "UI strings contributed by this debug adapter."),121type: 'object',122properties: {123unverifiedBreakpoints: {124description: nls.localize('vscode.extension.contributes.debuggers.strings.unverifiedBreakpoints', "When there are unverified breakpoints in a language supported by this debug adapter, this message will appear on the breakpoint hover and in the breakpoints view. Markdown and command links are supported."),125type: 'string'126}127}128}129}130}131}132});133134// breakpoints extension point #9037135export const breakpointsExtPoint = extensionsRegistry.ExtensionsRegistry.registerExtensionPoint<IBreakpointContribution[]>({136extensionPoint: 'breakpoints',137jsonSchema: {138description: nls.localize('vscode.extension.contributes.breakpoints', 'Contributes breakpoints.'),139type: 'array',140defaultSnippets: [{ body: [{ language: '' }] }],141items: {142type: 'object',143additionalProperties: false,144defaultSnippets: [{ body: { language: '' } }],145properties: {146language: {147description: nls.localize('vscode.extension.contributes.breakpoints.language', "Allow breakpoints for this language."),148type: 'string'149},150when: {151description: nls.localize('vscode.extension.contributes.breakpoints.when', "Condition which must be true to enable breakpoints in this language. Consider matching this to the debugger when clause as appropriate."),152type: 'string',153default: ''154}155}156}157}158});159160// debug general schema161162export const presentationSchema: IJSONSchema = {163type: 'object',164description: nls.localize('presentation', "Presentation options on how to show this configuration in the debug configuration dropdown and the command palette."),165properties: {166hidden: {167type: 'boolean',168default: false,169description: nls.localize('presentation.hidden', "Controls if this configuration should be shown in the configuration dropdown and the command palette.")170},171group: {172type: 'string',173default: '',174description: nls.localize('presentation.group', "Group that this configuration belongs to. Used for grouping and sorting in the configuration dropdown and the command palette.")175},176order: {177type: 'number',178default: 1,179description: nls.localize('presentation.order', "Order of this configuration within a group. Used for grouping and sorting in the configuration dropdown and the command palette.")180}181},182default: {183hidden: false,184group: '',185order: 1186}187};188const defaultCompound: ICompound = { name: 'Compound', configurations: [] };189export const launchSchema: IJSONSchema = {190id: launchSchemaId,191type: 'object',192title: nls.localize('app.launch.json.title', "Launch"),193allowTrailingCommas: true,194allowComments: true,195required: [],196default: { version: '0.2.0', configurations: [], compounds: [] },197properties: {198version: {199type: 'string',200description: nls.localize('app.launch.json.version', "Version of this file format."),201default: '0.2.0'202},203configurations: {204type: 'array',205description: nls.localize('app.launch.json.configurations', "List of configurations. Add new configurations or edit existing ones by using IntelliSense."),206items: {207defaultSnippets: [],208'type': 'object',209oneOf: []210}211},212compounds: {213type: 'array',214description: nls.localize('app.launch.json.compounds', "List of compounds. Each compound references multiple configurations which will get launched together."),215items: {216type: 'object',217required: ['name', 'configurations'],218properties: {219name: {220type: 'string',221description: nls.localize('app.launch.json.compound.name', "Name of compound. Appears in the launch configuration drop down menu.")222},223presentation: presentationSchema,224configurations: {225type: 'array',226default: [],227items: {228oneOf: [{229enum: [],230description: nls.localize('useUniqueNames', "Please use unique configuration names.")231}, {232type: 'object',233required: ['name'],234properties: {235name: {236enum: [],237description: nls.localize('app.launch.json.compound.name', "Name of compound. Appears in the launch configuration drop down menu.")238},239folder: {240enum: [],241description: nls.localize('app.launch.json.compound.folder', "Name of folder in which the compound is located.")242}243}244}]245},246description: nls.localize('app.launch.json.compounds.configurations', "Names of configurations that will be started as part of this compound.")247},248stopAll: {249type: 'boolean',250default: false,251description: nls.localize('app.launch.json.compound.stopAll', "Controls whether manually terminating one session will stop all of the compound sessions.")252},253preLaunchTask: {254type: 'string',255default: '',256description: nls.localize('compoundPrelaunchTask', "Task to run before any of the compound configurations start.")257}258},259default: defaultCompound260},261default: [262defaultCompound263]264},265inputs: inputsSchema.definitions!.inputs266}267};268269class DebuggersDataRenderer extends Disposable implements IExtensionFeatureTableRenderer {270271readonly type = 'table';272273shouldRender(manifest: IExtensionManifest): boolean {274return !!manifest.contributes?.debuggers;275}276277render(manifest: IExtensionManifest): IRenderedData<ITableData> {278const contrib = manifest.contributes?.debuggers || [];279if (!contrib.length) {280return { data: { headers: [], rows: [] }, dispose: () => { } };281}282283const headers = [284nls.localize('debugger name', "Name"),285nls.localize('debugger type', "Type"),286];287288const rows: IRowData[][] = contrib.map(d => {289return [290d.label ?? '',291d.type292];293});294295return {296data: {297headers,298rows299},300dispose: () => { }301};302}303}304305Registry.as<IExtensionFeaturesRegistry>(Extensions.ExtensionFeaturesRegistry).registerExtensionFeature({306id: 'debuggers',307label: nls.localize('debuggers', "Debuggers"),308access: {309canToggle: false310},311renderer: new SyncDescriptor(DebuggersDataRenderer),312});313314315316