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

Merge pull request #14663 from Microsoft/isidorn/next

Isidorn/next
......@@ -5,26 +5,25 @@
import nls = require('vs/nls');
import errors = require('vs/base/common/errors');
import { TPromise } from 'vs/base/common/winjs.base';
import { IAction } from 'vs/base/common/actions';
import { SelectActionItem } from 'vs/base/browser/ui/actionbar/actionbar';
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 {
constructor(
action: IAction,
@IDebugService private debugService: IDebugService,
@IConfigurationService configurationService: IConfigurationService
@IConfigurationService private configurationService: IConfigurationService
) {
super(null, action, [], -1);
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.updateOptions(false).done(null, errors.onUnexpectedError);
this.updateOptions(false);
}));
this.toDispose.push(this.debugService.onDidChangeState(() => {
this.enabled = this.debugService.state === State.Inactive;
......@@ -33,25 +32,22 @@ export class DebugSelectActionItem extends SelectActionItem {
public render(container: HTMLElement): void {
super.render(container);
this.updateOptions(true).done(null, errors.onUnexpectedError);
this.updateOptions(true);
this.enabled = this.debugService.state === State.Inactive;
}
private updateOptions(changeDebugConfiguration: boolean): TPromise<any> {
const configurationManager = this.debugService.getConfigurationManager();
return configurationManager.loadLaunchConfig().then(config => {
if (!config || !config.configurations || config.configurations.length === 0) {
this.setOptions([nls.localize('noConfigurations', "No Configurations")], 0);
return changeDebugConfiguration ? this.actionRunner.run(this._action, null) : null;
}
private updateOptions(changeDebugConfiguration: boolean): void {
const config = this.configurationService.getConfiguration<IGlobalConfig>('launch');
if (!config || !config.configurations || config.configurations.length === 0) {
this.setOptions([nls.localize('noConfigurations', "No Configurations")], 0);
} else {
const configurationNames = config.configurations.filter(cfg => !!cfg.name).map(cfg => cfg.name);
const selected = configurationNames.indexOf(this.debugService.getViewModel().selectedConfigurationName);
this.setOptions(configurationNames, selected);
}
if (changeDebugConfiguration) {
return this.actionRunner.run(this._action, this.getSelected());
}
});
if (changeDebugConfiguration) {
this.actionRunner.run(this._action, this.getSelected()).done(null, errors.onUnexpectedError);
}
}
}
......@@ -457,7 +457,7 @@ export class ReapplyBreakpointsAction extends AbstractDebugAction {
protected isEnabled(state: debug.State): boolean {
const model = this.debugService.getModel();
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 {
return breakpoints.map((breakpoint) => {
return {
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 {
}
export interface ISession {
// TODO@Isidor consider removing this - feels ugly
requestType: SessionRequestType;
stackTrace(args: DebugProtocol.StackTraceArguments): TPromise<DebugProtocol.StackTraceResponse>;
scopes(args: DebugProtocol.ScopesArguments): TPromise<DebugProtocol.ScopesResponse>;
......@@ -299,13 +298,6 @@ export interface IEnvConfig {
configurationNames?: string[];
}
export interface IExtHostConfig extends IEnvConfig {
port?: number;
sourceMaps?: boolean;
outDir?: string;
outFiles?: string;
}
export interface IConfig extends IEnvConfig {
windows?: IEnvConfig;
osx?: IEnvConfig;
......@@ -351,9 +343,6 @@ export interface IConfigurationManager {
*/
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.
*/
......
......@@ -490,7 +490,7 @@ export class Process implements debug.IProcess {
}
public getId(): string {
return this._session.getId();;
return this._session.getId();
}
public rawUpdate(data: debug.IRawModelUpdate): void {
......
......@@ -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 => {
const telemetryInfo: { [key: string]: string } = Object.create(null);
......@@ -764,15 +764,8 @@ export class DebugService implements debug.IDebugService {
const sessionId = uuid.generateUuid();
this.setStateAndEmit(sessionId, debug.State.Initializing);
return this.configurationManager.getConfiguration(this.viewModel.selectedConfigurationName).then((configuration: debug.IExtHostConfig) =>
this.doCreateProcess(sessionId, {
type: configuration.type,
request: 'attach',
port,
sourceMaps: configuration.sourceMaps,
outFiles: configuration.outDir || configuration.outFiles,
debugServer: configuration.debugServer
})
return this.configurationManager.getConfiguration(this.viewModel.selectedConfigurationName).then(config =>
this.doCreateProcess(sessionId, config)
);
}
......@@ -904,19 +897,8 @@ export class DebugService implements debug.IDebugService {
private transitionToRunningState(session: RawDebugSession, threadId?: number): void {
this.model.clearThreads(session.getId(), false, threadId);
// TODO@Isidor remove this mess
// 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);
this.setStateAndEmit(session.getId(), session.requestType === debug.SessionRequestType.LAUNCH_NO_DEBUG ? debug.State.RunningNoDebug : debug.State.Running);
this.setFocusedStackFrameAndEvaluate(null).done(null, errors.onUnexpectedError);
}
private getDebugStringEditorInput(process: debug.IProcess, source: Source, value: string, mtype: string): DebugStringEditorInput {
......
......@@ -142,6 +142,10 @@ export class Adapter {
enum: [request],
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 = {
type: 'array',
default: [],
......
......@@ -8,7 +8,6 @@ import { TPromise } from 'vs/base/common/winjs.base';
import strings = require('vs/base/common/strings');
import types = require('vs/base/common/types');
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 uri from 'vs/base/common/uri';
import { Schemas } from 'vs/base/common/network';
......@@ -159,7 +158,12 @@ const schema: IJSONSchema = {
'type': 'object',
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);
export class ConfigurationManager implements debug.IConfigurationManager {
private adapters: Adapter[];
private allModeIdsForBreakpoints: { [key: string]: boolean };
private _onDidConfigurationChange: Emitter<debug.IConfig>;
constructor(
@IWorkspaceContextService private contextService: IWorkspaceContextService,
......@@ -181,7 +184,6 @@ export class ConfigurationManager implements debug.IConfigurationManager {
@IConfigurationResolverService private configurationResolverService: IConfigurationResolverService,
@IInstantiationService private instantiationService: IInstantiationService
) {
this._onDidConfigurationChange = new Emitter<debug.IConfig>();
this.adapters = [];
this.registerListeners();
this.allModeIdsForBreakpoints = {};
......@@ -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 {
return this.adapters.filter(adapter => strings.equalsIgnoreCase(adapter.type, type)).pop();
}
public getConfiguration(nameOrConfig: string | debug.IConfig): TPromise<debug.IConfig> {
return this.loadLaunchConfig().then(config => {
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);
const config = this.configurationService.getConfiguration<debug.IGlobalConfig>('launch');
result = filtered.length === 1 ? filtered[0] : config.configurations[0];
result = objects.deepClone(result);
if (config && result) {
result.debugServer = config.debugServer;
}
let result: debug.IConfig = null;
if (types.isObject(nameOrConfig)) {
result = objects.deepClone(nameOrConfig) as debug.IConfig;
} 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) {
// Set operating system specific properties #1873
if (isWindows && result.windows) {
Object.keys(result.windows).forEach(key => {
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];
});
}
result = filtered.length === 1 ? filtered[0] : config.configurations[0];
result = objects.deepClone(result);
if (config && result && config.debugServer) {
result.debugServer = config.debugServer;
}
}
// 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]);
if (result) {
// Set operating system specific properties #1873
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 => {
this._onDidConfigurationChange.fire(result);
return result;
});
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.
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> {
......@@ -348,8 +343,4 @@ export class ConfigurationManager implements debug.IConfigurationManager {
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.
先完成此消息的编辑!
想要评论请 注册