未验证 提交 3ae5ecd8 编写于 作者: C Connor Peet

debug: show warning in launch.json for disabled debuggers

Fixes #134173
上级 31ca4cd3
...@@ -181,7 +181,7 @@ export class AdapterManager extends Disposable implements IAdapterManager { ...@@ -181,7 +181,7 @@ export class AdapterManager extends Disposable implements IAdapterManager {
hasEnabledDebuggers(): boolean { hasEnabledDebuggers(): boolean {
for (let [type] of this.debugAdapterFactories) { for (let [type] of this.debugAdapterFactories) {
const dbg = this.getDebugger(type); const dbg = this.getDebugger(type);
if (dbg && this.isDebuggerEnabled(dbg)) { if (dbg && dbg.enabled) {
return true; return true;
} }
} }
...@@ -270,24 +270,20 @@ export class AdapterManager extends Disposable implements IAdapterManager { ...@@ -270,24 +270,20 @@ export class AdapterManager extends Disposable implements IAdapterManager {
return this.breakpointModeIdsSet.has(languageId); return this.breakpointModeIdsSet.has(languageId);
} }
isDebuggerEnabled(dbg: Debugger): boolean {
return !dbg.when || this.contextKeyService.contextMatchesRules(dbg.when);
}
getDebugger(type: string): Debugger | undefined { getDebugger(type: string): Debugger | undefined {
return this.debuggers.find(dbg => strings.equalsIgnoreCase(dbg.type, type)); return this.debuggers.find(dbg => strings.equalsIgnoreCase(dbg.type, type));
} }
isDebuggerInterestedInLanguage(language: string): boolean { isDebuggerInterestedInLanguage(language: string): boolean {
return !!this.debuggers return !!this.debuggers
.filter(d => this.isDebuggerEnabled(d)) .filter(d => d.enabled)
.find(a => language && a.languages && a.languages.indexOf(language) >= 0); .find(a => language && a.languages && a.languages.indexOf(language) >= 0);
} }
async guessDebugger(gettingConfigurations: boolean, type?: string): Promise<Debugger | undefined> { async guessDebugger(gettingConfigurations: boolean, type?: string): Promise<Debugger | undefined> {
if (type) { if (type) {
const adapter = this.getDebugger(type); const adapter = this.getDebugger(type);
return adapter && this.isDebuggerEnabled(adapter) ? adapter : undefined; return adapter && adapter.enabled ? adapter : undefined;
} }
const activeTextEditorControl = this.editorService.activeTextEditorControl; const activeTextEditorControl = this.editorService.activeTextEditorControl;
...@@ -301,7 +297,7 @@ export class AdapterManager extends Disposable implements IAdapterManager { ...@@ -301,7 +297,7 @@ export class AdapterManager extends Disposable implements IAdapterManager {
languageLabel = this.modeService.getLanguageName(language); languageLabel = this.modeService.getLanguageName(language);
} }
const adapters = this.debuggers const adapters = this.debuggers
.filter(a => this.isDebuggerEnabled(a)) .filter(a => a.enabled)
.filter(a => language && a.languages && a.languages.indexOf(language) >= 0); .filter(a => language && a.languages && a.languages.indexOf(language) >= 0);
if (adapters.length === 1) { if (adapters.length === 1) {
return adapters[0]; return adapters[0];
...@@ -316,7 +312,7 @@ export class AdapterManager extends Disposable implements IAdapterManager { ...@@ -316,7 +312,7 @@ export class AdapterManager extends Disposable implements IAdapterManager {
if ((!languageLabel || gettingConfigurations || (model && this.canSetBreakpointsIn(model))) && candidates.length === 0) { if ((!languageLabel || gettingConfigurations || (model && this.canSetBreakpointsIn(model))) && candidates.length === 0) {
await this.activateDebuggers('onDebugInitialConfigurations'); await this.activateDebuggers('onDebugInitialConfigurations');
candidates = this.debuggers candidates = this.debuggers
.filter(a => this.isDebuggerEnabled(a)) .filter(a => a.enabled)
.filter(dbg => dbg.hasInitialConfiguration() || dbg.hasConfigurationProvider()); .filter(dbg => dbg.hasInitialConfiguration() || dbg.hasConfigurationProvider());
} }
......
...@@ -36,7 +36,7 @@ import { DEBUG_CONFIGURE_COMMAND_ID, DEBUG_CONFIGURE_LABEL } from 'vs/workbench/ ...@@ -36,7 +36,7 @@ import { DEBUG_CONFIGURE_COMMAND_ID, DEBUG_CONFIGURE_LABEL } from 'vs/workbench/
import { ConfigurationManager } from 'vs/workbench/contrib/debug/browser/debugConfigurationManager'; import { ConfigurationManager } from 'vs/workbench/contrib/debug/browser/debugConfigurationManager';
import { DebugSession } from 'vs/workbench/contrib/debug/browser/debugSession'; import { DebugSession } from 'vs/workbench/contrib/debug/browser/debugSession';
import { DebugTaskRunner, TaskRunResult } from 'vs/workbench/contrib/debug/browser/debugTaskRunner'; import { DebugTaskRunner, TaskRunResult } from 'vs/workbench/contrib/debug/browser/debugTaskRunner';
import { CALLSTACK_VIEW_ID, CONTEXT_BREAKPOINTS_EXIST, CONTEXT_DEBUG_STATE, CONTEXT_DEBUG_TYPE, CONTEXT_DEBUG_UX, CONTEXT_DISASSEMBLY_VIEW_FOCUS, CONTEXT_IN_DEBUG_MODE, getStateLabel, IAdapterManager, IBreakpoint, IBreakpointData, ICompound, IConfig, IConfigurationManager, IDebugConfiguration, IDebugModel, IDebugService, IDebugSession, IDebugSessionOptions, IEnablement, IExceptionBreakpoint, IGlobalConfig, ILaunch, IStackFrame, IThread, IViewModel, REPL_VIEW_ID, State, VIEWLET_ID } from 'vs/workbench/contrib/debug/common/debug'; import { CALLSTACK_VIEW_ID, CONTEXT_BREAKPOINTS_EXIST, CONTEXT_DEBUG_STATE, CONTEXT_DEBUG_TYPE, CONTEXT_DEBUG_UX, CONTEXT_DISASSEMBLY_VIEW_FOCUS, CONTEXT_IN_DEBUG_MODE, debuggerDisabledMessage, getStateLabel, IAdapterManager, IBreakpoint, IBreakpointData, ICompound, IConfig, IConfigurationManager, IDebugConfiguration, IDebugModel, IDebugService, IDebugSession, IDebugSessionOptions, IEnablement, IExceptionBreakpoint, IGlobalConfig, ILaunch, IStackFrame, IThread, IViewModel, REPL_VIEW_ID, State, VIEWLET_ID } from 'vs/workbench/contrib/debug/common/debug';
import { DebugCompoundRoot } from 'vs/workbench/contrib/debug/common/debugCompoundRoot'; import { DebugCompoundRoot } from 'vs/workbench/contrib/debug/common/debugCompoundRoot';
import { Debugger } from 'vs/workbench/contrib/debug/common/debugger'; import { Debugger } from 'vs/workbench/contrib/debug/common/debugger';
import { Breakpoint, DataBreakpoint, DebugModel, FunctionBreakpoint, InstructionBreakpoint } from 'vs/workbench/contrib/debug/common/debugModel'; import { Breakpoint, DataBreakpoint, DebugModel, FunctionBreakpoint, InstructionBreakpoint } from 'vs/workbench/contrib/debug/common/debugModel';
...@@ -492,9 +492,8 @@ export class DebugService implements IDebugService { ...@@ -492,9 +492,8 @@ export class DebugService implements IDebugService {
return false; return false;
} }
if (!this.adapterManager.isDebuggerEnabled(dbg)) { if (!dbg.enabled) {
const message = nls.localize('debuggerDisabled', "Configured debug type '{0}' is installed but not supported in this environment.", dbg.type); await this.showError(debuggerDisabledMessage(dbg.type), []);
await this.showError(message, []);
return false; return false;
} }
......
...@@ -88,6 +88,8 @@ export const CONTEXT_DISASSEMBLY_VIEW_FOCUS = new RawContextKey<boolean>('disass ...@@ -88,6 +88,8 @@ export const CONTEXT_DISASSEMBLY_VIEW_FOCUS = new RawContextKey<boolean>('disass
export const CONTEXT_LANGUAGE_SUPPORTS_DISASSEMBLE_REQUEST = new RawContextKey<boolean>('languageSupportsDisassembleRequest', false, { type: 'boolean', description: nls.localize('languageSupportsDisassembleRequest', "True when the language in the current editor supports disassemble request.") }); export const CONTEXT_LANGUAGE_SUPPORTS_DISASSEMBLE_REQUEST = new RawContextKey<boolean>('languageSupportsDisassembleRequest', false, { type: 'boolean', description: nls.localize('languageSupportsDisassembleRequest', "True when the language in the current editor supports disassemble request.") });
export const CONTEXT_FOCUSED_STACK_FRAME_HAS_INSTRUCTION_POINTER_REFERENCE = new RawContextKey<boolean>('focusedStackFrameHasInstructionReference', false, { type: 'boolean', description: nls.localize('focusedStackFrameHasInstructionReference', "True when the focused stack frame has instruction pointer reference.") }); export const CONTEXT_FOCUSED_STACK_FRAME_HAS_INSTRUCTION_POINTER_REFERENCE = new RawContextKey<boolean>('focusedStackFrameHasInstructionReference', false, { type: 'boolean', description: nls.localize('focusedStackFrameHasInstructionReference', "True when the focused stack frame has instruction pointer reference.") });
export const debuggerDisabledMessage = (debugType: string) => nls.localize('debuggerDisabled', "Configured debug type '{0}' is installed but not supported in this environment.", debugType);
export const EDITOR_CONTRIBUTION_ID = 'editor.contrib.debug'; export const EDITOR_CONTRIBUTION_ID = 'editor.contrib.debug';
export const BREAKPOINT_EDITOR_CONTRIBUTION_ID = 'editor.contrib.breakpoint'; export const BREAKPOINT_EDITOR_CONTRIBUTION_ID = 'editor.contrib.breakpoint';
export const DEBUG_SCHEME = 'debug'; export const DEBUG_SCHEME = 'debug';
......
...@@ -7,7 +7,7 @@ import * as nls from 'vs/nls'; ...@@ -7,7 +7,7 @@ import * as nls from 'vs/nls';
import { isObject } from 'vs/base/common/types'; import { isObject } from 'vs/base/common/types';
import { IJSONSchema, IJSONSchemaMap, IJSONSchemaSnippet } from 'vs/base/common/jsonSchema'; import { IJSONSchema, IJSONSchemaMap, IJSONSchemaSnippet } from 'vs/base/common/jsonSchema';
import { IWorkspaceFolder } from 'vs/platform/workspace/common/workspace'; import { IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
import { IConfig, IDebuggerContribution, IDebugAdapter, IDebugger, IDebugSession, IAdapterManager, IDebugService } from 'vs/workbench/contrib/debug/common/debug'; import { IConfig, IDebuggerContribution, IDebugAdapter, IDebugger, IDebugSession, IAdapterManager, IDebugService, debuggerDisabledMessage } from 'vs/workbench/contrib/debug/common/debug';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver'; import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver';
import * as ConfigurationResolverUtils from 'vs/workbench/services/configurationResolver/common/configurationResolverUtils'; import * as ConfigurationResolverUtils from 'vs/workbench/services/configurationResolver/common/configurationResolverUtils';
...@@ -19,7 +19,7 @@ import { IExtensionDescription } from 'vs/platform/extensions/common/extensions' ...@@ -19,7 +19,7 @@ import { IExtensionDescription } from 'vs/platform/extensions/common/extensions'
import { ITelemetryEndpoint } from 'vs/platform/telemetry/common/telemetry'; import { ITelemetryEndpoint } from 'vs/platform/telemetry/common/telemetry';
import { cleanRemoteAuthority } from 'vs/platform/telemetry/common/telemetryUtils'; import { cleanRemoteAuthority } from 'vs/platform/telemetry/common/telemetryUtils';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService'; import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { ContextKeyExpr, ContextKeyExpression } from 'vs/platform/contextkey/common/contextkey'; import { ContextKeyExpr, ContextKeyExpression, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
export class Debugger implements IDebugger { export class Debugger implements IDebugger {
...@@ -37,7 +37,8 @@ export class Debugger implements IDebugger { ...@@ -37,7 +37,8 @@ export class Debugger implements IDebugger {
@ITextResourcePropertiesService private readonly resourcePropertiesService: ITextResourcePropertiesService, @ITextResourcePropertiesService private readonly resourcePropertiesService: ITextResourcePropertiesService,
@IConfigurationResolverService private readonly configurationResolverService: IConfigurationResolverService, @IConfigurationResolverService private readonly configurationResolverService: IConfigurationResolverService,
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService, @IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
@IDebugService private readonly debugService: IDebugService @IDebugService private readonly debugService: IDebugService,
@IContextKeyService private readonly contextKeyService: IContextKeyService,
) { ) {
this.debuggerContribution = { type: dbgContribution.type }; this.debuggerContribution = { type: dbgContribution.type };
this.merge(dbgContribution, extensionDescription); this.merge(dbgContribution, extensionDescription);
...@@ -142,6 +143,10 @@ export class Debugger implements IDebugger { ...@@ -142,6 +143,10 @@ export class Debugger implements IDebugger {
return this.debuggerWhen; return this.debuggerWhen;
} }
get enabled() {
return !this.debuggerWhen || this.contextKeyService.contextMatchesRules(this.debuggerWhen);
}
hasInitialConfiguration(): boolean { hasInitialConfiguration(): boolean {
return !!this.debuggerContribution.initialConfigurations; return !!this.debuggerContribution.initialConfigurations;
} }
...@@ -221,6 +226,7 @@ export class Debugger implements IDebugger { ...@@ -221,6 +226,7 @@ export class Debugger implements IDebugger {
enum: [this.type], enum: [this.type],
description: nls.localize('debugType', "Type of configuration."), description: nls.localize('debugType', "Type of configuration."),
pattern: '^(?!node2)', pattern: '^(?!node2)',
deprecationMessage: this.enabled ? undefined : debuggerDisabledMessage(this.type),
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."), 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."),
patternErrorMessage: nls.localize('node2NotSupported', "\"node2\" is no longer supported, use \"node\" instead and set the \"protocol\" attribute to \"inspector\".") patternErrorMessage: nls.localize('node2NotSupported', "\"node2\" is no longer supported, use \"node\" instead and set the \"protocol\" attribute to \"inspector\".")
}; };
......
...@@ -132,7 +132,7 @@ suite('Debug - Debugger', () => { ...@@ -132,7 +132,7 @@ suite('Debug - Debugger', () => {
const testResourcePropertiesService = new TestTextResourcePropertiesService(configurationService); const testResourcePropertiesService = new TestTextResourcePropertiesService(configurationService);
setup(() => { setup(() => {
_debugger = new Debugger(adapterManager, debuggerContribution, extensionDescriptor0, configurationService, testResourcePropertiesService, undefined!, undefined!, undefined!); _debugger = new Debugger(adapterManager, debuggerContribution, extensionDescriptor0, configurationService, testResourcePropertiesService, undefined!, undefined!, undefined!, undefined!);
}); });
teardown(() => { teardown(() => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册