提交 2634a491 编写于 作者: I Isidor Nikolic 提交者: GitHub

Merge pull request #14663 from Microsoft/isidorn/next

Isidorn/next
...@@ -5,26 +5,25 @@ ...@@ -5,26 +5,25 @@
import nls = require('vs/nls'); import nls = require('vs/nls');
import errors = require('vs/base/common/errors'); import errors = require('vs/base/common/errors');
import { TPromise } from 'vs/base/common/winjs.base';
import { IAction } from 'vs/base/common/actions'; import { IAction } from 'vs/base/common/actions';
import { SelectActionItem } from 'vs/base/browser/ui/actionbar/actionbar'; import { SelectActionItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IDebugService, State } from 'vs/workbench/parts/debug/common/debug'; import { IDebugService, State, IGlobalConfig } from 'vs/workbench/parts/debug/common/debug';
export class DebugSelectActionItem extends SelectActionItem { export class DebugSelectActionItem extends SelectActionItem {
constructor( constructor(
action: IAction, action: IAction,
@IDebugService private debugService: IDebugService, @IDebugService private debugService: IDebugService,
@IConfigurationService configurationService: IConfigurationService @IConfigurationService private configurationService: IConfigurationService
) { ) {
super(null, action, [], -1); super(null, action, [], -1);
this.toDispose.push(configurationService.onDidUpdateConfiguration(e => { this.toDispose.push(configurationService.onDidUpdateConfiguration(e => {
this.updateOptions(true).done(null, errors.onUnexpectedError); this.updateOptions(true);
})); }));
this.toDispose.push(this.debugService.getViewModel().onDidSelectConfigurationName(name => { this.toDispose.push(this.debugService.getViewModel().onDidSelectConfigurationName(name => {
this.updateOptions(false).done(null, errors.onUnexpectedError); this.updateOptions(false);
})); }));
this.toDispose.push(this.debugService.onDidChangeState(() => { this.toDispose.push(this.debugService.onDidChangeState(() => {
this.enabled = this.debugService.state === State.Inactive; this.enabled = this.debugService.state === State.Inactive;
...@@ -33,25 +32,22 @@ export class DebugSelectActionItem extends SelectActionItem { ...@@ -33,25 +32,22 @@ export class DebugSelectActionItem extends SelectActionItem {
public render(container: HTMLElement): void { public render(container: HTMLElement): void {
super.render(container); super.render(container);
this.updateOptions(true).done(null, errors.onUnexpectedError); this.updateOptions(true);
this.enabled = this.debugService.state === State.Inactive; this.enabled = this.debugService.state === State.Inactive;
} }
private updateOptions(changeDebugConfiguration: boolean): TPromise<any> { private updateOptions(changeDebugConfiguration: boolean): void {
const configurationManager = this.debugService.getConfigurationManager(); const config = this.configurationService.getConfiguration<IGlobalConfig>('launch');
return configurationManager.loadLaunchConfig().then(config => { if (!config || !config.configurations || config.configurations.length === 0) {
if (!config || !config.configurations || config.configurations.length === 0) { this.setOptions([nls.localize('noConfigurations', "No Configurations")], 0);
this.setOptions([nls.localize('noConfigurations', "No Configurations")], 0); } else {
return changeDebugConfiguration ? this.actionRunner.run(this._action, null) : null;
}
const configurationNames = config.configurations.filter(cfg => !!cfg.name).map(cfg => cfg.name); const configurationNames = config.configurations.filter(cfg => !!cfg.name).map(cfg => cfg.name);
const selected = configurationNames.indexOf(this.debugService.getViewModel().selectedConfigurationName); const selected = configurationNames.indexOf(this.debugService.getViewModel().selectedConfigurationName);
this.setOptions(configurationNames, selected); this.setOptions(configurationNames, selected);
}
if (changeDebugConfiguration) { if (changeDebugConfiguration) {
return this.actionRunner.run(this._action, this.getSelected()); this.actionRunner.run(this._action, this.getSelected()).done(null, errors.onUnexpectedError);
} }
});
} }
} }
...@@ -457,7 +457,7 @@ export class ReapplyBreakpointsAction extends AbstractDebugAction { ...@@ -457,7 +457,7 @@ export class ReapplyBreakpointsAction extends AbstractDebugAction {
protected isEnabled(state: debug.State): boolean { protected isEnabled(state: debug.State): boolean {
const model = this.debugService.getModel(); const model = this.debugService.getModel();
return super.isEnabled(state) && state !== debug.State.Disabled && state !== debug.State.Inactive && return super.isEnabled(state) && state !== debug.State.Disabled && state !== debug.State.Inactive &&
(model.getFunctionBreakpoints().length + model.getBreakpoints().length > 0); (model.getFunctionBreakpoints().length + model.getBreakpoints().length + model.getExceptionBreakpoints().length > 0);
} }
} }
......
...@@ -264,7 +264,7 @@ export class DebugEditorModelManager implements IWorkbenchContribution { ...@@ -264,7 +264,7 @@ export class DebugEditorModelManager implements IWorkbenchContribution {
return breakpoints.map((breakpoint) => { return breakpoints.map((breakpoint) => {
return { return {
options: this.getBreakpointDecorationOptions(breakpoint), options: this.getBreakpointDecorationOptions(breakpoint),
range: createRange(breakpoint.lineNumber, 1, breakpoint.lineNumber, 2) range: createRange(breakpoint.lineNumber, 1, breakpoint.lineNumber, Number.MAX_VALUE)
}; };
}); });
} }
......
...@@ -72,7 +72,6 @@ export enum SessionRequestType { ...@@ -72,7 +72,6 @@ export enum SessionRequestType {
} }
export interface ISession { export interface ISession {
// TODO@Isidor consider removing this - feels ugly
requestType: SessionRequestType; requestType: SessionRequestType;
stackTrace(args: DebugProtocol.StackTraceArguments): TPromise<DebugProtocol.StackTraceResponse>; stackTrace(args: DebugProtocol.StackTraceArguments): TPromise<DebugProtocol.StackTraceResponse>;
scopes(args: DebugProtocol.ScopesArguments): TPromise<DebugProtocol.ScopesResponse>; scopes(args: DebugProtocol.ScopesArguments): TPromise<DebugProtocol.ScopesResponse>;
...@@ -299,13 +298,6 @@ export interface IEnvConfig { ...@@ -299,13 +298,6 @@ export interface IEnvConfig {
configurationNames?: string[]; configurationNames?: string[];
} }
export interface IExtHostConfig extends IEnvConfig {
port?: number;
sourceMaps?: boolean;
outDir?: string;
outFiles?: string;
}
export interface IConfig extends IEnvConfig { export interface IConfig extends IEnvConfig {
windows?: IEnvConfig; windows?: IEnvConfig;
osx?: IEnvConfig; osx?: IEnvConfig;
...@@ -351,9 +343,6 @@ export interface IConfigurationManager { ...@@ -351,9 +343,6 @@ export interface IConfigurationManager {
*/ */
openConfigFile(sideBySide: boolean): TPromise<boolean>; openConfigFile(sideBySide: boolean): TPromise<boolean>;
// TODO@Isidor remove this from the interface
loadLaunchConfig(): TPromise<IGlobalConfig>;
/** /**
* Returns true if breakpoints can be set for a given editor model. Depends on mode. * Returns true if breakpoints can be set for a given editor model. Depends on mode.
*/ */
......
...@@ -490,7 +490,7 @@ export class Process implements debug.IProcess { ...@@ -490,7 +490,7 @@ export class Process implements debug.IProcess {
} }
public getId(): string { public getId(): string {
return this._session.getId();; return this._session.getId();
} }
public rawUpdate(data: debug.IRawModelUpdate): void { public rawUpdate(data: debug.IRawModelUpdate): void {
......
...@@ -601,7 +601,7 @@ export class DebugService implements debug.IDebugService { ...@@ -601,7 +601,7 @@ export class DebugService implements debug.IDebugService {
})))); }))));
} }
private doCreateProcess(sessionId: string, configuration: debug.IExtHostConfig): TPromise<any> { private doCreateProcess(sessionId: string, configuration: debug.IConfig): TPromise<any> {
return this.telemetryService.getTelemetryInfo().then(info => { return this.telemetryService.getTelemetryInfo().then(info => {
const telemetryInfo: { [key: string]: string } = Object.create(null); const telemetryInfo: { [key: string]: string } = Object.create(null);
...@@ -764,15 +764,8 @@ export class DebugService implements debug.IDebugService { ...@@ -764,15 +764,8 @@ export class DebugService implements debug.IDebugService {
const sessionId = uuid.generateUuid(); const sessionId = uuid.generateUuid();
this.setStateAndEmit(sessionId, debug.State.Initializing); this.setStateAndEmit(sessionId, debug.State.Initializing);
return this.configurationManager.getConfiguration(this.viewModel.selectedConfigurationName).then((configuration: debug.IExtHostConfig) => return this.configurationManager.getConfiguration(this.viewModel.selectedConfigurationName).then(config =>
this.doCreateProcess(sessionId, { this.doCreateProcess(sessionId, config)
type: configuration.type,
request: 'attach',
port,
sourceMaps: configuration.sourceMaps,
outFiles: configuration.outDir || configuration.outFiles,
debugServer: configuration.debugServer
})
); );
} }
...@@ -904,19 +897,8 @@ export class DebugService implements debug.IDebugService { ...@@ -904,19 +897,8 @@ export class DebugService implements debug.IDebugService {
private transitionToRunningState(session: RawDebugSession, threadId?: number): void { private transitionToRunningState(session: RawDebugSession, threadId?: number): void {
this.model.clearThreads(session.getId(), false, threadId); this.model.clearThreads(session.getId(), false, threadId);
this.setStateAndEmit(session.getId(), session.requestType === debug.SessionRequestType.LAUNCH_NO_DEBUG ? debug.State.RunningNoDebug : debug.State.Running);
// TODO@Isidor remove this mess this.setFocusedStackFrameAndEvaluate(null).done(null, errors.onUnexpectedError);
// Get a top stack frame of a stopped thread if there is any.
const process = this.model.getProcesses().filter(p => p.getId() === session.getId()).pop();
const stoppedThread = process && process.getAllThreads().filter(t => t.stopped).pop();
const callStack = stoppedThread ? stoppedThread.getCachedCallStack() : null;
const stackFrameToFocus = callStack && callStack.length > 0 ? callStack[0] : null;
if (!stoppedThread && process) {
this.setStateAndEmit(session.getId(), process.session.requestType === debug.SessionRequestType.LAUNCH_NO_DEBUG ? debug.State.RunningNoDebug : debug.State.Running);
}
this.setFocusedStackFrameAndEvaluate(stackFrameToFocus).done(null, errors.onUnexpectedError);
} }
private getDebugStringEditorInput(process: debug.IProcess, source: Source, value: string, mtype: string): DebugStringEditorInput { private getDebugStringEditorInput(process: debug.IProcess, source: Source, value: string, mtype: string): DebugStringEditorInput {
......
...@@ -142,6 +142,10 @@ export class Adapter { ...@@ -142,6 +142,10 @@ export class Adapter {
enum: [request], enum: [request],
description: nls.localize('debugRequest', "Request type of configuration. Can be \"launch\" or \"attach\"."), description: nls.localize('debugRequest', "Request type of configuration. Can be \"launch\" or \"attach\"."),
}; };
properties.debugServer = {
type: 'number',
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")
};
properties.configurationNames = { properties.configurationNames = {
type: 'array', type: 'array',
default: [], default: [],
......
...@@ -8,7 +8,6 @@ import { TPromise } from 'vs/base/common/winjs.base'; ...@@ -8,7 +8,6 @@ import { TPromise } from 'vs/base/common/winjs.base';
import strings = require('vs/base/common/strings'); import strings = require('vs/base/common/strings');
import types = require('vs/base/common/types'); import types = require('vs/base/common/types');
import { isLinux, isMacintosh, isWindows } from 'vs/base/common/platform'; import { isLinux, isMacintosh, isWindows } from 'vs/base/common/platform';
import Event, { Emitter } from 'vs/base/common/event';
import objects = require('vs/base/common/objects'); import objects = require('vs/base/common/objects');
import uri from 'vs/base/common/uri'; import uri from 'vs/base/common/uri';
import { Schemas } from 'vs/base/common/network'; import { Schemas } from 'vs/base/common/network';
...@@ -159,7 +158,12 @@ const schema: IJSONSchema = { ...@@ -159,7 +158,12 @@ const schema: IJSONSchema = {
'type': 'object', 'type': 'object',
oneOf: [] oneOf: []
} }
} },
// TODO@Isidor remove support for this in December
debugServer: {
type: 'number',
description: nls.localize('app.launch.json.debugServer', "DEPRECATED: please move debugServer inside a configuration.")
},
} }
}; };
...@@ -169,7 +173,6 @@ jsonRegistry.registerSchema(schemaId, schema); ...@@ -169,7 +173,6 @@ jsonRegistry.registerSchema(schemaId, schema);
export class ConfigurationManager implements debug.IConfigurationManager { export class ConfigurationManager implements debug.IConfigurationManager {
private adapters: Adapter[]; private adapters: Adapter[];
private allModeIdsForBreakpoints: { [key: string]: boolean }; private allModeIdsForBreakpoints: { [key: string]: boolean };
private _onDidConfigurationChange: Emitter<debug.IConfig>;
constructor( constructor(
@IWorkspaceContextService private contextService: IWorkspaceContextService, @IWorkspaceContextService private contextService: IWorkspaceContextService,
...@@ -181,7 +184,6 @@ export class ConfigurationManager implements debug.IConfigurationManager { ...@@ -181,7 +184,6 @@ export class ConfigurationManager implements debug.IConfigurationManager {
@IConfigurationResolverService private configurationResolverService: IConfigurationResolverService, @IConfigurationResolverService private configurationResolverService: IConfigurationResolverService,
@IInstantiationService private instantiationService: IInstantiationService @IInstantiationService private instantiationService: IInstantiationService
) { ) {
this._onDidConfigurationChange = new Emitter<debug.IConfig>();
this.adapters = []; this.adapters = [];
this.registerListeners(); this.registerListeners();
this.allModeIdsForBreakpoints = {}; this.allModeIdsForBreakpoints = {};
...@@ -243,63 +245,56 @@ export class ConfigurationManager implements debug.IConfigurationManager { ...@@ -243,63 +245,56 @@ export class ConfigurationManager implements debug.IConfigurationManager {
}); });
} }
public get onDidConfigurationChange(): Event<debug.IConfig> {
return this._onDidConfigurationChange.event;
}
public getAdapter(type: string): Adapter { public getAdapter(type: string): Adapter {
return this.adapters.filter(adapter => strings.equalsIgnoreCase(adapter.type, type)).pop(); return this.adapters.filter(adapter => strings.equalsIgnoreCase(adapter.type, type)).pop();
} }
public getConfiguration(nameOrConfig: string | debug.IConfig): TPromise<debug.IConfig> { public getConfiguration(nameOrConfig: string | debug.IConfig): TPromise<debug.IConfig> {
return this.loadLaunchConfig().then(config => { const config = this.configurationService.getConfiguration<debug.IGlobalConfig>('launch');
let result: debug.IConfig = null;
if (types.isObject(nameOrConfig)) {
result = objects.deepClone(nameOrConfig) as debug.IConfig;
} else {
if (!config || !config.configurations) {
return result;
}
// if the configuration name is not set yet, take the first launch config (can happen if debug viewlet has not been opened yet).
const filtered = config.configurations.filter(cfg => cfg.name === nameOrConfig);
result = filtered.length === 1 ? filtered[0] : config.configurations[0]; let result: debug.IConfig = null;
result = objects.deepClone(result); if (types.isObject(nameOrConfig)) {
if (config && result) { result = objects.deepClone(nameOrConfig) as debug.IConfig;
result.debugServer = config.debugServer; } else {
} if (!config || !config.configurations) {
return TPromise.as(null);
} }
// if the configuration name is not set yet, take the first launch config (can happen if debug viewlet has not been opened yet).
const filtered = config.configurations.filter(cfg => cfg.name === nameOrConfig);
if (result) { result = filtered.length === 1 ? filtered[0] : config.configurations[0];
// Set operating system specific properties #1873 result = objects.deepClone(result);
if (isWindows && result.windows) { if (config && result && config.debugServer) {
Object.keys(result.windows).forEach(key => { result.debugServer = config.debugServer;
result[key] = result.windows[key]; }
}); }
}
if (isMacintosh && result.osx) {
Object.keys(result.osx).forEach(key => {
result[key] = result.osx[key];
});
}
if (isLinux && result.linux) {
Object.keys(result.linux).forEach(key => {
result[key] = result.linux[key];
});
}
// massage configuration attributes - append workspace path to relatvie paths, substitute variables in paths. if (result) {
Object.keys(result).forEach(key => { // Set operating system specific properties #1873
result[key] = this.configurationResolverService.resolveAny(result[key]); if (isWindows && result.windows) {
Object.keys(result.windows).forEach(key => {
result[key] = result.windows[key];
}); });
const adapter = this.getAdapter(result.type);
return this.configurationResolverService.resolveInteractiveVariables(result, adapter ? adapter.variables : null);
} }
}).then(result => { if (isMacintosh && result.osx) {
this._onDidConfigurationChange.fire(result); Object.keys(result.osx).forEach(key => {
return result; result[key] = result.osx[key];
}); });
}
if (isLinux && result.linux) {
Object.keys(result.linux).forEach(key => {
result[key] = result.linux[key];
});
}
// massage configuration attributes - append workspace path to relatvie paths, substitute variables in paths.
Object.keys(result).forEach(key => {
result[key] = this.configurationResolverService.resolveAny(result[key]);
});
const adapter = this.getAdapter(result.type);
return this.configurationResolverService.resolveInteractiveVariables(result, adapter ? adapter.variables : null);
}
} }
public openConfigFile(sideBySide: boolean): TPromise<boolean> { public openConfigFile(sideBySide: boolean): TPromise<boolean> {
...@@ -348,8 +343,4 @@ export class ConfigurationManager implements debug.IConfigurationManager { ...@@ -348,8 +343,4 @@ export class ConfigurationManager implements debug.IConfigurationManager {
return !!this.allModeIdsForBreakpoints[modeId]; return !!this.allModeIdsForBreakpoints[modeId];
} }
public loadLaunchConfig(): TPromise<debug.IGlobalConfig> {
return TPromise.as(this.configurationService.getConfiguration<debug.IGlobalConfig>('launch'));
}
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册