提交 33697437 编写于 作者: I isidor

debug: use TPromise, not Promise

上级 e23b397a
......@@ -5,7 +5,7 @@
import lifecycle = require('vs/base/common/lifecycle');
import errors = require('vs/base/common/errors');
import { Promise } from 'vs/base/common/winjs.base';
import { TPromise } from 'vs/base/common/winjs.base';
import dom = require('vs/base/browser/dom');
import { IAction } from 'vs/base/common/actions';
import { BaseActionItem } from 'vs/base/browser/ui/actionbar/actionbar';
......@@ -61,7 +61,7 @@ export class SelectConfigActionItem extends BaseActionItem {
}
}
private setOptions(): Promise {
private setOptions(): TPromise<any> {
let previousSelectedIndex = this.select.selectedIndex;
this.select.options.length = 0;
......
......@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import nls = require('vs/nls');
import { Promise, TPromise } from 'vs/base/common/winjs.base';
import { TPromise } from 'vs/base/common/winjs.base';
import lifecycle = require('vs/base/common/lifecycle');
import { CommonKeybindings } from 'vs/base/common/keyCodes';
import paths = require('vs/base/common/paths');
......@@ -193,7 +193,7 @@ export class CallStackDataSource implements tree.IDataSource {
return element instanceof model.Model || element instanceof model.Thread;
}
public getChildren(tree: tree.ITree, element: any): Promise {
public getChildren(tree: tree.ITree, element: any): TPromise<any> {
if (element instanceof model.Thread) {
return TPromise.as((<model.Thread> element).callStack);
}
......@@ -211,7 +211,7 @@ export class CallStackDataSource implements tree.IDataSource {
}
}
public getParent(tree: tree.ITree, element: any): Promise {
public getParent(tree: tree.ITree, element: any): TPromise<any> {
return TPromise.as(null);
}
}
......@@ -335,7 +335,7 @@ export class VariablesActionProvider implements renderer.IActionProvider {
return element instanceof model.Variable;
}
public getSecondaryActions(tree: tree.ITree, element: any): Promise {
public getSecondaryActions(tree: tree.ITree, element: any): TPromise<actions.IAction[]> {
let actions: actions.Action[] = [];
const variable = <model.Variable> element;
actions.push(this.instantiationService.createInstance(debugactions.AddToWatchExpressionsAction, debugactions.AddToWatchExpressionsAction.ID, debugactions.AddToWatchExpressionsAction.LABEL, variable));
......@@ -370,7 +370,7 @@ export class VariablesDataSource implements tree.IDataSource {
return variable.reference !== 0 && !strings.equalsIgnoreCase(variable.value, 'null');
}
public getChildren(tree: tree.ITree, element: any): Promise {
public getChildren(tree: tree.ITree, element: any): TPromise<any> {
if (element instanceof viewmodel.ViewModel) {
let focusedStackFrame = (<viewmodel.ViewModel> element).getFocusedStackFrame();
return focusedStackFrame ? focusedStackFrame.getScopes(this.debugService) : TPromise.as([]);
......@@ -380,7 +380,7 @@ export class VariablesDataSource implements tree.IDataSource {
return scope.getChildren(this.debugService);
}
public getParent(tree: tree.ITree, element: any): Promise {
public getParent(tree: tree.ITree, element: any): TPromise<any> {
return TPromise.as(null);
}
}
......@@ -484,7 +484,7 @@ export class WatchExpressionsActionProvider implements renderer.IActionProvider
return true;
}
public getActions(tree: tree.ITree, element: any): Promise {
public getActions(tree: tree.ITree, element: any): TPromise<actions.IAction[]> {
return TPromise.as(this.getExpressionActions());
}
......@@ -492,7 +492,7 @@ export class WatchExpressionsActionProvider implements renderer.IActionProvider
return [this.instantiationService.createInstance(debugactions.RemoveWatchExpressionAction, debugactions.RemoveWatchExpressionAction.ID, debugactions.RemoveWatchExpressionAction.LABEL)];
}
public getSecondaryActions(tree: tree.ITree, element: any): Promise {
public getSecondaryActions(tree: tree.ITree, element: any): TPromise<actions.IAction[]> {
const actions: actions.Action[] = [];
if (element instanceof model.Expression) {
const expression = <model.Expression> element;
......@@ -544,7 +544,7 @@ export class WatchExpressionsDataSource implements tree.IDataSource {
return watchExpression.reference !== 0 && !strings.equalsIgnoreCase(watchExpression.value, 'null');
}
public getChildren(tree: tree.ITree, element: any): Promise {
public getChildren(tree: tree.ITree, element: any): TPromise<any> {
if (element instanceof model.Model) {
return TPromise.as((<model.Model> element).getWatchExpressions());
}
......@@ -553,7 +553,7 @@ export class WatchExpressionsDataSource implements tree.IDataSource {
return expression.getChildren(this.debugService);
}
public getParent(tree: tree.ITree, element: any): Promise {
public getParent(tree: tree.ITree, element: any): TPromise<any> {
return TPromise.as(null);
}
}
......@@ -765,14 +765,14 @@ export class BreakpointsDataSource implements tree.IDataSource {
return element instanceof model.Model;
}
public getChildren(tree: tree.ITree, element: any): Promise {
public getChildren(tree: tree.ITree, element: any): TPromise<any> {
const model = <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): Promise {
public getParent(tree: tree.ITree, element: any): TPromise<any> {
return TPromise.as(null);
}
}
......
......@@ -7,7 +7,7 @@ import 'vs/css!./media/debugViewlet';
import nls = require('vs/nls');
import dom = require('vs/base/browser/dom');
import builder = require('vs/base/browser/builder');
import { Promise, TPromise } from 'vs/base/common/winjs.base';
import { TPromise } from 'vs/base/common/winjs.base';
import errors = require('vs/base/common/errors');
import lifecycle = require('vs/base/common/lifecycle');
import events = require('vs/base/common/events');
......@@ -487,9 +487,9 @@ export class DebugViewlet extends viewlet.Viewlet {
return TPromise.as(null);
}
public setVisible(visible: boolean): TPromise<void> {
public setVisible(visible: boolean): TPromise<any> {
return super.setVisible(visible).then(() => {
return Promise.join(this.views.map((view) => view.setVisible(visible)));
return TPromise.join(this.views.map((view) => view.setVisible(visible)));
});
}
......
......@@ -5,7 +5,7 @@
import 'vs/css!./media/repl';
import nls = require('vs/nls');
import { TPromise, Promise } from 'vs/base/common/winjs.base';
import { TPromise } from 'vs/base/common/winjs.base';
import errors = require('vs/base/common/errors');
import lifecycle = require('vs/base/common/lifecycle');
import actions = require('vs/base/common/actions');
......@@ -155,7 +155,7 @@ export class Repl extends Panel {
this.replInput.focus();
}
public reveal(element: debug.ITreeElement): Promise {
public reveal(element: debug.ITreeElement): TPromise<void> {
return this.tree.reveal(element);
}
......
......@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import nls = require('vs/nls');
import { Promise, TPromise } from 'vs/base/common/winjs.base';
import { TPromise } from 'vs/base/common/winjs.base';
import actions = require('vs/base/common/actions');
import strings = require('vs/base/common/strings');
import URI from 'vs/base/common/uri';
......@@ -47,7 +47,7 @@ export class ReplExpressionsDataSource implements tree.IDataSource {
return element instanceof model.Model || element.reference > 0 || (element instanceof model.KeyValueOutputElement && element.getChildren().length > 0);
}
public getChildren(tree: tree.ITree, element: any): Promise {
public getChildren(tree: tree.ITree, element: any): TPromise<any> {
if (element instanceof model.Model) {
return TPromise.as(element.getReplElements());
}
......@@ -61,7 +61,7 @@ export class ReplExpressionsDataSource implements tree.IDataSource {
return (<debug.IExpression> element).getChildren(this.debugService);
}
public getParent(tree: tree.ITree, element: any): Promise {
public getParent(tree: tree.ITree, element: any): TPromise<any> {
return TPromise.as(null);
}
}
......
......@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import uri from 'vs/base/common/uri';
import { TPromise, Promise } from 'vs/base/common/winjs.base';
import { TPromise } from 'vs/base/common/winjs.base';
import ee = require('vs/base/common/eventEmitter');
import severity from 'vs/base/common/severity';
import { createDecorator, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';
......@@ -223,26 +223,26 @@ export interface IDebugService extends ee.IEventEmitter {
canSetBreakpointsIn(model: editor.IModel, lineNumber: number): boolean;
getConfigurationName(): string;
setConfiguration(name: string): Promise;
setConfiguration(name: string): TPromise<void>;
openConfigFile(sideBySide: boolean): TPromise<boolean>;
loadLaunchConfig(): TPromise<IGlobalConfig>;
setFocusedStackFrameAndEvaluate(focusedStackFrame: IStackFrame): void;
setBreakpointsForModel(modelUri: uri, data: IRawBreakpoint[]): Promise;
toggleBreakpoint(IRawBreakpoint): Promise;
enableOrDisableAllBreakpoints(enabled: boolean): Promise;
toggleEnablement(element: IEnablement): Promise;
toggleBreakpointsActivated(): Promise;
removeAllBreakpoints(): Promise;
sendAllBreakpoints(): Promise;
editBreakpoint(editor: editorbrowser.ICodeEditor, lineNumber: number): Promise;
setBreakpointsForModel(modelUri: uri, data: IRawBreakpoint[]): TPromise<void>;
toggleBreakpoint(IRawBreakpoint): TPromise<void>;
enableOrDisableAllBreakpoints(enabled: boolean): TPromise<void>;
toggleEnablement(element: IEnablement): TPromise<void>;
toggleBreakpointsActivated(): TPromise<void>;
removeAllBreakpoints(): TPromise<any>;
sendAllBreakpoints(): TPromise<any>;
editBreakpoint(editor: editorbrowser.ICodeEditor, lineNumber: number): TPromise<void>;
addFunctionBreakpoint(functionName?: string): Promise;
renameFunctionBreakpoint(id: string, newFunctionName: string): Promise;
removeFunctionBreakpoints(id?: string): Promise;
addFunctionBreakpoint(functionName?: string): TPromise<void>;
renameFunctionBreakpoint(id: string, newFunctionName: string): TPromise<void>;
removeFunctionBreakpoints(id?: string): TPromise<void>;
addReplExpression(name: string): Promise;
addReplExpression(name: string): TPromise<void>;
clearReplExpressions(): void;
logToRepl(value: string, severity?: severity): void;
......@@ -250,20 +250,20 @@ export interface IDebugService extends ee.IEventEmitter {
appendReplOutput(value: string, severity?: severity): void;
addWatchExpression(name?: string): Promise;
renameWatchExpression(id: string, newName: string): Promise;
addWatchExpression(name?: string): TPromise<void>;
renameWatchExpression(id: string, newName: string): TPromise<void>;
clearWatchExpressions(id?: string): void;
createSession(): Promise;
restartSession(): Promise;
rawAttach(port: number): Promise;
createSession(): TPromise<any>;
restartSession(): TPromise<any>;
rawAttach(port: number): TPromise<any>;
getActiveSession(): IRawDebugSession;
getModel(): IModel;
getViewModel(): IViewModel;
openOrRevealEditor(source: Source, lineNumber: number, preserveFocus: boolean, sideBySide: boolean): Promise;
revealRepl(inBackground?:boolean): Promise;
openOrRevealEditor(source: Source, lineNumber: number, preserveFocus: boolean, sideBySide: boolean): TPromise<any>;
revealRepl(inBackground?:boolean): TPromise<void>;
}
// utils
......
......@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Promise, TPromise } from 'vs/base/common/winjs.base';
import { TPromise } from 'vs/base/common/winjs.base';
import nls = require('vs/nls');
import lifecycle = require('vs/base/common/lifecycle');
import ee = require('vs/base/common/eventEmitter');
......@@ -464,7 +464,7 @@ export class Model extends ee.EventEmitter implements debug.IModel {
return this.replElements;
}
public addReplExpression(session: debug.IRawDebugSession, stackFrame: debug.IStackFrame, name: string): Promise {
public addReplExpression(session: debug.IRawDebugSession, stackFrame: debug.IStackFrame, name: string): TPromise<void> {
const expression = new Expression(name, true);
this.replElements.push(expression);
return evaluateExpression(session, stackFrame, expression, 'repl').then(() =>
......@@ -533,7 +533,7 @@ export class Model extends ee.EventEmitter implements debug.IModel {
return this.watchExpressions;
}
public addWatchExpression(session: debug.IRawDebugSession, stackFrame: debug.IStackFrame, name: string): Promise {
public addWatchExpression(session: debug.IRawDebugSession, stackFrame: debug.IStackFrame, name: string): TPromise<void> {
const we = new Expression(name, false);
this.watchExpressions.push(we);
if (!name) {
......@@ -544,7 +544,7 @@ export class Model extends ee.EventEmitter implements debug.IModel {
return this.evaluateWatchExpressions(session, stackFrame, we.getId());
}
public renameWatchExpression(session: debug.IRawDebugSession, stackFrame: debug.IStackFrame, id: string, newName: string): Promise {
public renameWatchExpression(session: debug.IRawDebugSession, stackFrame: debug.IStackFrame, id: string, newName: string): TPromise<void> {
const filtered = this.watchExpressions.filter(we => we.getId() === id);
if (filtered.length === 1) {
filtered[0].name = newName;
......@@ -556,7 +556,7 @@ export class Model extends ee.EventEmitter implements debug.IModel {
return TPromise.as(null);
}
public evaluateWatchExpressions(session: debug.IRawDebugSession, stackFrame: debug.IStackFrame, id: string = null): Promise {
public evaluateWatchExpressions(session: debug.IRawDebugSession, stackFrame: debug.IStackFrame, id: string = null): TPromise<void> {
if (id) {
const filtered = this.watchExpressions.filter(we => we.getId() === id);
if (filtered.length !== 1) {
......@@ -568,7 +568,7 @@ export class Model extends ee.EventEmitter implements debug.IModel {
});
}
return Promise.join(this.watchExpressions.map(we => evaluateExpression(session, stackFrame, we, 'watch'))).then(() => {
return TPromise.join(this.watchExpressions.map(we => evaluateExpression(session, stackFrame, we, 'watch'))).then(() => {
this.emit(debug.ModelEvents.WATCH_EXPRESSIONS_UPDATED);
});
}
......
......@@ -6,7 +6,7 @@
import nls = require('vs/nls');
import actions = require('vs/base/common/actions');
import lifecycle = require('vs/base/common/lifecycle');
import { Promise, TPromise } from 'vs/base/common/winjs.base';
import { TPromise } from 'vs/base/common/winjs.base';
import editorCommon = require('vs/editor/common/editorCommon');
import editorbrowser = require('vs/editor/browser/editorBrowser');
import { EditorAction, Behaviour } from 'vs/editor/common/editorAction';
......@@ -48,7 +48,7 @@ export class AbstractDebugAction extends actions.Action {
this.updateEnablement();
}
public run(e?: any): Promise {
public run(e?: any): TPromise<any> {
throw new Error('implement me');
}
......@@ -76,7 +76,7 @@ export class ConfigureAction extends AbstractDebugAction {
super(id, label, 'debug-action configure', debugService, keybindingService);
}
public run(event?: any): Promise {
public run(event?: any): TPromise<any> {
const sideBySide = !!(event && (event.ctrlKey || event.metaKey));
return this.debugService.openConfigFile(sideBySide);
}
......@@ -90,7 +90,7 @@ export class SelectConfigAction extends AbstractDebugAction {
super(id, label, 'debug-action select-active-config', debugService, keybindingService);
}
public run(configName: string): Promise {
public run(configName: string): TPromise<any> {
return this.debugService.setConfiguration(configName);
}
......@@ -108,7 +108,7 @@ export class StartDebugAction extends AbstractDebugAction {
this.updateEnablement();
}
public run(): Promise {
public run(): TPromise<any> {
return this.debugService.createSession();
}
......@@ -133,7 +133,7 @@ export class RestartDebugAction extends AbstractDebugAction {
}));
}
public run(): Promise {
public run(): TPromise<any> {
return this.debugService.restartSession();
}
......@@ -150,7 +150,7 @@ export class StepOverDebugAction extends AbstractDebugAction {
super(id, label, 'debug-action step-over', debugService, keybindingService);
}
public run(): Promise {
public run(): TPromise<any> {
return this.debugService.getActiveSession().next({ threadId: this.debugService.getViewModel().getFocusedThreadId() });
}
......@@ -167,7 +167,7 @@ export class StepIntoDebugAction extends AbstractDebugAction {
super(id, label, 'debug-action step-into', debugService, keybindingService);
}
public run(): Promise {
public run(): TPromise<any> {
return this.debugService.getActiveSession().stepIn({ threadId: this.debugService.getViewModel().getFocusedThreadId() });
}
......@@ -184,7 +184,7 @@ export class StepOutDebugAction extends AbstractDebugAction {
super(id, label, 'debug-action step-out', debugService, keybindingService);
}
public run(): Promise {
public run(): TPromise<any> {
return this.debugService.getActiveSession().stepOut({ threadId: this.debugService.getViewModel().getFocusedThreadId() });
}
......@@ -208,7 +208,7 @@ export class StopDebugAction extends AbstractDebugAction {
}));
}
public run(): Promise {
public run(): TPromise<any> {
var session = this.debugService.getActiveSession();
return session ? session.disconnect(false, true) : TPromise.as(null);
}
......@@ -226,7 +226,7 @@ export class ContinueAction extends AbstractDebugAction {
super(id, label, 'debug-action continue', debugService, keybindingService);
}
public run(): Promise {
public run(): TPromise<any> {
return this.debugService.getActiveSession().continue({ threadId: this.debugService.getViewModel().getFocusedThreadId() });
}
......@@ -243,7 +243,7 @@ export class PauseAction extends AbstractDebugAction {
super(id, label, 'debug-action pause', debugService, keybindingService);
}
public run(): Promise {
public run(): TPromise<any> {
return this.debugService.getActiveSession().pause({ threadId: this.debugService.getViewModel().getFocusedThreadId() });
}
......@@ -261,7 +261,7 @@ export class RemoveBreakpointAction extends AbstractDebugAction {
this.updateEnablement();
}
public run(breakpoint: debug.IBreakpoint): Promise {
public run(breakpoint: debug.IBreakpoint): TPromise<any> {
return breakpoint instanceof model.Breakpoint ? this.debugService.toggleBreakpoint({ uri: breakpoint.source.uri, lineNumber: breakpoint.lineNumber })
: this.debugService.removeFunctionBreakpoints(breakpoint.getId());
}
......@@ -276,8 +276,8 @@ export class RemoveAllBreakpointsAction extends AbstractDebugAction {
this.toDispose.push(this.debugService.getModel().addListener2(debug.ModelEvents.BREAKPOINTS_UPDATED,() => this.updateEnablement()));
}
public run(): Promise {
return Promise.join([this.debugService.removeAllBreakpoints(), this.debugService.removeFunctionBreakpoints()]);
public run(): TPromise<any> {
return TPromise.join([this.debugService.removeAllBreakpoints(), this.debugService.removeFunctionBreakpoints()]);
}
protected isEnabled(): boolean {
......@@ -293,7 +293,7 @@ export class ToggleEnablementAction extends AbstractDebugAction {
super(id, label, 'debug-action toggle-enablement', debugService, keybindingService);
}
public run(element: debug.IEnablement): Promise {
public run(element: debug.IEnablement): TPromise<any> {
return this.debugService.toggleEnablement(element);
}
}
......@@ -307,7 +307,7 @@ export class EnableAllBreakpointsAction extends AbstractDebugAction {
this.toDispose.push(this.debugService.getModel().addListener2(debug.ModelEvents.BREAKPOINTS_UPDATED, () => this.updateEnablement()));
}
public run(): Promise {
public run(): TPromise<any> {
return this.debugService.enableOrDisableAllBreakpoints(true);
}
......@@ -326,7 +326,7 @@ export class DisableAllBreakpointsAction extends AbstractDebugAction {
this.toDispose.push(this.debugService.getModel().addListener2(debug.ModelEvents.BREAKPOINTS_UPDATED, () => this.updateEnablement()));
}
public run(): Promise {
public run(): TPromise<any> {
return this.debugService.enableOrDisableAllBreakpoints(false);
}
......@@ -353,7 +353,7 @@ export class ToggleBreakpointsActivatedAction extends AbstractDebugAction {
this.label = this.debugService.getModel().areBreakpointsActivated() ? ToggleBreakpointsActivatedAction.DEACTIVATE_LABEL : ToggleBreakpointsActivatedAction.ACTIVATE_LABEL;
}
public run(): Promise {
public run(): TPromise<any> {
return this.debugService.toggleBreakpointsActivated();
}
}
......@@ -367,7 +367,7 @@ export class ReapplyBreakpointsAction extends AbstractDebugAction {
this.toDispose.push(this.debugService.getModel().addListener2(debug.ModelEvents.BREAKPOINTS_UPDATED, () => this.updateEnablement()));
}
public run(): Promise {
public run(): TPromise<any> {
return this.debugService.sendAllBreakpoints();
}
......@@ -384,7 +384,7 @@ export class AddFunctionBreakpointAction extends AbstractDebugAction {
super(id, label, 'debug-action add-function-breakpoint', debugService, keybindingService);
}
public run(): Promise {
public run(): TPromise<any> {
this.debugService.addFunctionBreakpoint();
return TPromise.as(null);
}
......@@ -398,7 +398,7 @@ export class AddConditionalBreakpointAction extends AbstractDebugAction {
super(id, label, null, debugService, keybindingService);
}
public run(): Promise {
public run(): TPromise<any> {
return this.debugService.editBreakpoint(this.editor, this.lineNumber);
}
}
......@@ -411,7 +411,7 @@ export class EditConditionalBreakpointAction extends AbstractDebugAction {
super(id, label, null, debugService, keybindingService);
}
public run(breakpoint: debug.IBreakpoint): Promise {
public run(breakpoint: debug.IBreakpoint): TPromise<any> {
return this.debugService.editBreakpoint(this.editor, this.lineNumber);
}
}
......@@ -423,7 +423,7 @@ export class ToggleBreakpointAction extends EditorAction {
super(descriptor, editor, Behaviour.TextFocus);
}
public run(): TPromise<boolean> {
public run(): TPromise<any> {
if (this.debugService.getState() !== debug.State.Disabled) {
const lineNumber = this.editor.getPosition().lineNumber;
const modelUrl = this.editor.getModel().getAssociatedResource();
......@@ -443,7 +443,7 @@ export class EditorConditionalBreakpointAction extends EditorAction {
super(descriptor, editor, Behaviour.TextFocus);
}
public run(): TPromise<boolean> {
public run(): TPromise<any> {
if (this.debugService.getState() !== debug.State.Disabled) {
const lineNumber = this.editor.getPosition().lineNumber;
if (this.debugService.canSetBreakpointsIn(this.editor.getModel(), lineNumber)) {
......@@ -463,7 +463,7 @@ export class CopyValueAction extends AbstractDebugAction {
super(id, label, 'debug-action copy-value', debugService, keybindingService);
}
public run(): Promise {
public run(): TPromise<any> {
if (this.value instanceof model.Variable) {
const frameId = this.debugService.getViewModel().getFocusedStackFrame().frameId;
const session = this.debugService.getActiveSession();
......@@ -529,7 +529,7 @@ export class AddWatchExpressionAction extends AbstractDebugAction {
this.toDispose.push(this.debugService.getModel().addListener2(debug.ModelEvents.WATCH_EXPRESSIONS_UPDATED, () => this.updateEnablement()));
}
public run(): Promise {
public run(): TPromise<any> {
return this.debugService.addWatchExpression();
}
......@@ -545,7 +545,7 @@ export class SelectionToWatchExpressionsAction extends EditorAction {
super(descriptor, editor, Behaviour.TextFocus);
}
public run(): TPromise<boolean> {
public run(): TPromise<any> {
const text = this.editor.getModel().getValueInRange(this.editor.getSelection());
return this.viewletService.openViewlet(debug.VIEWLET_ID).then(() => this.debugService.addWatchExpression(text));
}
......@@ -569,7 +569,7 @@ export class SelectionToReplAction extends EditorAction {
super(descriptor, editor, Behaviour.TextFocus);
}
public run(): TPromise<boolean> {
public run(): TPromise<any> {
const text = this.editor.getModel().getValueInRange(this.editor.getSelection());
return this.debugService.addReplExpression(text).then(() => this.debugService.revealRepl());
}
......@@ -592,7 +592,7 @@ export class AddToWatchExpressionsAction extends AbstractDebugAction {
super(id, label, 'debug-action add-to-watch', debugService, keybindingService);
}
public run(): Promise {
public run(): TPromise<any> {
return this.debugService.addWatchExpression(model.getFullExpressionName(this.expression, this.debugService.getActiveSession().getType()));
}
}
......@@ -605,7 +605,7 @@ export class RenameWatchExpressionAction extends AbstractDebugAction {
super(id, label, 'debug-action rename', debugService, keybindingService);
}
public run(): Promise {
public run(): TPromise<any> {
this.debugService.getViewModel().setSelectedExpression(this.expression);
return TPromise.as(null);
}
......@@ -619,7 +619,7 @@ export class RemoveWatchExpressionAction extends AbstractDebugAction {
super(id, label, 'debug-action remove', debugService, keybindingService);
}
public run(expression: model.Expression): Promise {
public run(expression: model.Expression): TPromise<any> {
this.debugService.clearWatchExpressions(expression.getId());
return TPromise.as(null);
}
......@@ -634,7 +634,7 @@ export class RemoveAllWatchExpressionsAction extends AbstractDebugAction {
this.toDispose.push(this.debugService.getModel().addListener2(debug.ModelEvents.WATCH_EXPRESSIONS_UPDATED, () => this.updateEnablement()));
}
public run(): Promise {
public run(): TPromise<any> {
this.debugService.clearWatchExpressions();
return TPromise.as(null);
}
......@@ -652,7 +652,7 @@ export class ClearReplAction extends AbstractDebugAction {
super(id, label, 'debug-action clear-repl', debugService, keybindingService);
}
public run(): Promise {
public run(): TPromise<any> {
this.debugService.clearReplExpressions();
// focus back to repl
......@@ -674,7 +674,7 @@ export class ToggleReplAction extends AbstractDebugAction {
this.enabled = this.debugService.getState() !== debug.State.Disabled;
}
public run(): Promise {
public run(): TPromise<any> {
const panel = this.panelService.getActivePanel();
if (panel && panel.getId() === debug.REPL_ID) {
this.partService.setPanelHidden(true);
......
......@@ -13,7 +13,7 @@ import arrays = require('vs/base/common/arrays');
import types = require('vs/base/common/types');
import errors = require('vs/base/common/errors');
import severity from 'vs/base/common/severity';
import { Promise, TPromise } from 'vs/base/common/winjs.base';
import { TPromise } from 'vs/base/common/winjs.base';
import editor = require('vs/editor/common/editorCommon');
import editorbrowser = require('vs/editor/browser/editorBrowser');
import { IKeybindingService, IKeybindingContextKey } from 'vs/platform/keybinding/common/keybindingService';
......@@ -302,8 +302,8 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService
this.revealRepl(true /* in background */).done(null, errors.onUnexpectedError);
}
private getThreadData(threadId: number): Promise {
return this.model.getThreads()[threadId] ? TPromise.as(true) :
private getThreadData(threadId: number): TPromise<void> {
return this.model.getThreads()[threadId] ? TPromise.as(undefined) :
this.session.threads().then((response: DebugProtocol.ThreadsResponse) => {
const thread = response.body.threads.filter(t => t.id === threadId).pop();
if (!thread) {
......@@ -383,7 +383,7 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService
}
}
public setBreakpointsForModel(modelUri: uri, rawData: debug.IRawBreakpoint[]): Promise {
public setBreakpointsForModel(modelUri: uri, rawData: debug.IRawBreakpoint[]): TPromise<void> {
this.model.removeBreakpoints(
this.model.getBreakpoints().filter(bp => bp.source.uri.toString() === modelUri.toString()));
this.model.addBreakpoints(rawData);
......@@ -391,7 +391,7 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService
return this.sendBreakpoints(modelUri);
}
public toggleBreakpoint(rawBreakpoint: debug.IRawBreakpoint): Promise {
public toggleBreakpoint(rawBreakpoint: debug.IRawBreakpoint): TPromise<void> {
const breakpoint = this.model.getBreakpoints().filter(bp => bp.lineNumber === rawBreakpoint.lineNumber && bp.source.uri.toString() === rawBreakpoint.uri.toString()).pop();
if (breakpoint) {
this.model.removeBreakpoints([breakpoint]);
......@@ -402,36 +402,37 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService
return this.sendBreakpoints(rawBreakpoint.uri);
}
public enableOrDisableAllBreakpoints(enabled: boolean): Promise {
public enableOrDisableAllBreakpoints(enabled: boolean): TPromise<void>{
this.model.enableOrDisableAllBreakpoints(enabled);
return this.sendAllBreakpoints();
}
public toggleEnablement(element: debug.IEnablement): Promise {
public toggleEnablement(element: debug.IEnablement): TPromise<void> {
this.model.toggleEnablement(element);
if (element instanceof model.Breakpoint) {
const breakpoint = <model.Breakpoint> element;
return this.sendBreakpoints(breakpoint.source.uri);
} else if (element instanceof model.FunctionBreakpoint) {
return TPromise.as(null);
// TODO@Isidor send function breakpoints and return
}
return this.sendExceptionBreakpoints();
}
public removeAllBreakpoints(): Promise {
public removeAllBreakpoints(): TPromise<any> {
const urisToClear = arrays.distinct(this.model.getBreakpoints(), bp => bp.source.uri.toString()).map(bp => bp.source.uri);
this.model.removeBreakpoints(this.model.getBreakpoints());
return Promise.join(urisToClear.map(uri => this.sendBreakpoints(uri)));
return TPromise.join(urisToClear.map(uri => this.sendBreakpoints(uri)));
}
public toggleBreakpointsActivated(): Promise {
public toggleBreakpointsActivated(): TPromise<void> {
this.model.toggleBreakpointsActivated();
return this.sendAllBreakpoints();
}
public editBreakpoint(editor: editorbrowser.ICodeEditor, lineNumber: number): Promise {
public editBreakpoint(editor: editorbrowser.ICodeEditor, lineNumber: number): TPromise<void> {
if (BreakpointWidget.INSTANCE) {
BreakpointWidget.INSTANCE.dispose();
}
......@@ -439,28 +440,28 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService
this.instantiationService.createInstance(BreakpointWidget, editor, lineNumber);
BreakpointWidget.INSTANCE.show({ lineNumber, column: 1 }, 2);
return TPromise.as(true);
return TPromise.as(null);
}
public addFunctionBreakpoint(functionName?: string): Promise {
public addFunctionBreakpoint(functionName?: string): TPromise<void> {
this.model.addFunctionBreakpoint(functionName);
// TODO@Isidor send updated function breakpoints
return TPromise.as(true);
return TPromise.as(null);
}
public renameFunctionBreakpoint(id: string, newFunctionName: string): Promise {
public renameFunctionBreakpoint(id: string, newFunctionName: string): TPromise<void> {
this.model.renameFunctionBreakpoint(id, newFunctionName);
// TODO@Isidor send updated function breakpoints
return TPromise.as(true);
return TPromise.as(null);
}
public removeFunctionBreakpoints(id?: string): Promise {
public removeFunctionBreakpoints(id?: string): TPromise<void> {
this.model.removeFunctionBreakpoints(id);
// TODO@Isidor send updated function breakpoints
return TPromise.as(true);
return TPromise.as(null);
}
public addReplExpression(name: string): Promise {
public addReplExpression(name: string): TPromise<void> {
return this.model.addReplExpression(this.session, this.viewModel.getFocusedStackFrame(), name);
}
......@@ -478,11 +479,11 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService
this.model.clearReplExpressions();
}
public addWatchExpression(name: string): Promise {
public addWatchExpression(name: string): TPromise<void> {
return this.model.addWatchExpression(this.session, this.viewModel.getFocusedStackFrame(), name);
}
public renameWatchExpression(id: string, newName: string): Promise {
public renameWatchExpression(id: string, newName: string): TPromise<void> {
return this.model.renameWatchExpression(this.session, this.viewModel.getFocusedStackFrame(), id, newName);
}
......@@ -490,7 +491,7 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService
this.model.clearWatchExpressions(id);
}
public createSession(openViewlet = true): Promise {
public createSession(openViewlet = true): TPromise<any> {
this.textFileService.saveAll().done(null, errors.onUnexpectedError);
this.clearReplExpressions();
......@@ -505,7 +506,7 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService
}
if (!this.configurationManager.getAdapter()) {
this.emit(debug.ServiceEvents.TYPE_NOT_SUPPORTED, configuration.type);
return Promise.wrapError(new Error(nls.localize('debugTypeNotSupported', "Configured debug type {0} is not supported.", configuration.type)));
return TPromise.wrapError(new Error(nls.localize('debugTypeNotSupported', "Configured debug type {0} is not supported.", configuration.type)));
}
return this.runPreLaunchTask(configuration.preLaunchTask).then(() => {
......@@ -526,7 +527,7 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService
});
}
private doCreateSession(configuration: debug.IConfig, openViewlet: boolean): Promise {
private doCreateSession(configuration: debug.IConfig, openViewlet: boolean): TPromise<any> {
this.session = new session.RawDebugSession(this.messageService, this.telemetryService, configuration.debugServer, this.configurationManager.getAdapter());
this.registerSessionListeners();
......@@ -537,7 +538,7 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService
columnsStartAt1: true
}).then((result: DebugProtocol.InitializeResponse) => {
if (!this.session) {
return Promise.wrapError(new Error(nls.localize('debugAdapterCrash', "Debug adapter process has terminated unexpectedly")));
return TPromise.wrapError(new Error(nls.localize('debugAdapterCrash', "Debug adapter process has terminated unexpectedly")));
}
this.setStateAndEmit(debug.State.Initializing);
......@@ -559,13 +560,13 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService
this.session.disconnect();
}
return Promise.wrapError(errors.create(error.message, { actions: [CloseAction, this.instantiationService.createInstance(debugactions.ConfigureAction, debugactions.ConfigureAction.ID, debugactions.ConfigureAction.LABEL)] }));
return TPromise.wrapError(errors.create(error.message, { actions: [CloseAction, this.instantiationService.createInstance(debugactions.ConfigureAction, debugactions.ConfigureAction.ID, debugactions.ConfigureAction.LABEL)] }));
});
}
private runPreLaunchTask(taskName: string): Promise {
private runPreLaunchTask(taskName: string): TPromise<void> {
if (!taskName) {
return TPromise.as(true);
return TPromise.as(null);
}
// run a task before starting a debug session
......@@ -573,17 +574,17 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService
const filteredTasks = descriptions.filter(task => task.name === taskName);
if (filteredTasks.length !== 1) {
this.messageService.show(severity.Warning, nls.localize('DebugTaskNotFound', "Could not find a unique task \'{0}\'. Make sure the task exists and that it has a unique name.", taskName));
return TPromise.as(true);
return TPromise.as(null);
}
// task is already running - nothing to do.
if (this.lastTaskEvent && this.lastTaskEvent.taskName === taskName) {
return TPromise.as(true);
return TPromise.as(null);
}
if (this.lastTaskEvent) {
// there is a different task running currently.
return Promise.wrapError(errors.create(nls.localize('differentTaskRunning', "There is a task {0} running. Can not run pre launch task {1}.", this.lastTaskEvent.taskName, taskName)));
return TPromise.wrapError(errors.create(nls.localize('differentTaskRunning', "There is a task {0} running. Can not run pre launch task {1}.", this.lastTaskEvent.taskName, taskName)));
}
// no task running, execute the preLaunchTask.
......@@ -607,7 +608,7 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService
});
}
public rawAttach(port: number): Promise {
public rawAttach(port: number): TPromise<any> {
if (this.session) {
if (!this.session.isAttach) {
return this.session.attach({ port });
......@@ -627,11 +628,11 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService
}, true);
}
public restartSession(): Promise {
public restartSession(): TPromise<any> {
return this.session ? this.session.disconnect(true).then(() =>
new Promise(c => {
new TPromise<void>(c => {
setTimeout(() => {
this.createSession(false).then(() => c(true));
this.createSession(false).then(() => c(null));
}, 300);
})
) : this.createSession(false);
......@@ -680,7 +681,7 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService
return this.viewModel;
}
public openOrRevealEditor(source: Source, lineNumber: number, preserveFocus: boolean, sideBySide: boolean): Promise {
public openOrRevealEditor(source: Source, lineNumber: number, preserveFocus: boolean, sideBySide: boolean): TPromise<any> {
const visibleEditors = this.editorService.getVisibleEditors();
for (let i = 0; i < visibleEditors.length; i++) {
const fileInput = wbeditorcommon.asFileEditorInput(visibleEditors[i].input);
......@@ -734,14 +735,14 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService
);
}
private sourceIsUnavailable(source: Source, sideBySide: boolean): Promise {
private sourceIsUnavailable(source: Source, sideBySide: boolean): TPromise<any> {
this.model.sourceIsUnavailable(source);
const editorInput = this.getDebugStringEditorInput(source, nls.localize('debugSourceNotAvailable', "Source {0} is not available.", source.uri.fsPath), 'text/plain');
return this.editorService.openEditor(editorInput, wbeditorcommon.TextEditorOptions.create({ preserveFocus: true }), sideBySide);
}
public revealRepl(inBackground: boolean = false): Promise {
public revealRepl(inBackground: boolean = false): TPromise<void> {
return this.panelService.openPanel(debug.REPL_ID, !inBackground).then((repl: Repl) => {
const elements = this.model.getReplElements();
if (!inBackground && elements.length > 0) {
......@@ -758,7 +759,7 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService
return this.configurationManager.getConfigurationName();
}
public setConfiguration(name: string): Promise {
public setConfiguration(name: string): TPromise<void> {
return this.configurationManager.setConfiguration(name);
}
......@@ -782,13 +783,13 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService
}
}
public sendAllBreakpoints(): Promise {
return Promise.join(arrays.distinct(this.model.getBreakpoints(), bp => bp.source.uri.toString()).map(bp => this.sendBreakpoints(bp.source.uri)));
public sendAllBreakpoints(): TPromise<any> {
return TPromise.join(arrays.distinct(this.model.getBreakpoints(), bp => bp.source.uri.toString()).map(bp => this.sendBreakpoints(bp.source.uri)));
}
private sendBreakpoints(modelUri: uri): Promise {
private sendBreakpoints(modelUri: uri): TPromise<void> {
if (!this.session || !this.session.readyForBreakpoints) {
return TPromise.as(null);
return TPromise.as(undefined);
}
const breakpointsToSend = arrays.distinct(
......@@ -809,9 +810,9 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService
});
}
private sendExceptionBreakpoints(): Promise {
private sendExceptionBreakpoints(): TPromise<any> {
if (!this.session || !this.session.readyForBreakpoints) {
return TPromise.as(null);
return TPromise.as(undefined);
}
const enabledExBreakpoints = this.model.getExceptionBreakpoints().filter(exb => exb.enabled);
......
......@@ -5,7 +5,7 @@
import path = require('path');
import nls = require('vs/nls');
import { Promise, TPromise } from 'vs/base/common/winjs.base';
import { TPromise } from 'vs/base/common/winjs.base';
import objects = require('vs/base/common/objects');
import uri from 'vs/base/common/uri';
import { schemas } from 'vs/base/common/network';
......@@ -223,7 +223,7 @@ export class ConfigurationManager {
return this.adapters.filter(adapter => adapter.type === this.configuration.type).pop();
}
public setConfiguration(name: string): Promise {
public setConfiguration(name: string): TPromise<void> {
return this.loadLaunchConfig().then(config => {
if (!config || !config.configurations) {
this.configuration = null;
......@@ -290,9 +290,9 @@ export class ConfigurationManager {
});
}
private massageInitialConfigurations(adapter: Adapter): Promise {
private massageInitialConfigurations(adapter: Adapter): TPromise<void> {
if (!adapter || !adapter.initialConfigurations || adapter.type !== 'node') {
return TPromise.as(true);
return TPromise.as(undefined);
}
// check package.json for 'main' or 'scripts' so we generate a more pecise 'program' attribute in launch.json.
......
......@@ -9,7 +9,7 @@ import fs = require('fs');
import net = require('net');
import platform = require('vs/base/common/platform');
import errors = require('vs/base/common/errors');
import { Promise, TPromise} from 'vs/base/common/winjs.base';
import { TPromise } from 'vs/base/common/winjs.base';
import severity from 'vs/base/common/severity';
import debug = require('vs/workbench/parts/debug/common/debug');
import { Adapter } from 'vs/workbench/parts/debug/node/debugAdapter';
......@@ -21,7 +21,7 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
export class RawDebugSession extends v8.V8Protocol implements debug.IRawDebugSession {
private serverProcess: cp.ChildProcess;
private socket: net.Socket = null;
private cachedInitServer: Promise;
private cachedInitServer: TPromise<void>;
private startTime: number;
private stopServerPending: boolean;
public isAttach: boolean;
......@@ -36,7 +36,7 @@ export class RawDebugSession extends v8.V8Protocol implements debug.IRawDebugSes
super();
}
private initServer(): Promise {
private initServer(): TPromise<void> {
if (this.cachedInitServer) {
return this.cachedInitServer;
}
......@@ -46,7 +46,7 @@ export class RawDebugSession extends v8.V8Protocol implements debug.IRawDebugSes
this.startTime = new Date().getTime();
}, err => {
this.cachedInitServer = null;
return Promise.wrapError(err);
return TPromise.wrapError(err);
}
);
......@@ -61,7 +61,7 @@ export class RawDebugSession extends v8.V8Protocol implements debug.IRawDebugSes
this.telemetryService.publicLog('debugProtocolErrorResponse', { error : message });
}
return Promise.wrapError(new Error(message));
return TPromise.wrapError(new Error(message));
}));
}
......@@ -176,8 +176,8 @@ export class RawDebugSession extends v8.V8Protocol implements debug.IRawDebugSes
return this.adapter.type;
}
private connectServer(port: number): Promise {
return new Promise((c, e) => {
private connectServer(port: number): TPromise<void> {
return new TPromise<void>((c, e) => {
this.socket = net.createConnection(port, '127.0.0.1', () => {
this.connect(this.socket, <any>this.socket);
c(null);
......@@ -188,9 +188,9 @@ export class RawDebugSession extends v8.V8Protocol implements debug.IRawDebugSes
});
}
private startServer(): Promise {
private startServer(): TPromise<any> {
if (!this.adapter.program) {
return Promise.wrapError(new Error(nls.localize('noDebugAdapterExtensionInstalled', "No extension installed for '{0}' debugging.", this.adapter.type)));
return TPromise.wrapError(new Error(nls.localize('noDebugAdapterExtensionInstalled', "No extension installed for '{0}' debugging.", this.adapter.type)));
}
return this.getLaunchDetails().then(d => this.launchServer(d).then(() => {
......@@ -209,15 +209,15 @@ export class RawDebugSession extends v8.V8Protocol implements debug.IRawDebugSes
}));
}
private launchServer(launch: { command: string, argv: string[] }): Promise {
return new Promise((c, e) => {
private launchServer(launch: { command: string, argv: string[] }): TPromise<void> {
return new TPromise<void>((c, e) => {
if (launch.command === 'node') {
stdfork.fork(launch.argv[0], launch.argv.slice(1), {}, (err, child) => {
if (err) {
e(new Error(nls.localize('unableToLaunchDebugAdapter', "Unable to launch debug adapter from {0}.", launch.argv[0])));
}
this.serverProcess = child;
c(true);
c(null);
});
} else {
this.serverProcess = cp.spawn(launch.command, launch.argv, {
......@@ -227,12 +227,12 @@ export class RawDebugSession extends v8.V8Protocol implements debug.IRawDebugSes
'pipe' // stderr
],
});
c(true);
c(null);
}
});
}
private stopServer(): Promise {
private stopServer(): TPromise<any> {
if (this.socket !== null) {
this.socket.end();
......@@ -241,17 +241,17 @@ export class RawDebugSession extends v8.V8Protocol implements debug.IRawDebugSes
}
if (!this.serverProcess) {
return TPromise.as(undefined);
return TPromise.as(null);
}
this.stopServerPending = true;
let ret: Promise;
let ret: TPromise<void>;
// when killing a process in windows its child
// processes are *not* killed but become root
// processes. Therefore we use TASKKILL.EXE
if (platform.isWindows) {
ret = new Promise((c, e) => {
ret = new TPromise<void>((c, e) => {
const killer = cp.exec(`taskkill /F /T /PID ${this.serverProcess.pid}`, function (err, stdout, stderr) {
if (err) {
return e(err);
......@@ -262,14 +262,14 @@ export class RawDebugSession extends v8.V8Protocol implements debug.IRawDebugSes
});
} else {
this.serverProcess.kill('SIGTERM');
ret = TPromise.as(undefined);
ret = TPromise.as(null);
}
return ret;
}
private getLaunchDetails(): TPromise<{ command: string; argv: string[]; }> {
return new Promise((c, e) => {
return new TPromise((c, e) => {
fs.exists(this.adapter.program, exists => {
if (exists) {
c(null);
......
......@@ -6,7 +6,7 @@
import stream = require('stream');
import uuid = require('vs/base/common/uuid');
import ee = require('vs/base/common/eventEmitter');
import { Promise, TPromise } from 'vs/base/common/winjs.base';
import { TPromise } from 'vs/base/common/winjs.base';
import debug = require('vs/workbench/parts/debug/common/debug');
export abstract class V8Protocol extends ee.EventEmitter {
......@@ -71,7 +71,7 @@ export abstract class V8Protocol extends ee.EventEmitter {
}
protected send(command: string, args: any): TPromise<DebugProtocol.Response> {
return new Promise((completeDispatch, errorDispatch) => {
return new TPromise((completeDispatch, errorDispatch) => {
this.doSend(command, args, (result: DebugProtocol.Response) => {
if (result.success) {
completeDispatch(result);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册