提交 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 {
......
......@@ -3,28 +3,28 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import nls = require('vs/nls');
import * as nls from 'vs/nls';
import { TPromise } from 'vs/base/common/winjs.base';
import lifecycle = require('vs/base/common/lifecycle');
import * as lifecycle from 'vs/base/common/lifecycle';
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import paths = require('vs/base/common/paths');
import async = require('vs/base/common/async');
import errors = require('vs/base/common/errors');
import strings = require('vs/base/common/strings');
import * as paths from 'vs/base/common/paths';
import * as async from 'vs/base/common/async';
import * as errors from 'vs/base/common/errors';
import { equalsIgnoreCase } from 'vs/base/common/strings';
import { isMacintosh } from 'vs/base/common/platform';
import dom = require('vs/base/browser/dom');
import * as dom from 'vs/base/browser/dom';
import { IMouseEvent } from 'vs/base/browser/mouseEvent';
import labels = require('vs/base/common/labels');
import actions = require('vs/base/common/actions');
import actionbar = require('vs/base/browser/ui/actionbar/actionbar');
import tree = require('vs/base/parts/tree/browser/tree');
import { getPathLabel } from 'vs/base/common/labels';
import { IAction, IActionRunner } from 'vs/base/common/actions';
import { IActionItem, Separator, ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
import { ITree, IAccessibilityProvider, ContextMenuEvent, IDataSource, IRenderer } from 'vs/base/parts/tree/browser/tree';
import { InputBox, IInputValidationOptions } from 'vs/base/browser/ui/inputbox/inputBox';
import treedefaults = require('vs/base/parts/tree/browser/treeDefaults');
import renderer = require('vs/base/parts/tree/browser/actionsRenderer');
import debug = require('vs/workbench/parts/debug/common/debug');
import model = require('vs/workbench/parts/debug/common/debugModel');
import viewmodel = require('vs/workbench/parts/debug/common/debugViewModel');
import debugactions = require('vs/workbench/parts/debug/browser/debugActions');
import { DefaultController } from 'vs/base/parts/tree/browser/treeDefaults';
import { IActionProvider } from 'vs/base/parts/tree/browser/actionsRenderer';
import * as debug from 'vs/workbench/parts/debug/common/debug';
import { Expression, Variable, FunctionBreakpoint, StackFrame, Thread, Process, Breakpoint, ExceptionBreakpoint, Model, Scope } from 'vs/workbench/parts/debug/common/debugModel';
import { ViewModel } from 'vs/workbench/parts/debug/common/debugViewModel';
import { ContinueAction, StepOverAction, PauseAction, AddFunctionBreakpointAction, ReapplyBreakpointsAction, DisableAllBreakpointsAction, RemoveBreakpointAction, ToggleEnablementAction, RenameFunctionBreakpointAction, RemoveWatchExpressionAction, AddWatchExpressionAction, EditWatchExpressionAction, RemoveAllBreakpointsAction, EnableAllBreakpointsAction, StepOutAction, StepIntoAction, SetValueAction, RemoveAllWatchExpressionsAction, ToggleBreakpointsActivatedAction, RestartFrameAction, AddToWatchExpressionsAction } from 'vs/workbench/parts/debug/browser/debugActions';
import { CopyValueAction } from 'vs/workbench/parts/debug/electron-browser/electronDebugActions';
import { IContextViewService, IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
......@@ -43,9 +43,9 @@ export function renderExpressionValue(expressionOrValue: debug.IExpression | str
// remove stale classes
container.className = 'value';
// when resolving expressions we represent errors from the server as a variable with name === null.
if (value === null || ((expressionOrValue instanceof model.Expression || expressionOrValue instanceof model.Variable) && !expressionOrValue.available)) {
if (value === null || ((expressionOrValue instanceof Expression || expressionOrValue instanceof Variable) && !expressionOrValue.available)) {
dom.addClass(container, 'unavailable');
if (value !== model.Expression.DEFAULT_VALUE) {
if (value !== Expression.DEFAULT_VALUE) {
dom.addClass(container, 'error');
}
} else if (!isNaN(+value)) {
......@@ -68,7 +68,7 @@ export function renderExpressionValue(expressionOrValue: debug.IExpression | str
container.title = value;
}
export function renderVariable(tree: tree.ITree, variable: model.Variable, data: IVariableTemplateData, showChanged: boolean): void {
export function renderVariable(tree: ITree, variable: Variable, data: IVariableTemplateData, showChanged: boolean): void {
if (variable.available) {
data.name.textContent = variable.name;
data.name.title = variable.type ? variable.type : '';
......@@ -91,7 +91,7 @@ interface IRenameBoxOptions {
validationOptions?: IInputValidationOptions;
}
function renderRenameBox(debugService: debug.IDebugService, contextViewService: IContextViewService, tree: tree.ITree, element: any, container: HTMLElement, options: IRenameBoxOptions): void {
function renderRenameBox(debugService: debug.IDebugService, contextViewService: IContextViewService, tree: ITree, element: any, container: HTMLElement, options: IRenameBoxOptions): void {
let inputBoxContainer = dom.append(container, $('.inputBoxContainer'));
let inputBox = new InputBox(inputBoxContainer, contextViewService, {
validationOptions: options.validationOptions,
......@@ -109,15 +109,15 @@ function renderRenameBox(debugService: debug.IDebugService, contextViewService:
const wrapUp = async.once((renamed: boolean) => {
if (!disposed) {
disposed = true;
if (element instanceof model.Expression && renamed && inputBox.value) {
if (element instanceof Expression && renamed && inputBox.value) {
debugService.renameWatchExpression(element.getId(), inputBox.value).done(null, errors.onUnexpectedError);
} else if (element instanceof model.Expression && !element.name) {
} else if (element instanceof Expression && !element.name) {
debugService.removeWatchExpressions(element.getId());
} else if (element instanceof model.FunctionBreakpoint && renamed && inputBox.value) {
} else if (element instanceof FunctionBreakpoint && renamed && inputBox.value) {
debugService.renameFunctionBreakpoint(element.getId(), inputBox.value).done(null, errors.onUnexpectedError);
} else if (element instanceof model.FunctionBreakpoint && !element.name) {
} else if (element instanceof FunctionBreakpoint && !element.name) {
debugService.removeFunctionBreakpoints(element.getId()).done(null, errors.onUnexpectedError);
} else if (element instanceof model.Variable) {
} else if (element instanceof Variable) {
element.errorMessage = null;
if (renamed && element.value !== inputBox.value) {
element.setVariable(inputBox.value)
......@@ -153,15 +153,15 @@ function getSourceName(source: Source, contextService: IWorkspaceContextService)
return source.name;
}
return labels.getPathLabel(paths.basename(source.uri.fsPath), contextService);
return getPathLabel(paths.basename(source.uri.fsPath), contextService);
}
export class BaseDebugController extends treedefaults.DefaultController {
export class BaseDebugController extends DefaultController {
constructor(
protected debugService: debug.IDebugService,
private contextMenuService: IContextMenuService,
private actionProvider: renderer.IActionProvider,
private actionProvider: IActionProvider,
private focusOnContextMenu = true
) {
super();
......@@ -174,7 +174,7 @@ export class BaseDebugController extends treedefaults.DefaultController {
}
}
public onContextMenu(tree: tree.ITree, element: debug.IEnablement, event: tree.ContextMenuEvent): boolean {
public onContextMenu(tree: ITree, element: debug.IEnablement, event: ContextMenuEvent): boolean {
if (event.target && event.target.tagName && event.target.tagName.toLowerCase() === 'input') {
return false;
}
......@@ -205,7 +205,7 @@ export class BaseDebugController extends treedefaults.DefaultController {
return false;
}
protected onDelete(tree: tree.ITree, event: IKeyboardEvent): boolean {
protected onDelete(tree: ITree, event: IKeyboardEvent): boolean {
return false;
}
}
......@@ -222,51 +222,51 @@ class ThreadAndProcessIds implements debug.ITreeElement {
export class CallStackController extends BaseDebugController {
protected onLeftClick(tree: tree.ITree, element: any, event: IMouseEvent): boolean {
protected onLeftClick(tree: ITree, element: any, event: IMouseEvent): boolean {
if (element instanceof ThreadAndProcessIds) {
return this.showMoreStackFrames(tree, element);
}
if (element instanceof model.StackFrame) {
if (element instanceof StackFrame) {
this.focusStackFrame(element, event, true);
}
return super.onLeftClick(tree, element, event);
}
protected onEnter(tree: tree.ITree, event: IKeyboardEvent): boolean {
protected onEnter(tree: ITree, event: IKeyboardEvent): boolean {
const element = tree.getFocus();
if (element instanceof ThreadAndProcessIds) {
return this.showMoreStackFrames(tree, element);
}
if (element instanceof model.StackFrame) {
if (element instanceof StackFrame) {
this.focusStackFrame(element, event, false);
}
return super.onEnter(tree, event);
}
protected onUp(tree: tree.ITree, event: IKeyboardEvent): boolean {
protected onUp(tree: ITree, event: IKeyboardEvent): boolean {
super.onUp(tree, event);
this.focusStackFrame(tree.getFocus(), event, true);
return true;
}
protected onPageUp(tree: tree.ITree, event: IKeyboardEvent): boolean {
protected onPageUp(tree: ITree, event: IKeyboardEvent): boolean {
super.onPageUp(tree, event);
this.focusStackFrame(tree.getFocus(), event, true);
return true;
}
protected onDown(tree: tree.ITree, event: IKeyboardEvent): boolean {
protected onDown(tree: ITree, event: IKeyboardEvent): boolean {
super.onDown(tree, event);
this.focusStackFrame(tree.getFocus(), event, true);
return true;
}
protected onPageDown(tree: tree.ITree, event: IKeyboardEvent): boolean {
protected onPageDown(tree: ITree, event: IKeyboardEvent): boolean {
super.onPageDown(tree, event);
this.focusStackFrame(tree.getFocus(), event, true);
......@@ -274,7 +274,7 @@ export class CallStackController extends BaseDebugController {
}
// user clicked / pressed on 'Load More Stack Frames', get those stack frames and refresh the tree.
private showMoreStackFrames(tree: tree.ITree, threadAndProcessIds: ThreadAndProcessIds): boolean {
private showMoreStackFrames(tree: ITree, threadAndProcessIds: ThreadAndProcessIds): boolean {
const process = this.debugService.getModel().getProcesses().filter(p => p.getId() === threadAndProcessIds.processId).pop();
const thread = process && process.getThread(threadAndProcessIds.threadId);
if (thread) {
......@@ -296,54 +296,54 @@ export class CallStackController extends BaseDebugController {
}
export class CallStackActionProvider implements renderer.IActionProvider {
export class CallStackActionProvider implements IActionProvider {
constructor( @IInstantiationService private instantiationService: IInstantiationService, @debug.IDebugService private debugService: debug.IDebugService) {
// noop
}
public hasActions(tree: tree.ITree, element: any): boolean {
public hasActions(tree: ITree, element: any): boolean {
return false;
}
public getActions(tree: tree.ITree, element: any): TPromise<actions.IAction[]> {
public getActions(tree: ITree, element: any): TPromise<IAction[]> {
return TPromise.as([]);
}
public hasSecondaryActions(tree: tree.ITree, element: any): boolean {
return element instanceof model.Thread || element instanceof model.StackFrame;
public hasSecondaryActions(tree: ITree, element: any): boolean {
return element instanceof Thread || element instanceof StackFrame;
}
public getSecondaryActions(tree: tree.ITree, element: any): TPromise<actions.IAction[]> {
const actions: actions.Action[] = [];
if (element instanceof model.Thread) {
const thread = <model.Thread>element;
public getSecondaryActions(tree: ITree, element: any): TPromise<IAction[]> {
const actions: IAction[] = [];
if (element instanceof Thread) {
const thread = <Thread>element;
if (thread.stopped) {
actions.push(this.instantiationService.createInstance(debugactions.ContinueAction, debugactions.ContinueAction.ID, debugactions.ContinueAction.LABEL));
actions.push(this.instantiationService.createInstance(debugactions.StepOverAction, debugactions.StepOverAction.ID, debugactions.StepOverAction.LABEL));
actions.push(this.instantiationService.createInstance(debugactions.StepIntoAction, debugactions.StepIntoAction.ID, debugactions.StepIntoAction.LABEL));
actions.push(this.instantiationService.createInstance(debugactions.StepOutAction, debugactions.StepOutAction.ID, debugactions.StepOutAction.LABEL));
actions.push(this.instantiationService.createInstance(ContinueAction, ContinueAction.ID, ContinueAction.LABEL));
actions.push(this.instantiationService.createInstance(StepOverAction, StepOverAction.ID, StepOverAction.LABEL));
actions.push(this.instantiationService.createInstance(StepIntoAction, StepIntoAction.ID, StepIntoAction.LABEL));
actions.push(this.instantiationService.createInstance(StepOutAction, StepOutAction.ID, StepOutAction.LABEL));
} else {
actions.push(this.instantiationService.createInstance(debugactions.PauseAction, debugactions.PauseAction.ID, debugactions.PauseAction.LABEL));
actions.push(this.instantiationService.createInstance(PauseAction, PauseAction.ID, PauseAction.LABEL));
}
} else if (element instanceof model.StackFrame) {
} else if (element instanceof StackFrame) {
const capabilities = this.debugService.getViewModel().focusedProcess.session.configuration.capabilities;
if (typeof capabilities.supportsRestartFrame === 'boolean' && capabilities.supportsRestartFrame) {
actions.push(this.instantiationService.createInstance(debugactions.RestartFrameAction, debugactions.RestartFrameAction.ID, debugactions.RestartFrameAction.LABEL));
actions.push(this.instantiationService.createInstance(RestartFrameAction, RestartFrameAction.ID, RestartFrameAction.LABEL));
}
}
return TPromise.as(actions);
}
public getActionItem(tree: tree.ITree, element: any, action: actions.IAction): actionbar.IActionItem {
public getActionItem(tree: ITree, element: any, action: IAction): IActionItem {
return null;
}
}
export class CallStackDataSource implements tree.IDataSource {
export class CallStackDataSource implements IDataSource {
public getId(tree: tree.ITree, element: any): string {
public getId(tree: ITree, element: any): string {
if (typeof element === 'string') {
return element;
}
......@@ -351,15 +351,15 @@ export class CallStackDataSource implements tree.IDataSource {
return element.getId();
}
public hasChildren(tree: tree.ITree, element: any): boolean {
return element instanceof model.Model || element instanceof model.Process || (element instanceof model.Thread && (<model.Thread>element).stopped);
public hasChildren(tree: ITree, element: any): boolean {
return element instanceof Model || element instanceof Process || (element instanceof Thread && (<Thread>element).stopped);
}
public getChildren(tree: tree.ITree, element: any): TPromise<any> {
if (element instanceof model.Thread) {
public getChildren(tree: ITree, element: any): TPromise<any> {
if (element instanceof Thread) {
return this.getThreadChildren(element);
}
if (element instanceof model.Model) {
if (element instanceof Model) {
return TPromise.as(element.getProcesses());
}
......@@ -380,7 +380,7 @@ export class CallStackDataSource implements tree.IDataSource {
});
}
public getParent(tree: tree.ITree, element: any): TPromise<any> {
public getParent(tree: ITree, element: any): TPromise<any> {
return TPromise.as(null);
}
}
......@@ -413,7 +413,7 @@ interface IStackFrameTemplateData {
lineNumber: HTMLElement;
}
export class CallStackRenderer implements tree.IRenderer {
export class CallStackRenderer implements IRenderer {
private static THREAD_TEMPLATE_ID = 'thread';
private static STACK_FRAME_TEMPLATE_ID = 'stackFrame';
......@@ -425,18 +425,18 @@ export class CallStackRenderer implements tree.IRenderer {
// noop
}
public getHeight(tree: tree.ITree, element: any): number {
public getHeight(tree: ITree, element: any): number {
return 22;
}
public getTemplateId(tree: tree.ITree, element: any): string {
if (element instanceof model.Process) {
public getTemplateId(tree: ITree, element: any): string {
if (element instanceof Process) {
return CallStackRenderer.PROCESS_TEMPLATE_ID;
}
if (element instanceof model.Thread) {
if (element instanceof Thread) {
return CallStackRenderer.THREAD_TEMPLATE_ID;
}
if (element instanceof model.StackFrame) {
if (element instanceof StackFrame) {
return CallStackRenderer.STACK_FRAME_TEMPLATE_ID;
}
if (typeof element === 'string') {
......@@ -446,7 +446,7 @@ export class CallStackRenderer implements tree.IRenderer {
return CallStackRenderer.LOAD_MORE_TEMPLATE_ID;
}
public renderTemplate(tree: tree.ITree, templateId: string, container: HTMLElement): any {
public renderTemplate(tree: ITree, templateId: string, container: HTMLElement): any {
if (templateId === CallStackRenderer.PROCESS_TEMPLATE_ID) {
let data: IProcessTemplateData = Object.create(null);
data.process = dom.append(container, $('.process'));
......@@ -487,7 +487,7 @@ export class CallStackRenderer implements tree.IRenderer {
return data;
}
public renderElement(tree: tree.ITree, element: any, templateId: string, templateData: any): void {
public renderElement(tree: ITree, element: any, templateId: string, templateData: any): void {
if (templateId === CallStackRenderer.PROCESS_TEMPLATE_ID) {
this.renderProcess(element, templateData);
} else if (templateId === CallStackRenderer.THREAD_TEMPLATE_ID) {
......@@ -536,23 +536,23 @@ export class CallStackRenderer implements tree.IRenderer {
}
}
public disposeTemplate(tree: tree.ITree, templateId: string, templateData: any): void {
public disposeTemplate(tree: ITree, templateId: string, templateData: any): void {
// noop
}
}
export class CallstackAccessibilityProvider implements tree.IAccessibilityProvider {
export class CallstackAccessibilityProvider implements IAccessibilityProvider {
constructor( @IWorkspaceContextService private contextService: IWorkspaceContextService) {
// noop
}
public getAriaLabel(tree: tree.ITree, element: any): string {
if (element instanceof model.Thread) {
return nls.localize('threadAriaLabel', "Thread {0}, callstack, debug", (<model.Thread>element).name);
public getAriaLabel(tree: ITree, element: any): string {
if (element instanceof Thread) {
return nls.localize('threadAriaLabel', "Thread {0}, callstack, debug", (<Thread>element).name);
}
if (element instanceof model.StackFrame) {
return nls.localize('stackFrameAriaLabel', "Stack Frame {0} line {1} {2}, callstack, debug", (<model.StackFrame>element).name, (<model.StackFrame>element).lineNumber, getSourceName((<model.StackFrame>element).source, this.contextService));
if (element instanceof StackFrame) {
return nls.localize('stackFrameAriaLabel', "Stack Frame {0} line {1} {2}, callstack, debug", (<StackFrame>element).name, (<StackFrame>element).lineNumber, getSourceName((<StackFrame>element).source, this.contextService));
}
return null;
......@@ -561,68 +561,68 @@ export class CallstackAccessibilityProvider implements tree.IAccessibilityProvid
// variables
export class VariablesActionProvider implements renderer.IActionProvider {
export class VariablesActionProvider implements IActionProvider {
constructor(private instantiationService: IInstantiationService) {
// noop
}
public hasActions(tree: tree.ITree, element: any): boolean {
public hasActions(tree: ITree, element: any): boolean {
return false;
}
public getActions(tree: tree.ITree, element: any): TPromise<actions.IAction[]> {
public getActions(tree: ITree, element: any): TPromise<IAction[]> {
return TPromise.as([]);
}
public hasSecondaryActions(tree: tree.ITree, element: any): boolean {
return element instanceof model.Variable;
public hasSecondaryActions(tree: ITree, element: any): boolean {
return element instanceof Variable;
}
public getSecondaryActions(tree: tree.ITree, element: any): TPromise<actions.IAction[]> {
let actions: actions.Action[] = [];
const variable = <model.Variable>element;
public getSecondaryActions(tree: ITree, element: any): TPromise<IAction[]> {
let actions: IAction[] = [];
const variable = <Variable>element;
if (variable.reference === 0) {
actions.push(this.instantiationService.createInstance(debugactions.SetValueAction, debugactions.SetValueAction.ID, debugactions.SetValueAction.LABEL, variable));
actions.push(this.instantiationService.createInstance(SetValueAction, SetValueAction.ID, SetValueAction.LABEL, variable));
actions.push(this.instantiationService.createInstance(CopyValueAction, CopyValueAction.ID, CopyValueAction.LABEL, variable));
actions.push(new actionbar.Separator());
actions.push(new Separator());
}
actions.push(this.instantiationService.createInstance(debugactions.AddToWatchExpressionsAction, debugactions.AddToWatchExpressionsAction.ID, debugactions.AddToWatchExpressionsAction.LABEL, variable));
actions.push(this.instantiationService.createInstance(AddToWatchExpressionsAction, AddToWatchExpressionsAction.ID, AddToWatchExpressionsAction.LABEL, variable));
return TPromise.as(actions);
}
public getActionItem(tree: tree.ITree, element: any, action: actions.IAction): actionbar.IActionItem {
public getActionItem(tree: ITree, element: any, action: IAction): IActionItem {
return null;
}
}
export class VariablesDataSource implements tree.IDataSource {
export class VariablesDataSource implements IDataSource {
public getId(tree: tree.ITree, element: any): string {
public getId(tree: ITree, element: any): string {
return element.getId();
}
public hasChildren(tree: tree.ITree, element: any): boolean {
if (element instanceof viewmodel.ViewModel || element instanceof model.Scope) {
public hasChildren(tree: ITree, element: any): boolean {
if (element instanceof ViewModel || element instanceof Scope) {
return true;
}
let variable = <model.Variable>element;
return variable.reference !== 0 && !strings.equalsIgnoreCase(variable.value, 'null');
let variable = <Variable>element;
return variable.reference !== 0 && !equalsIgnoreCase(variable.value, 'null');
}
public getChildren(tree: tree.ITree, element: any): TPromise<any> {
if (element instanceof viewmodel.ViewModel) {
const focusedStackFrame = (<viewmodel.ViewModel>element).focusedStackFrame;
public getChildren(tree: ITree, element: any): TPromise<any> {
if (element instanceof ViewModel) {
const focusedStackFrame = (<ViewModel>element).focusedStackFrame;
return focusedStackFrame ? focusedStackFrame.getScopes() : TPromise.as([]);
}
let scope = <model.Scope>element;
let scope = <Scope>element;
return scope.getChildren();
}
public getParent(tree: tree.ITree, element: any): TPromise<any> {
public getParent(tree: ITree, element: any): TPromise<any> {
return TPromise.as(null);
}
}
......@@ -637,7 +637,7 @@ export interface IVariableTemplateData {
value: HTMLElement;
}
export class VariablesRenderer implements tree.IRenderer {
export class VariablesRenderer implements IRenderer {
private static SCOPE_TEMPLATE_ID = 'scope';
private static VARIABLE_TEMPLATE_ID = 'variable';
......@@ -649,22 +649,22 @@ export class VariablesRenderer implements tree.IRenderer {
// noop
}
public getHeight(tree: tree.ITree, element: any): number {
public getHeight(tree: ITree, element: any): number {
return 22;
}
public getTemplateId(tree: tree.ITree, element: any): string {
if (element instanceof model.Scope) {
public getTemplateId(tree: ITree, element: any): string {
if (element instanceof Scope) {
return VariablesRenderer.SCOPE_TEMPLATE_ID;
}
if (element instanceof model.Variable) {
if (element instanceof Variable) {
return VariablesRenderer.VARIABLE_TEMPLATE_ID;
}
return null;
}
public renderTemplate(tree: tree.ITree, templateId: string, container: HTMLElement): any {
public renderTemplate(tree: ITree, templateId: string, container: HTMLElement): any {
if (templateId === VariablesRenderer.SCOPE_TEMPLATE_ID) {
let data: IScopeTemplateData = Object.create(null);
data.name = dom.append(container, $('.scope'));
......@@ -680,11 +680,11 @@ export class VariablesRenderer implements tree.IRenderer {
return data;
}
public renderElement(tree: tree.ITree, element: any, templateId: string, templateData: any): void {
public renderElement(tree: ITree, element: any, templateId: string, templateData: any): void {
if (templateId === VariablesRenderer.SCOPE_TEMPLATE_ID) {
this.renderScope(element, templateData);
} else {
const variable = <model.Variable>element;
const variable = <Variable>element;
if (variable === this.debugService.getViewModel().getSelectedExpression() || variable.errorMessage) {
renderRenameBox(this.debugService, this.contextViewService, tree, variable, (<IVariableTemplateData>templateData).expression, {
initialValue: variable.value,
......@@ -699,23 +699,23 @@ export class VariablesRenderer implements tree.IRenderer {
}
}
private renderScope(scope: model.Scope, data: IScopeTemplateData): void {
private renderScope(scope: Scope, data: IScopeTemplateData): void {
data.name.textContent = scope.name;
}
public disposeTemplate(tree: tree.ITree, templateId: string, templateData: any): void {
public disposeTemplate(tree: ITree, templateId: string, templateData: any): void {
// noop
}
}
export class VariablesAccessibilityProvider implements tree.IAccessibilityProvider {
export class VariablesAccessibilityProvider implements IAccessibilityProvider {
public getAriaLabel(tree: tree.ITree, element: any): string {
if (element instanceof model.Scope) {
return nls.localize('variableScopeAriaLabel', "Scope {0}, variables, debug", (<model.Scope>element).name);
public getAriaLabel(tree: ITree, element: any): string {
if (element instanceof Scope) {
return nls.localize('variableScopeAriaLabel', "Scope {0}, variables, debug", (<Scope>element).name);
}
if (element instanceof model.Variable) {
return nls.localize('variableAriaLabel', "{0} value {1}, variables, debug", (<model.Variable>element).name, (<model.Variable>element).value);
if (element instanceof Variable) {
return nls.localize('variableAriaLabel', "{0} value {1}, variables, debug", (<Variable>element).name, (<Variable>element).value);
}
return null;
......@@ -724,14 +724,14 @@ export class VariablesAccessibilityProvider implements tree.IAccessibilityProvid
export class VariablesController extends BaseDebugController {
constructor(debugService: debug.IDebugService, contextMenuService: IContextMenuService, actionProvider: renderer.IActionProvider) {
constructor(debugService: debug.IDebugService, contextMenuService: IContextMenuService, actionProvider: IActionProvider) {
super(debugService, contextMenuService, actionProvider);
this.downKeyBindingDispatcher.set(KeyCode.Enter, this.setSelectedExpression.bind(this));
}
protected onLeftClick(tree: tree.ITree, element: any, event: IMouseEvent): boolean {
protected onLeftClick(tree: ITree, element: any, event: IMouseEvent): boolean {
// double click on primitive value: open input box to be able to set the value
if (element instanceof model.Variable && event.detail === 2) {
if (element instanceof Variable && event.detail === 2) {
const expression = <debug.IExpression>element;
if (expression.reference === 0) {
this.debugService.getViewModel().setSelectedExpression(expression);
......@@ -742,9 +742,9 @@ export class VariablesController extends BaseDebugController {
return super.onLeftClick(tree, element, event);
}
protected setSelectedExpression(tree: tree.ITree, event: KeyboardEvent): boolean {
protected setSelectedExpression(tree: ITree, event: KeyboardEvent): boolean {
const element = tree.getFocus();
if (element instanceof model.Variable && element.reference === 0) {
if (element instanceof Variable && element.reference === 0) {
this.debugService.getViewModel().setSelectedExpression(element);
return true;
}
......@@ -755,7 +755,7 @@ export class VariablesController extends BaseDebugController {
// watch expressions
export class WatchExpressionsActionProvider implements renderer.IActionProvider {
export class WatchExpressionsActionProvider implements IActionProvider {
private instantiationService: IInstantiationService;
......@@ -763,89 +763,89 @@ export class WatchExpressionsActionProvider implements renderer.IActionProvider
this.instantiationService = instantiationService;
}
public hasActions(tree: tree.ITree, element: any): boolean {
return element instanceof model.Expression && !!element.name;
public hasActions(tree: ITree, element: any): boolean {
return element instanceof Expression && !!element.name;
}
public hasSecondaryActions(tree: tree.ITree, element: any): boolean {
public hasSecondaryActions(tree: ITree, element: any): boolean {
return true;
}
public getActions(tree: tree.ITree, element: any): TPromise<actions.IAction[]> {
public getActions(tree: ITree, element: any): TPromise<IAction[]> {
return TPromise.as(this.getExpressionActions());
}
public getExpressionActions(): actions.IAction[] {
return [this.instantiationService.createInstance(debugactions.RemoveWatchExpressionAction, debugactions.RemoveWatchExpressionAction.ID, debugactions.RemoveWatchExpressionAction.LABEL)];
public getExpressionActions(): IAction[] {
return [this.instantiationService.createInstance(RemoveWatchExpressionAction, RemoveWatchExpressionAction.ID, RemoveWatchExpressionAction.LABEL)];
}
public getSecondaryActions(tree: tree.ITree, element: any): TPromise<actions.IAction[]> {
const actions: actions.Action[] = [];
if (element instanceof model.Expression) {
const expression = <model.Expression>element;
actions.push(this.instantiationService.createInstance(debugactions.AddWatchExpressionAction, debugactions.AddWatchExpressionAction.ID, debugactions.AddWatchExpressionAction.LABEL));
actions.push(this.instantiationService.createInstance(debugactions.EditWatchExpressionAction, debugactions.EditWatchExpressionAction.ID, debugactions.EditWatchExpressionAction.LABEL, expression));
public getSecondaryActions(tree: ITree, element: any): TPromise<IAction[]> {
const actions: IAction[] = [];
if (element instanceof Expression) {
const expression = <Expression>element;
actions.push(this.instantiationService.createInstance(AddWatchExpressionAction, AddWatchExpressionAction.ID, AddWatchExpressionAction.LABEL));
actions.push(this.instantiationService.createInstance(EditWatchExpressionAction, EditWatchExpressionAction.ID, EditWatchExpressionAction.LABEL, expression));
if (expression.reference === 0) {
actions.push(this.instantiationService.createInstance(CopyValueAction, CopyValueAction.ID, CopyValueAction.LABEL, expression.value));
}
actions.push(new actionbar.Separator());
actions.push(new Separator());
actions.push(this.instantiationService.createInstance(debugactions.RemoveWatchExpressionAction, debugactions.RemoveWatchExpressionAction.ID, debugactions.RemoveWatchExpressionAction.LABEL));
actions.push(this.instantiationService.createInstance(debugactions.RemoveAllWatchExpressionsAction, debugactions.RemoveAllWatchExpressionsAction.ID, debugactions.RemoveAllWatchExpressionsAction.LABEL));
actions.push(this.instantiationService.createInstance(RemoveWatchExpressionAction, RemoveWatchExpressionAction.ID, RemoveWatchExpressionAction.LABEL));
actions.push(this.instantiationService.createInstance(RemoveAllWatchExpressionsAction, RemoveAllWatchExpressionsAction.ID, RemoveAllWatchExpressionsAction.LABEL));
} else {
actions.push(this.instantiationService.createInstance(debugactions.AddWatchExpressionAction, debugactions.AddWatchExpressionAction.ID, debugactions.AddWatchExpressionAction.LABEL));
if (element instanceof model.Variable) {
const variable = <model.Variable>element;
actions.push(this.instantiationService.createInstance(AddWatchExpressionAction, AddWatchExpressionAction.ID, AddWatchExpressionAction.LABEL));
if (element instanceof Variable) {
const variable = <Variable>element;
if (variable.reference === 0) {
actions.push(this.instantiationService.createInstance(CopyValueAction, CopyValueAction.ID, CopyValueAction.LABEL, variable.value));
}
actions.push(new actionbar.Separator());
actions.push(new Separator());
}
actions.push(this.instantiationService.createInstance(debugactions.RemoveAllWatchExpressionsAction, debugactions.RemoveAllWatchExpressionsAction.ID, debugactions.RemoveAllWatchExpressionsAction.LABEL));
actions.push(this.instantiationService.createInstance(RemoveAllWatchExpressionsAction, RemoveAllWatchExpressionsAction.ID, RemoveAllWatchExpressionsAction.LABEL));
}
return TPromise.as(actions);
}
public getActionItem(tree: tree.ITree, element: any, action: actions.IAction): actionbar.IActionItem {
public getActionItem(tree: ITree, element: any, action: IAction): IActionItem {
return null;
}
}
export class WatchExpressionsDataSource implements tree.IDataSource {
export class WatchExpressionsDataSource implements IDataSource {
public getId(tree: tree.ITree, element: any): string {
public getId(tree: ITree, element: any): string {
return element.getId();
}
public hasChildren(tree: tree.ITree, element: any): boolean {
if (element instanceof model.Model) {
public hasChildren(tree: ITree, element: any): boolean {
if (element instanceof Model) {
return true;
}
const watchExpression = <model.Expression>element;
return watchExpression.reference !== 0 && !strings.equalsIgnoreCase(watchExpression.value, 'null');
const watchExpression = <Expression>element;
return watchExpression.reference !== 0 && !equalsIgnoreCase(watchExpression.value, 'null');
}
public getChildren(tree: tree.ITree, element: any): TPromise<any> {
if (element instanceof model.Model) {
return TPromise.as((<model.Model>element).getWatchExpressions());
public getChildren(tree: ITree, element: any): TPromise<any> {
if (element instanceof Model) {
return TPromise.as((<Model>element).getWatchExpressions());
}
let expression = <model.Expression>element;
let expression = <Expression>element;
return expression.getChildren();
}
public getParent(tree: tree.ITree, element: any): TPromise<any> {
public getParent(tree: ITree, element: any): TPromise<any> {
return TPromise.as(null);
}
}
interface IWatchExpressionTemplateData extends IVariableTemplateData {
actionBar: actionbar.ActionBar;
actionBar: ActionBar;
}
export class WatchExpressionsRenderer implements tree.IRenderer {
export class WatchExpressionsRenderer implements IRenderer {
private static WATCH_EXPRESSION_TEMPLATE_ID = 'watchExpression';
private static VARIABLE_TEMPLATE_ID = 'variables';
......@@ -853,8 +853,8 @@ export class WatchExpressionsRenderer implements tree.IRenderer {
private actionProvider: WatchExpressionsActionProvider;
constructor(
actionProvider: renderer.IActionProvider,
private actionRunner: actions.IActionRunner,
actionProvider: IActionProvider,
private actionRunner: IActionRunner,
@debug.IDebugService private debugService: debug.IDebugService,
@IContextViewService private contextViewService: IContextViewService
) {
......@@ -862,22 +862,22 @@ export class WatchExpressionsRenderer implements tree.IRenderer {
this.actionProvider = <WatchExpressionsActionProvider>actionProvider;
}
public getHeight(tree: tree.ITree, element: any): number {
public getHeight(tree: ITree, element: any): number {
return 22;
}
public getTemplateId(tree: tree.ITree, element: any): string {
if (element instanceof model.Expression) {
public getTemplateId(tree: ITree, element: any): string {
if (element instanceof Expression) {
return WatchExpressionsRenderer.WATCH_EXPRESSION_TEMPLATE_ID;
}
return WatchExpressionsRenderer.VARIABLE_TEMPLATE_ID;
}
public renderTemplate(tree: tree.ITree, templateId: string, container: HTMLElement): any {
public renderTemplate(tree: ITree, templateId: string, container: HTMLElement): any {
let data: IWatchExpressionTemplateData = Object.create(null);
if (templateId === WatchExpressionsRenderer.WATCH_EXPRESSION_TEMPLATE_ID) {
data.actionBar = new actionbar.ActionBar(container, { actionRunner: this.actionRunner });
data.actionBar = new ActionBar(container, { actionRunner: this.actionRunner });
data.actionBar.push(this.actionProvider.getExpressionActions(), { icon: true, label: false });
}
......@@ -888,7 +888,7 @@ export class WatchExpressionsRenderer implements tree.IRenderer {
return data;
}
public renderElement(tree: tree.ITree, element: any, templateId: string, templateData: any): void {
public renderElement(tree: ITree, element: any, templateId: string, templateData: any): void {
if (templateId === WatchExpressionsRenderer.WATCH_EXPRESSION_TEMPLATE_ID) {
this.renderWatchExpression(tree, element, templateData);
} else {
......@@ -896,9 +896,9 @@ export class WatchExpressionsRenderer implements tree.IRenderer {
}
}
private renderWatchExpression(tree: tree.ITree, watchExpression: debug.IExpression, data: IWatchExpressionTemplateData): void {
private renderWatchExpression(tree: ITree, watchExpression: debug.IExpression, data: IWatchExpressionTemplateData): void {
let selectedExpression = this.debugService.getViewModel().getSelectedExpression();
if ((selectedExpression instanceof model.Expression && selectedExpression.getId() === watchExpression.getId()) || (watchExpression instanceof model.Expression && !watchExpression.name)) {
if ((selectedExpression instanceof Expression && selectedExpression.getId() === watchExpression.getId()) || (watchExpression instanceof Expression && !watchExpression.name)) {
renderRenameBox(this.debugService, this.contextViewService, tree, watchExpression, data.expression, {
initialValue: watchExpression.name,
placeholder: nls.localize('watchExpressionPlaceholder', "Expression to watch"),
......@@ -915,7 +915,7 @@ export class WatchExpressionsRenderer implements tree.IRenderer {
}
}
public disposeTemplate(tree: tree.ITree, templateId: string, templateData: any): void {
public disposeTemplate(tree: ITree, templateId: string, templateData: any): void {
if (templateId === WatchExpressionsRenderer.WATCH_EXPRESSION_TEMPLATE_ID) {
(<IWatchExpressionTemplateData>templateData).actionBar.dispose();
}
......@@ -926,14 +926,14 @@ export class WatchExpressionsRenderer implements tree.IRenderer {
}
}
export class WatchExpressionsAccessibilityProvider implements tree.IAccessibilityProvider {
export class WatchExpressionsAccessibilityProvider implements IAccessibilityProvider {
public getAriaLabel(tree: tree.ITree, element: any): string {
if (element instanceof model.Expression) {
return nls.localize('watchExpressionAriaLabel', "{0} value {1}, watch, debug", (<model.Expression>element).name, (<model.Expression>element).value);
public getAriaLabel(tree: ITree, element: any): string {
if (element instanceof Expression) {
return nls.localize('watchExpressionAriaLabel', "{0} value {1}, watch, debug", (<Expression>element).name, (<Expression>element).value);
}
if (element instanceof model.Variable) {
return nls.localize('watchVariableAriaLabel', "{0} value {1}, watch, debug", (<model.Variable>element).name, (<model.Variable>element).value);
if (element instanceof Variable) {
return nls.localize('watchVariableAriaLabel', "{0} value {1}, watch, debug", (<Variable>element).name, (<Variable>element).value);
}
return null;
......@@ -942,7 +942,7 @@ export class WatchExpressionsAccessibilityProvider implements tree.IAccessibilit
export class WatchExpressionsController extends BaseDebugController {
constructor(debugService: debug.IDebugService, contextMenuService: IContextMenuService, actionProvider: renderer.IActionProvider) {
constructor(debugService: debug.IDebugService, contextMenuService: IContextMenuService, actionProvider: IActionProvider) {
super(debugService, contextMenuService, actionProvider);
if (isMacintosh) {
......@@ -952,9 +952,9 @@ export class WatchExpressionsController extends BaseDebugController {
}
}
protected onLeftClick(tree: tree.ITree, element: any, event: IMouseEvent): boolean {
protected onLeftClick(tree: ITree, element: any, event: IMouseEvent): boolean {
// double click on primitive value: open input box to be able to select and copy value.
if (element instanceof model.Expression && event.detail === 2) {
if (element instanceof Expression && event.detail === 2) {
const expression = <debug.IExpression>element;
if (expression.reference === 0) {
this.debugService.getViewModel().setSelectedExpression(expression);
......@@ -965,10 +965,10 @@ export class WatchExpressionsController extends BaseDebugController {
return super.onLeftClick(tree, element, event);
}
protected onRename(tree: tree.ITree, event: KeyboardEvent): boolean {
protected onRename(tree: ITree, event: KeyboardEvent): boolean {
const element = tree.getFocus();
if (element instanceof model.Expression) {
const watchExpression = <model.Expression>element;
if (element instanceof Expression) {
const watchExpression = <Expression>element;
if (watchExpression.reference === 0) {
this.debugService.getViewModel().setSelectedExpression(watchExpression);
}
......@@ -978,10 +978,10 @@ export class WatchExpressionsController extends BaseDebugController {
return false;
}
protected onDelete(tree: tree.ITree, event: IKeyboardEvent): boolean {
protected onDelete(tree: ITree, event: IKeyboardEvent): boolean {
const element = tree.getFocus();
if (element instanceof model.Expression) {
const we = <model.Expression>element;
if (element instanceof Expression) {
const we = <Expression>element;
this.debugService.removeWatchExpressions(we.getId());
return true;
......@@ -993,83 +993,83 @@ export class WatchExpressionsController extends BaseDebugController {
// breakpoints
export class BreakpointsActionProvider implements renderer.IActionProvider {
export class BreakpointsActionProvider implements IActionProvider {
constructor(private instantiationService: IInstantiationService) {
// noop
}
public hasActions(tree: tree.ITree, element: any): boolean {
return element instanceof model.Breakpoint;
public hasActions(tree: ITree, element: any): boolean {
return element instanceof Breakpoint;
}
public hasSecondaryActions(tree: tree.ITree, element: any): boolean {
return element instanceof model.Breakpoint || element instanceof model.ExceptionBreakpoint || element instanceof model.FunctionBreakpoint;
public hasSecondaryActions(tree: ITree, element: any): boolean {
return element instanceof Breakpoint || element instanceof ExceptionBreakpoint || element instanceof FunctionBreakpoint;
}
public getActions(tree: tree.ITree, element: any): TPromise<actions.IAction[]> {
if (element instanceof model.Breakpoint) {
public getActions(tree: ITree, element: any): TPromise<IAction[]> {
if (element instanceof Breakpoint) {
return TPromise.as(this.getBreakpointActions());
}
return TPromise.as([]);
}
public getBreakpointActions(): actions.IAction[] {
return [this.instantiationService.createInstance(debugactions.RemoveBreakpointAction, debugactions.RemoveBreakpointAction.ID, debugactions.RemoveBreakpointAction.LABEL)];
public getBreakpointActions(): IAction[] {
return [this.instantiationService.createInstance(RemoveBreakpointAction, RemoveBreakpointAction.ID, RemoveBreakpointAction.LABEL)];
}
public getSecondaryActions(tree: tree.ITree, element: any): TPromise<actions.IAction[]> {
const actions: actions.Action[] = [this.instantiationService.createInstance(debugactions.ToggleEnablementAction, debugactions.ToggleEnablementAction.ID, debugactions.ToggleEnablementAction.LABEL)];
actions.push(new actionbar.Separator());
public getSecondaryActions(tree: ITree, element: any): TPromise<IAction[]> {
const actions: IAction[] = [this.instantiationService.createInstance(ToggleEnablementAction, ToggleEnablementAction.ID, ToggleEnablementAction.LABEL)];
actions.push(new Separator());
if (element instanceof model.Breakpoint || element instanceof model.FunctionBreakpoint) {
actions.push(this.instantiationService.createInstance(debugactions.RemoveBreakpointAction, debugactions.RemoveBreakpointAction.ID, debugactions.RemoveBreakpointAction.LABEL));
if (element instanceof Breakpoint || element instanceof FunctionBreakpoint) {
actions.push(this.instantiationService.createInstance(RemoveBreakpointAction, RemoveBreakpointAction.ID, RemoveBreakpointAction.LABEL));
}
actions.push(this.instantiationService.createInstance(debugactions.RemoveAllBreakpointsAction, debugactions.RemoveAllBreakpointsAction.ID, debugactions.RemoveAllBreakpointsAction.LABEL));
actions.push(new actionbar.Separator());
actions.push(this.instantiationService.createInstance(RemoveAllBreakpointsAction, RemoveAllBreakpointsAction.ID, RemoveAllBreakpointsAction.LABEL));
actions.push(new Separator());
actions.push(this.instantiationService.createInstance(debugactions.ToggleBreakpointsActivatedAction, debugactions.ToggleBreakpointsActivatedAction.ID, debugactions.ToggleBreakpointsActivatedAction.ACTIVATE_LABEL));
actions.push(new actionbar.Separator());
actions.push(this.instantiationService.createInstance(ToggleBreakpointsActivatedAction, ToggleBreakpointsActivatedAction.ID, ToggleBreakpointsActivatedAction.ACTIVATE_LABEL));
actions.push(new Separator());
actions.push(this.instantiationService.createInstance(debugactions.EnableAllBreakpointsAction, debugactions.EnableAllBreakpointsAction.ID, debugactions.EnableAllBreakpointsAction.LABEL));
actions.push(this.instantiationService.createInstance(debugactions.DisableAllBreakpointsAction, debugactions.DisableAllBreakpointsAction.ID, debugactions.DisableAllBreakpointsAction.LABEL));
actions.push(new actionbar.Separator());
actions.push(this.instantiationService.createInstance(EnableAllBreakpointsAction, EnableAllBreakpointsAction.ID, EnableAllBreakpointsAction.LABEL));
actions.push(this.instantiationService.createInstance(DisableAllBreakpointsAction, DisableAllBreakpointsAction.ID, DisableAllBreakpointsAction.LABEL));
actions.push(new Separator());
actions.push(this.instantiationService.createInstance(debugactions.AddFunctionBreakpointAction, debugactions.AddFunctionBreakpointAction.ID, debugactions.AddFunctionBreakpointAction.LABEL));
if (element instanceof model.FunctionBreakpoint) {
actions.push(this.instantiationService.createInstance(debugactions.RenameFunctionBreakpointAction, debugactions.RenameFunctionBreakpointAction.ID, debugactions.RenameFunctionBreakpointAction.LABEL));
actions.push(this.instantiationService.createInstance(AddFunctionBreakpointAction, AddFunctionBreakpointAction.ID, AddFunctionBreakpointAction.LABEL));
if (element instanceof FunctionBreakpoint) {
actions.push(this.instantiationService.createInstance(RenameFunctionBreakpointAction, RenameFunctionBreakpointAction.ID, RenameFunctionBreakpointAction.LABEL));
}
actions.push(new actionbar.Separator());
actions.push(new Separator());
actions.push(this.instantiationService.createInstance(debugactions.ReapplyBreakpointsAction, debugactions.ReapplyBreakpointsAction.ID, debugactions.ReapplyBreakpointsAction.LABEL));
actions.push(this.instantiationService.createInstance(ReapplyBreakpointsAction, ReapplyBreakpointsAction.ID, ReapplyBreakpointsAction.LABEL));
return TPromise.as(actions);
}
public getActionItem(tree: tree.ITree, element: any, action: actions.IAction): actionbar.IActionItem {
public getActionItem(tree: ITree, element: any, action: IAction): IActionItem {
return null;
}
}
export class BreakpointsDataSource implements tree.IDataSource {
export class BreakpointsDataSource implements IDataSource {
public getId(tree: tree.ITree, element: any): string {
public getId(tree: ITree, element: any): string {
return element.getId();
}
public hasChildren(tree: tree.ITree, element: any): boolean {
return element instanceof model.Model;
public hasChildren(tree: ITree, element: any): boolean {
return element instanceof Model;
}
public getChildren(tree: tree.ITree, element: any): TPromise<any> {
const model = <model.Model>element;
public getChildren(tree: ITree, element: any): TPromise<any> {
const model = <Model>element;
const exBreakpoints = <debug.IEnablement[]>model.getExceptionBreakpoints();
return TPromise.as(exBreakpoints.concat(model.getFunctionBreakpoints()).concat(model.getBreakpoints()));
}
public getParent(tree: tree.ITree, element: any): TPromise<any> {
public getParent(tree: ITree, element: any): TPromise<any> {
return TPromise.as(null);
}
}
......@@ -1082,16 +1082,16 @@ interface IExceptionBreakpointTemplateData {
}
interface IBreakpointTemplateData extends IExceptionBreakpointTemplateData {
actionBar: actionbar.ActionBar;
actionBar: ActionBar;
lineNumber: HTMLElement;
filePath: HTMLElement;
}
interface IFunctionBreakpointTemplateData extends IExceptionBreakpointTemplateData {
actionBar: actionbar.ActionBar;
actionBar: ActionBar;
}
export class BreakpointsRenderer implements tree.IRenderer {
export class BreakpointsRenderer implements IRenderer {
private static EXCEPTION_BREAKPOINT_TEMPLATE_ID = 'exceptionBreakpoint';
private static FUNCTION_BREAKPOINT_TEMPLATE_ID = 'functionBreakpoint';
......@@ -1099,7 +1099,7 @@ export class BreakpointsRenderer implements tree.IRenderer {
constructor(
private actionProvider: BreakpointsActionProvider,
private actionRunner: actions.IActionRunner,
private actionRunner: IActionRunner,
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@debug.IDebugService private debugService: debug.IDebugService,
@IContextViewService private contextViewService: IContextViewService
......@@ -1107,28 +1107,28 @@ export class BreakpointsRenderer implements tree.IRenderer {
// noop
}
public getHeight(tree: tree.ITree, element: any): number {
public getHeight(tree: ITree, element: any): number {
return 22;
}
public getTemplateId(tree: tree.ITree, element: any): string {
if (element instanceof model.Breakpoint) {
public getTemplateId(tree: ITree, element: any): string {
if (element instanceof Breakpoint) {
return BreakpointsRenderer.BREAKPOINT_TEMPLATE_ID;
}
if (element instanceof model.FunctionBreakpoint) {
if (element instanceof FunctionBreakpoint) {
return BreakpointsRenderer.FUNCTION_BREAKPOINT_TEMPLATE_ID;
}
if (element instanceof model.ExceptionBreakpoint) {
if (element instanceof ExceptionBreakpoint) {
return BreakpointsRenderer.EXCEPTION_BREAKPOINT_TEMPLATE_ID;
}
return null;
}
public renderTemplate(tree: tree.ITree, templateId: string, container: HTMLElement): any {
public renderTemplate(tree: ITree, templateId: string, container: HTMLElement): any {
const data: IBreakpointTemplateData = Object.create(null);
if (templateId === BreakpointsRenderer.BREAKPOINT_TEMPLATE_ID || templateId === BreakpointsRenderer.FUNCTION_BREAKPOINT_TEMPLATE_ID) {
data.actionBar = new actionbar.ActionBar(container, { actionRunner: this.actionRunner });
data.actionBar = new ActionBar(container, { actionRunner: this.actionRunner });
data.actionBar.push(this.actionProvider.getBreakpointActions(), { icon: true, label: false });
}
......@@ -1150,7 +1150,7 @@ export class BreakpointsRenderer implements tree.IRenderer {
return data;
}
public renderElement(tree: tree.ITree, element: any, templateId: string, templateData: any): void {
public renderElement(tree: ITree, element: any, templateId: string, templateData: any): void {
templateData.toDisposeBeforeRender = lifecycle.dispose(templateData.toDisposeBeforeRender);
templateData.toDisposeBeforeRender.push(dom.addStandardDisposableListener(templateData.checkbox, 'change', (e) => {
this.debugService.enableOrDisableBreakpoints(!element.enabled, element);
......@@ -1171,7 +1171,7 @@ export class BreakpointsRenderer implements tree.IRenderer {
data.checkbox.checked = exceptionBreakpoint.enabled;
}
private renderFunctionBreakpoint(tree: tree.ITree, functionBreakpoint: debug.IFunctionBreakpoint, data: IFunctionBreakpointTemplateData): void {
private renderFunctionBreakpoint(tree: ITree, functionBreakpoint: debug.IFunctionBreakpoint, data: IFunctionBreakpointTemplateData): void {
const selected = this.debugService.getViewModel().getSelectedFunctionBreakpoint();
if (!functionBreakpoint.name || (selected && selected.getId() === functionBreakpoint.getId())) {
renderRenameBox(this.debugService, this.contextViewService, tree, functionBreakpoint, data.breakpoint, {
......@@ -1198,12 +1198,12 @@ export class BreakpointsRenderer implements tree.IRenderer {
data.actionBar.context = functionBreakpoint;
}
private renderBreakpoint(tree: tree.ITree, breakpoint: debug.IBreakpoint, data: IBreakpointTemplateData): void {
private renderBreakpoint(tree: ITree, breakpoint: debug.IBreakpoint, data: IBreakpointTemplateData): void {
this.debugService.getModel().areBreakpointsActivated() ? tree.removeTraits('disabled', [breakpoint]) : tree.addTraits('disabled', [breakpoint]);
data.name.textContent = labels.getPathLabel(paths.basename(breakpoint.source.uri.fsPath), this.contextService);
data.name.textContent = getPathLabel(paths.basename(breakpoint.source.uri.fsPath), this.contextService);
data.lineNumber.textContent = breakpoint.desiredLineNumber !== breakpoint.lineNumber ? breakpoint.desiredLineNumber + ' \u2192 ' + breakpoint.lineNumber : '' + breakpoint.lineNumber;
data.filePath.textContent = labels.getPathLabel(paths.dirname(breakpoint.source.uri.fsPath), this.contextService);
data.filePath.textContent = getPathLabel(paths.dirname(breakpoint.source.uri.fsPath), this.contextService);
data.checkbox.checked = breakpoint.enabled;
data.actionBar.context = breakpoint;
......@@ -1218,28 +1218,28 @@ export class BreakpointsRenderer implements tree.IRenderer {
}
}
public disposeTemplate(tree: tree.ITree, templateId: string, templateData: any): void {
public disposeTemplate(tree: ITree, templateId: string, templateData: any): void {
if (templateId === BreakpointsRenderer.BREAKPOINT_TEMPLATE_ID || templateId === BreakpointsRenderer.FUNCTION_BREAKPOINT_TEMPLATE_ID) {
templateData.actionBar.dispose();
}
}
}
export class BreakpointsAccessibilityProvider implements tree.IAccessibilityProvider {
export class BreakpointsAccessibilityProvider implements IAccessibilityProvider {
constructor( @IWorkspaceContextService private contextService: IWorkspaceContextService) {
// noop
}
public getAriaLabel(tree: tree.ITree, element: any): string {
if (element instanceof model.Breakpoint) {
return nls.localize('breakpointAriaLabel', "Breakpoint line {0} {1}, breakpoints, debug", (<model.Breakpoint>element).lineNumber, getSourceName((<model.Breakpoint>element).source, this.contextService));
public getAriaLabel(tree: ITree, element: any): string {
if (element instanceof Breakpoint) {
return nls.localize('breakpointAriaLabel', "Breakpoint line {0} {1}, breakpoints, debug", (<Breakpoint>element).lineNumber, getSourceName((<Breakpoint>element).source, this.contextService));
}
if (element instanceof model.FunctionBreakpoint) {
return nls.localize('functionBreakpointAriaLabel', "Function breakpoint {0}, breakpoints, debug", (<model.FunctionBreakpoint>element).name);
if (element instanceof FunctionBreakpoint) {
return nls.localize('functionBreakpointAriaLabel', "Function breakpoint {0}, breakpoints, debug", (<FunctionBreakpoint>element).name);
}
if (element instanceof model.ExceptionBreakpoint) {
return nls.localize('exceptionBreakpointAriaLabel', "Exception breakpoint {0}, breakpoints, debug", (<model.ExceptionBreakpoint>element).filter);
if (element instanceof ExceptionBreakpoint) {
return nls.localize('exceptionBreakpointAriaLabel', "Exception breakpoint {0}, breakpoints, debug", (<ExceptionBreakpoint>element).filter);
}
return null;
......@@ -1248,7 +1248,7 @@ export class BreakpointsAccessibilityProvider implements tree.IAccessibilityProv
export class BreakpointsController extends BaseDebugController {
constructor(debugService: debug.IDebugService, contextMenuService: IContextMenuService, actionProvider: renderer.IActionProvider) {
constructor(debugService: debug.IDebugService, contextMenuService: IContextMenuService, actionProvider: IActionProvider) {
super(debugService, contextMenuService, actionProvider);
if (isMacintosh) {
this.downKeyBindingDispatcher.set(KeyCode.Enter, this.onRename.bind(this));
......@@ -1257,32 +1257,32 @@ export class BreakpointsController extends BaseDebugController {
}
}
protected onLeftClick(tree: tree.ITree, element: any, event: IMouseEvent): boolean {
if (element instanceof model.FunctionBreakpoint && event.detail === 2) {
protected onLeftClick(tree: ITree, element: any, event: IMouseEvent): boolean {
if (element instanceof FunctionBreakpoint && event.detail === 2) {
this.debugService.getViewModel().setSelectedFunctionBreakpoint(element);
return true;
}
if (element instanceof model.Breakpoint) {
if (element instanceof Breakpoint) {
this.openBreakpointSource(element, event, true);
}
return super.onLeftClick(tree, element, event);
}
protected onRename(tree: tree.ITree, event: IKeyboardEvent): boolean {
protected onRename(tree: ITree, event: IKeyboardEvent): boolean {
const element = tree.getFocus();
if (element instanceof model.FunctionBreakpoint && element.name) {
if (element instanceof FunctionBreakpoint && element.name) {
this.debugService.getViewModel().setSelectedFunctionBreakpoint(element);
return true;
}
if (element instanceof model.Breakpoint) {
if (element instanceof Breakpoint) {
this.openBreakpointSource(element, event, false);
}
return super.onEnter(tree, event);
}
protected onSpace(tree: tree.ITree, event: IKeyboardEvent): boolean {
protected onSpace(tree: ITree, event: IKeyboardEvent): boolean {
super.onSpace(tree, event);
const element = <debug.IEnablement>tree.getFocus();
this.debugService.enableOrDisableBreakpoints(!element.enabled, element).done(null, errors.onUnexpectedError);
......@@ -1290,13 +1290,13 @@ export class BreakpointsController extends BaseDebugController {
return true;
}
protected onDelete(tree: tree.ITree, event: IKeyboardEvent): boolean {
protected onDelete(tree: ITree, event: IKeyboardEvent): boolean {
const element = tree.getFocus();
if (element instanceof model.Breakpoint) {
this.debugService.removeBreakpoints((<model.Breakpoint>element).getId()).done(null, errors.onUnexpectedError);
if (element instanceof Breakpoint) {
this.debugService.removeBreakpoints((<Breakpoint>element).getId()).done(null, errors.onUnexpectedError);
return true;
} else if (element instanceof model.FunctionBreakpoint) {
const fbp = <model.FunctionBreakpoint>element;
} else if (element instanceof FunctionBreakpoint) {
const fbp = <FunctionBreakpoint>element;
this.debugService.removeFunctionBreakpoints(fbp.getId()).done(null, errors.onUnexpectedError);
return true;
......
......@@ -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.
先完成此消息的编辑!
想要评论请 注册