未验证 提交 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 {
hasEnabledDebuggers(): boolean {
for (let [type] of this.debugAdapterFactories) {
const dbg = this.getDebugger(type);
if (dbg && this.isDebuggerEnabled(dbg)) {
if (dbg && dbg.enabled) {
return true;
}
}
......@@ -270,24 +270,20 @@ export class AdapterManager extends Disposable implements IAdapterManager {
return this.breakpointModeIdsSet.has(languageId);
}
isDebuggerEnabled(dbg: Debugger): boolean {
return !dbg.when || this.contextKeyService.contextMatchesRules(dbg.when);
}
getDebugger(type: string): Debugger | undefined {
return this.debuggers.find(dbg => strings.equalsIgnoreCase(dbg.type, type));
}
isDebuggerInterestedInLanguage(language: string): boolean {
return !!this.debuggers
.filter(d => this.isDebuggerEnabled(d))
.filter(d => d.enabled)
.find(a => language && a.languages && a.languages.indexOf(language) >= 0);
}
async guessDebugger(gettingConfigurations: boolean, type?: string): Promise<Debugger | undefined> {
if (type) {
const adapter = this.getDebugger(type);
return adapter && this.isDebuggerEnabled(adapter) ? adapter : undefined;
return adapter && adapter.enabled ? adapter : undefined;
}
const activeTextEditorControl = this.editorService.activeTextEditorControl;
......@@ -301,7 +297,7 @@ export class AdapterManager extends Disposable implements IAdapterManager {
languageLabel = this.modeService.getLanguageName(language);
}
const adapters = this.debuggers
.filter(a => this.isDebuggerEnabled(a))
.filter(a => a.enabled)
.filter(a => language && a.languages && a.languages.indexOf(language) >= 0);
if (adapters.length === 1) {
return adapters[0];
......@@ -316,7 +312,7 @@ export class AdapterManager extends Disposable implements IAdapterManager {
if ((!languageLabel || gettingConfigurations || (model && this.canSetBreakpointsIn(model))) && candidates.length === 0) {
await this.activateDebuggers('onDebugInitialConfigurations');
candidates = this.debuggers
.filter(a => this.isDebuggerEnabled(a))
.filter(a => a.enabled)
.filter(dbg => dbg.hasInitialConfiguration() || dbg.hasConfigurationProvider());
}
......
......@@ -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 { DebugSession } from 'vs/workbench/contrib/debug/browser/debugSession';
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 { Debugger } from 'vs/workbench/contrib/debug/common/debugger';
import { Breakpoint, DataBreakpoint, DebugModel, FunctionBreakpoint, InstructionBreakpoint } from 'vs/workbench/contrib/debug/common/debugModel';
......@@ -492,9 +492,8 @@ export class DebugService implements IDebugService {
return false;
}
if (!this.adapterManager.isDebuggerEnabled(dbg)) {
const message = nls.localize('debuggerDisabled', "Configured debug type '{0}' is installed but not supported in this environment.", dbg.type);
await this.showError(message, []);
if (!dbg.enabled) {
await this.showError(debuggerDisabledMessage(dbg.type), []);
return false;
}
......
......@@ -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_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 BREAKPOINT_EDITOR_CONTRIBUTION_ID = 'editor.contrib.breakpoint';
export const DEBUG_SCHEME = 'debug';
......
......@@ -7,7 +7,7 @@ import * as nls from 'vs/nls';
import { isObject } from 'vs/base/common/types';
import { IJSONSchema, IJSONSchemaMap, IJSONSchemaSnippet } from 'vs/base/common/jsonSchema';
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 { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver';
import * as ConfigurationResolverUtils from 'vs/workbench/services/configurationResolver/common/configurationResolverUtils';
......@@ -19,7 +19,7 @@ import { IExtensionDescription } from 'vs/platform/extensions/common/extensions'
import { ITelemetryEndpoint } from 'vs/platform/telemetry/common/telemetry';
import { cleanRemoteAuthority } from 'vs/platform/telemetry/common/telemetryUtils';
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 {
......@@ -37,7 +37,8 @@ export class Debugger implements IDebugger {
@ITextResourcePropertiesService private readonly resourcePropertiesService: ITextResourcePropertiesService,
@IConfigurationResolverService private readonly configurationResolverService: IConfigurationResolverService,
@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.merge(dbgContribution, extensionDescription);
......@@ -142,6 +143,10 @@ export class Debugger implements IDebugger {
return this.debuggerWhen;
}
get enabled() {
return !this.debuggerWhen || this.contextKeyService.contextMatchesRules(this.debuggerWhen);
}
hasInitialConfiguration(): boolean {
return !!this.debuggerContribution.initialConfigurations;
}
......@@ -221,6 +226,7 @@ export class Debugger implements IDebugger {
enum: [this.type],
description: nls.localize('debugType', "Type of configuration."),
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."),
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', () => {
const testResourcePropertiesService = new TestTextResourcePropertiesService(configurationService);
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(() => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册