1
>
/*---------------------------------------------------------------------------------------------
debugger.ts
2
>
* Copyright (c) Microsoft Corporation. All rights reserved.
3
>
* Licensed under the MIT License. See License.txt in the project root for license information.
4
>
*--------------------------------------------------------------------------------------------*/
5
>
6
>
import * as nls from '../../../../nls.js';
7
>
import { isObject } from '../../../../base/common/types.js';
8
>
import { IJSONSchema, IJSONSchemaMap, IJSONSchemaSnippet } from '../../../../base/common/jsonSchema.js';
9
>
import { IWorkspaceFolder } from '../../../../platform/workspace/common/workspace.js';
10
>
import { IConfig, IDebuggerContribution, IDebugAdapter, IDebugger, IDebugSession, IAdapterManager, IDebugService, debuggerDisabledMessage, IDebuggerMetadata, DebugConfigurationProviderTriggerKind } from './debug.js';
11
>
import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';
12
>
import { IConfigurationResolverService } from '../../../services/configurationResolver/common/configurationResolver.js';
13
>
import * as ConfigurationResolverUtils from '../../../services/configurationResolver/common/configurationResolverUtils.js';
14
>
import { ITextResourcePropertiesService } from '../../../../editor/common/services/textResourceConfiguration.js';
15
>
import { URI } from '../../../../base/common/uri.js';
16
>
import { Schemas } from '../../../../base/common/network.js';
17
>
import { isDebuggerMainContribution } from './debugUtils.js';
18
>
import { IExtensionDescription } from '../../../../platform/extensions/common/extensions.js';
19
>
import { ITelemetryEndpoint } from '../../../../platform/telemetry/common/telemetry.js';
20
>
import { cleanRemoteAuthority } from '../../../../platform/telemetry/common/telemetryUtils.js';
21
>
import { IWorkbenchEnvironmentService } from '../../../services/environment/common/environmentService.js';
22
>
import { ContextKeyExpr, ContextKeyExpression, IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js';
23
>
import { filter } from '../../../../base/common/objects.js';
24
>
import { IProductService } from '../../../../platform/product/common/productService.js';
25
>
import { ILogService } from '../../../../platform/log/common/log.js';
26
>
27
>
export class Debugger implements IDebugger, IDebuggerMetadata {
28
>
29
>
private debuggerContribution: IDebuggerContribution;
30
>
private mergedExtensionDescriptions: IExtensionDescription[] = [];
31
>
private mainExtensionDescription: IExtensionDescription | undefined;
32
>
33
>
private debuggerWhen: ContextKeyExpression | undefined;
34
>
private debuggerHiddenWhen: ContextKeyExpression | undefined;
35
>
36
>
constructor(
37
>
private adapterManager: IAdapterManager,
38
>
dbgContribution: IDebuggerContribution,
39
>
extensionDescription: IExtensionDescription,
40
>
@IConfigurationService private readonly configurationService: IConfigurationService,
41
>
@ITextResourcePropertiesService private readonly resourcePropertiesService: ITextResourcePropertiesService,
42
>
@IConfigurationResolverService private readonly configurationResolverService: IConfigurationResolverService,
43
>
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
44
>
@IDebugService private readonly debugService: IDebugService,
45
>
@IContextKeyService private readonly contextKeyService: IContextKeyService,
46
>
@IProductService private readonly productService: IProductService,
47
>
@ILogService private readonly logService: ILogService,
48
>
) {
49
>
this.debuggerContribution = { type: dbgContribution.type };
50
>
this.merge(dbgContribution, extensionDescription);
51
>
52
>
this.debuggerWhen = typeof this.debuggerContribution.when === 'string' ? ContextKeyExpr.deserialize(this.debuggerContribution.when) : undefined;
53
>
this.debuggerHiddenWhen = typeof this.debuggerContribution.hiddenWhen === 'string' ? ContextKeyExpr.deserialize(this.debuggerContribution.hiddenWhen) : undefined;
54
>
}
55
>
56
>
merge(otherDebuggerContribution: IDebuggerContribution, extensionDescription: IExtensionDescription): void {
57
>
58
>
/**
59
>
* Copies all properties of source into destination. The optional parameter "overwrite" allows to control
60
>
* if existing non-structured properties on the destination should be overwritten or not. Defaults to true (overwrite).
61
>
*/
62
>
function mixin(destination: any, source: any, overwrite: boolean, level = 0): any {
63
>
64
>
if (!isObject(destination)) {
65
return source;
66
}
68
>
if (isObject(source)) {
69
>
Object.keys(source).forEach(key => {
70
>
if (key !== '__proto__') {
71
>
if (isObject(destination[key]) && isObject(source[key])) {
72
mixin(destination[key], source[key], overwrite, level + 1);
74
>
if (key in destination) {
75
>
if (overwrite) {
76
if (level === 0 && key === 'type') {
77
// don't merge the 'type' property