Skip to content

Commit 969cf18

Browse files
Merge pull request #1 from microsoft/main
Updating Fork
2 parents dbb9eb4 + e8c4f47 commit 969cf18

File tree

4 files changed

+121
-93
lines changed

4 files changed

+121
-93
lines changed

src/vs/workbench/contrib/debug/browser/debugAdapterManager.ts

+41-4
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ import * as nls from 'vs/nls';
77
import { IDisposable } from 'vs/base/common/lifecycle';
88
import { Event, Emitter } from 'vs/base/common/event';
99
import * as strings from 'vs/base/common/strings';
10-
import { IJSONSchema } from 'vs/base/common/jsonSchema';
10+
import { IJSONSchema, IJSONSchemaMap } from 'vs/base/common/jsonSchema';
1111
import { ITextModel } from 'vs/editor/common/model';
1212
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
1313
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
1414
import { IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
1515
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
1616
import { ICommandService } from 'vs/platform/commands/common/commands';
17-
import { IDebugConfiguration, IConfig, IDebugAdapterDescriptorFactory, IDebugAdapter, IDebugSession, IAdapterDescriptor, IDebugAdapterFactory, CONTEXT_DEBUGGERS_AVAILABLE, IAdapterManager } from 'vs/workbench/contrib/debug/common/debug';
17+
import { IDebugConfiguration, IConfig, IDebugAdapterDescriptorFactory, IDebugAdapter, IDebugSession, IAdapterDescriptor, IDebugAdapterFactory, CONTEXT_DEBUGGERS_AVAILABLE, IAdapterManager, INTERNAL_CONSOLE_OPTIONS_SCHEMA } from 'vs/workbench/contrib/debug/common/debug';
1818
import { Debugger } from 'vs/workbench/contrib/debug/common/debugger';
1919
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
2020
import { isCodeEditor } from 'vs/editor/browser/editorBrowser';
21-
import { launchSchema, debuggersExtPoint, breakpointsExtPoint } from 'vs/workbench/contrib/debug/common/debugSchemas';
21+
import { launchSchema, debuggersExtPoint, breakpointsExtPoint, presentationSchema } from 'vs/workbench/contrib/debug/common/debugSchemas';
2222
import { IQuickInputService } from 'vs/platform/quickinput/common/quickInput';
2323
import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
2424
import { launchSchemaId } from 'vs/workbench/services/configuration/common/configuration';
@@ -27,6 +27,7 @@ import { IJSONContributionRegistry, Extensions as JSONExtensions } from 'vs/plat
2727
import { IModeService } from 'vs/editor/common/services/modeService';
2828
import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
2929
import Severity from 'vs/base/common/severity';
30+
import { TaskDefinitionRegistry } from 'vs/workbench/contrib/tasks/common/taskDefinitionRegistry';
3031

3132
const jsonRegistry = Registry.as<IJSONContributionRegistry>(JSONExtensions.JSONContribution);
3233
export class AdapterManager implements IAdapterManager {
@@ -91,10 +92,46 @@ export class AdapterManager implements IAdapterManager {
9192

9293
// update the schema to include all attributes, snippets and types from extensions.
9394
const items = (<IJSONSchema>launchSchema.properties!['configurations'].items);
95+
const taskSchema = TaskDefinitionRegistry.getJsonSchema();
96+
const definitions: IJSONSchemaMap = {
97+
'common': {
98+
properties: {
99+
'name': {
100+
type: 'string',
101+
description: nls.localize('debugName', "Name of configuration; appears in the launch configuration dropdown menu."),
102+
default: 'Launch'
103+
},
104+
'debugServer': {
105+
type: 'number',
106+
description: nls.localize('debugServer', "For debug extension development only: if a port is specified VS Code tries to connect to a debug adapter running in server mode"),
107+
default: 4711
108+
},
109+
'preLaunchTask': {
110+
anyOf: [taskSchema, {
111+
type: ['string']
112+
}],
113+
default: '',
114+
defaultSnippets: [{ body: { task: '', type: '' } }],
115+
description: nls.localize('debugPrelaunchTask', "Task to run before debug session starts.")
116+
},
117+
'postDebugTask': {
118+
anyOf: [taskSchema, {
119+
type: ['string'],
120+
}],
121+
default: '',
122+
defaultSnippets: [{ body: { task: '', type: '' } }],
123+
description: nls.localize('debugPostDebugTask', "Task to run after debug session ends.")
124+
},
125+
'presentation': presentationSchema,
126+
'internalConsoleOptions': INTERNAL_CONSOLE_OPTIONS_SCHEMA,
127+
}
128+
}
129+
};
130+
launchSchema.definitions = definitions;
94131
items.oneOf = [];
95132
items.defaultSnippets = [];
96133
this.debuggers.forEach(adapter => {
97-
const schemaAttributes = adapter.getSchemaAttributes();
134+
const schemaAttributes = adapter.getSchemaAttributes(definitions);
98135
if (schemaAttributes && items.oneOf) {
99136
items.oneOf.push(...schemaAttributes);
100137
}

src/vs/workbench/contrib/debug/common/debugger.ts

+34-57
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,18 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
import * as nls from 'vs/nls';
7-
import * as objects from 'vs/base/common/objects';
87
import { isObject } from 'vs/base/common/types';
9-
import { IJSONSchema, IJSONSchemaSnippet } from 'vs/base/common/jsonSchema';
8+
import { IJSONSchema, IJSONSchemaMap, IJSONSchemaSnippet } from 'vs/base/common/jsonSchema';
109
import { IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
11-
import { IConfig, IDebuggerContribution, INTERNAL_CONSOLE_OPTIONS_SCHEMA, IDebugAdapter, IDebugger, IDebugSession, IAdapterManager, IDebugService } from 'vs/workbench/contrib/debug/common/debug';
10+
import { IConfig, IDebuggerContribution, IDebugAdapter, IDebugger, IDebugSession, IAdapterManager, IDebugService } from 'vs/workbench/contrib/debug/common/debug';
1211
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
1312
import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver';
1413
import * as ConfigurationResolverUtils from 'vs/workbench/services/configurationResolver/common/configurationResolverUtils';
15-
import { TaskDefinitionRegistry } from 'vs/workbench/contrib/tasks/common/taskDefinitionRegistry';
1614
import { ITextResourcePropertiesService } from 'vs/editor/common/services/textResourceConfigurationService';
1715
import { URI } from 'vs/base/common/uri';
1816
import { Schemas } from 'vs/base/common/network';
1917
import { isDebuggerMainContribution } from 'vs/workbench/contrib/debug/common/debugUtils';
2018
import { IExtensionDescription } from 'vs/platform/extensions/common/extensions';
21-
import { presentationSchema } from 'vs/workbench/contrib/debug/common/debugSchemas';
2219
import { ITelemetryEndpoint } from 'vs/platform/telemetry/common/telemetry';
2320
import { cleanRemoteAuthority } from 'vs/platform/telemetry/common/telemetryUtils';
2421
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
@@ -194,15 +191,15 @@ export class Debugger implements IDebugger {
194191
};
195192
}
196193

197-
getSchemaAttributes(): IJSONSchema[] | null {
194+
getSchemaAttributes(definitions: IJSONSchemaMap): IJSONSchema[] | null {
198195

199196
if (!this.debuggerContribution.configurationAttributes) {
200197
return null;
201198
}
202199

203200
// fill in the default configuration attributes shared by all adapters.
204-
const taskSchema = TaskDefinitionRegistry.getJsonSchema();
205201
return Object.keys(this.debuggerContribution.configurationAttributes).map(request => {
202+
const definitionId = `${this.type}:${request}`;
206203
const attributes: IJSONSchema = this.debuggerContribution.configurationAttributes[request];
207204
const defaultRequired = ['name', 'type', 'request'];
208205
attributes.required = attributes.required && attributes.required.length ? defaultRequired.concat(attributes.required) : defaultRequired;
@@ -219,64 +216,44 @@ export class Debugger implements IDebugger {
219216
errorMessage: nls.localize('debugTypeNotRecognised', "The debug type is not recognized. Make sure that you have a corresponding debug extension installed and that it is enabled."),
220217
patternErrorMessage: nls.localize('node2NotSupported', "\"node2\" is no longer supported, use \"node\" instead and set the \"protocol\" attribute to \"inspector\".")
221218
};
222-
properties['name'] = {
223-
type: 'string',
224-
description: nls.localize('debugName', "Name of configuration; appears in the launch configuration dropdown menu."),
225-
default: 'Launch'
226-
};
227219
properties['request'] = {
228220
enum: [request],
229221
description: nls.localize('debugRequest', "Request type of configuration. Can be \"launch\" or \"attach\"."),
230222
};
231-
properties['debugServer'] = {
232-
type: 'number',
233-
description: nls.localize('debugServer', "For debug extension development only: if a port is specified VS Code tries to connect to a debug adapter running in server mode"),
234-
default: 4711
235-
};
236-
properties['preLaunchTask'] = {
237-
anyOf: [taskSchema, {
238-
type: ['string']
239-
}],
240-
default: '',
241-
defaultSnippets: [{ body: { task: '', type: '' } }],
242-
description: nls.localize('debugPrelaunchTask', "Task to run before debug session starts.")
243-
};
244-
properties['postDebugTask'] = {
245-
anyOf: [taskSchema, {
246-
type: ['string'],
247-
}],
248-
default: '',
249-
defaultSnippets: [{ body: { task: '', type: '' } }],
250-
description: nls.localize('debugPostDebugTask', "Task to run after debug session ends.")
251-
};
252-
properties['presentation'] = presentationSchema;
253-
properties['internalConsoleOptions'] = INTERNAL_CONSOLE_OPTIONS_SCHEMA;
254-
// Clear out windows, linux and osx fields to not have cycles inside the properties object
255-
delete properties['windows'];
256-
delete properties['osx'];
257-
delete properties['linux'];
258-
259-
const osProperties = objects.deepClone(properties);
260-
properties['windows'] = {
261-
type: 'object',
262-
description: nls.localize('debugWindowsConfiguration', "Windows specific launch configuration attributes."),
263-
properties: osProperties
264-
};
265-
properties['osx'] = {
266-
type: 'object',
267-
description: nls.localize('debugOSXConfiguration', "OS X specific launch configuration attributes."),
268-
properties: osProperties
269-
};
270-
properties['linux'] = {
271-
type: 'object',
272-
description: nls.localize('debugLinuxConfiguration', "Linux specific launch configuration attributes."),
273-
properties: osProperties
274-
};
223+
for (const prop in definitions['common'].properties) {
224+
properties[prop] = {
225+
$ref: `#/definitions/common/properties/${prop}`
226+
};
227+
}
228+
definitions[definitionId] = attributes;
229+
275230
Object.keys(properties).forEach(name => {
276231
// Use schema allOf property to get independent error reporting #21113
277232
ConfigurationResolverUtils.applyDeprecatedVariableMessage(properties[name]);
278233
});
279-
return attributes;
234+
235+
const result = {
236+
allOf: [{
237+
$ref: `#/definitions/${definitionId}`
238+
}, {
239+
properties: {
240+
windows: {
241+
$ref: `#/definitions/${definitionId}`,
242+
description: nls.localize('debugWindowsConfiguration', "Windows specific launch configuration attributes.")
243+
},
244+
osx: {
245+
$ref: `#/definitions/${definitionId}`,
246+
description: nls.localize('debugOSXConfiguration', "OS X specific launch configuration attributes.")
247+
},
248+
linux: {
249+
$ref: `#/definitions/${definitionId}`,
250+
description: nls.localize('debugLinuxConfiguration', "Linux specific launch configuration attributes.")
251+
}
252+
}
253+
}]
254+
};
255+
256+
return result;
280257
});
281258
}
282259
}

src/vs/workbench/contrib/debug/test/node/debugger.test.ts

-14
Original file line numberDiff line numberDiff line change
@@ -149,20 +149,6 @@ suite('Debug - Debugger', () => {
149149
assert.deepStrictEqual(ae!.args, debuggerContribution.args);
150150
});
151151

152-
test('schema attributes', () => {
153-
const schemaAttribute = _debugger.getSchemaAttributes()![0];
154-
assert.notDeepStrictEqual(schemaAttribute, debuggerContribution.configurationAttributes);
155-
Object.keys(debuggerContribution.configurationAttributes.launch).forEach(key => {
156-
assert.deepStrictEqual((<any>schemaAttribute)[key], (<any>debuggerContribution.configurationAttributes.launch)[key]);
157-
});
158-
159-
assert.strictEqual(schemaAttribute['additionalProperties'], false);
160-
assert.strictEqual(!!schemaAttribute['properties']!['request'], true);
161-
assert.strictEqual(!!schemaAttribute['properties']!['name'], true);
162-
assert.strictEqual(!!schemaAttribute['properties']!['type'], true);
163-
assert.strictEqual(!!schemaAttribute['properties']!['preLaunchTask'], true);
164-
});
165-
166152
test('merge platform specific attributes', () => {
167153
const ae = ExecutableDebugAdapter.platformAdapterExecutable([extensionDescriptor1, extensionDescriptor2], 'mock')!;
168154
assert.strictEqual(ae.command, platform.isLinux ? 'linuxRuntime' : (platform.isMacintosh ? 'osxRuntime' : 'winRuntime'));

0 commit comments

Comments
 (0)