提交 a9f66e01 编写于 作者: I isidor

debug more asyn await

上级 017e7dfb
......@@ -83,10 +83,10 @@ export class ConfigureAction extends AbstractDebugAction {
this.class = configurationCount > 0 ? 'debug-action configure' : 'debug-action configure notification';
}
run(event?: any): Promise<any> {
async run(event?: any): Promise<any> {
if (this.contextService.getWorkbenchState() === WorkbenchState.EMPTY) {
this.notificationService.info(nls.localize('noFolderDebugConfig', "Please first open a folder in order to do advanced debug configuration."));
return Promise.resolve();
return;
}
const sideBySide = !!(event && (event.ctrlKey || event.metaKey));
......@@ -295,9 +295,8 @@ export class AddFunctionBreakpointAction extends AbstractDebugAction {
this._register(this.debugService.getModel().onDidChangeBreakpoints(() => this.updateEnablement()));
}
run(): Promise<any> {
async run(): Promise<any> {
this.debugService.addFunctionBreakpoint();
return Promise.resolve();
}
protected isEnabled(_: State): boolean {
......@@ -316,9 +315,8 @@ export class AddWatchExpressionAction extends AbstractDebugAction {
this._register(this.debugService.getViewModel().onDidSelectExpression(() => this.updateEnablement()));
}
run(): Promise<any> {
async run(): Promise<any> {
this.debugService.addWatchExpression();
return Promise.resolve(undefined);
}
protected isEnabled(_: State): boolean {
......@@ -336,9 +334,8 @@ export class RemoveAllWatchExpressionsAction extends AbstractDebugAction {
this._register(this.debugService.getModel().onDidChangeWatchExpressions(() => this.updateEnablement()));
}
run(): Promise<any> {
async run(): Promise<any> {
this.debugService.removeWatchExpressions();
return Promise.resolve();
}
protected isEnabled(_: State): boolean {
......@@ -362,10 +359,8 @@ export class FocusSessionAction extends AbstractDebugAction {
await this.debugService.focusStackFrame(undefined, undefined, session, true);
const stackFrame = this.debugService.getViewModel().focusedStackFrame;
if (stackFrame) {
return stackFrame.openInEditor(this.editorService, true);
await stackFrame.openInEditor(this.editorService, true);
}
return Promise.resolve(undefined);
}
}
......
......@@ -34,7 +34,7 @@ class ToggleBreakpointAction extends EditorAction {
});
}
run(accessor: ServicesAccessor, editor: ICodeEditor): Promise<any> {
async run(accessor: ServicesAccessor, editor: ICodeEditor): Promise<any> {
if (editor.hasModel()) {
const debugService = accessor.get(IDebugService);
const modelUri = editor.getModel().uri;
......@@ -49,12 +49,10 @@ class ToggleBreakpointAction extends EditorAction {
} else if (canSet) {
return (debugService.addBreakpoints(modelUri, [{ lineNumber: line }], 'debugEditorActions.toggleBreakpointAction'));
} else {
return Promise.resolve([]);
return [];
}
}));
}
return Promise.resolve();
}
}
......@@ -175,7 +173,7 @@ class SelectionToReplAction extends EditorAction {
const viewModel = debugService.getViewModel();
const session = viewModel.focusedSession;
if (!editor.hasModel() || !session) {
return Promise.resolve();
return;
}
const text = editor.getModel().getValueInRange(editor.getSelection());
......@@ -203,7 +201,7 @@ class SelectionToWatchExpressionsAction extends EditorAction {
const debugService = accessor.get(IDebugService);
const viewletService = accessor.get(IViewletService);
if (!editor.hasModel()) {
return Promise.resolve();
return;
}
const text = editor.getModel().getValueInRange(editor.getSelection());
......@@ -228,14 +226,14 @@ class ShowDebugHoverAction extends EditorAction {
});
}
run(accessor: ServicesAccessor, editor: ICodeEditor): Promise<void> {
async run(accessor: ServicesAccessor, editor: ICodeEditor): Promise<void> {
const position = editor.getPosition();
if (!position || !editor.hasModel()) {
return Promise.resolve();
return;
}
const word = editor.getModel().getWordAtPosition(position);
if (!word) {
return Promise.resolve();
return;
}
const range = new Range(position.lineNumber, position.column, position.lineNumber, word.endColumn);
......@@ -248,7 +246,7 @@ class GoToBreakpointAction extends EditorAction {
super(opts);
}
run(accessor: ServicesAccessor, editor: ICodeEditor, args: any): Promise<any> {
async run(accessor: ServicesAccessor, editor: ICodeEditor): Promise<any> {
const debugService = accessor.get(IDebugService);
const editorService = accessor.get(IEditorService);
if (editor.hasModel()) {
......@@ -280,8 +278,6 @@ class GoToBreakpointAction extends EditorAction {
return openBreakpointSource(moveBreakpoint, false, true, debugService, editorService);
}
}
return Promise.resolve(null);
}
}
......
......@@ -145,14 +145,12 @@ class DebugEditorContribution implements IDebugEditorContribution {
return EDITOR_CONTRIBUTION_ID;
}
showHover(range: Range, focus: boolean): Promise<void> {
async showHover(range: Range, focus: boolean): Promise<void> {
const sf = this.debugService.getViewModel().focusedStackFrame;
const model = this.editor.getModel();
if (sf && model && sf.source.uri.toString() === model.uri.toString()) {
return this.hoverWidget.showAt(range, focus);
}
return Promise.resolve();
}
private async onFocusStackFrame(sf: IStackFrame | undefined): Promise<void> {
......@@ -327,7 +325,7 @@ class DebugEditorContribution implements IDebugEditorContribution {
let configurationsArrayPosition: Position | undefined;
const model = this.editor.getModel();
if (!model) {
return Promise.resolve();
return;
}
let depthInArray = 0;
......@@ -350,7 +348,7 @@ class DebugEditorContribution implements IDebugEditorContribution {
this.editor.focus();
if (!configurationsArrayPosition) {
return Promise.resolve();
return;
}
const insertLine = (position: Position): Promise<any> => {
......
......@@ -74,8 +74,8 @@ interface IPrivateReplService {
_serviceBrand: undefined;
acceptReplInput(): void;
getVisibleContent(): string;
selectSession(session?: IDebugSession): void;
clearRepl(): void;
selectSession(session?: IDebugSession): Promise<void>;
clearRepl(): Promise<void>;
focusRepl(): void;
}
......@@ -129,7 +129,7 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
}
private registerListeners(): void {
this._register(this.debugService.getViewModel().onDidFocusSession(session => {
this._register(this.debugService.getViewModel().onDidFocusSession(async session => {
if (session) {
sessionsToIgnore.delete(session);
if (this.completionItemProvider) {
......@@ -159,13 +159,13 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
}
}
this.selectSession();
await this.selectSession();
}));
this._register(this.debugService.onWillNewSession(newSession => {
this._register(this.debugService.onWillNewSession(async newSession => {
// Need to listen to output events for sessions which are not yet fully initialised
const input = this.tree.getInput();
if (!input || input.state === State.Inactive) {
this.selectSession(newSession);
await this.selectSession(newSession);
}
this.updateTitleArea();
}));
......@@ -252,7 +252,7 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
}
}
selectSession(session?: IDebugSession): void {
async selectSession(session?: IDebugSession): Promise<void> {
const treeInput = this.tree.getInput();
if (!session) {
const focusedSession = this.debugService.getViewModel().focusedSession;
......@@ -272,7 +272,8 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
});
if (this.tree && treeInput !== session) {
this.tree.setInput(session).then(() => revealLastElement(this.tree)).then(undefined, errors.onUnexpectedError);
await this.tree.setInput(session);
revealLastElement(this.tree);
}
}
......@@ -280,14 +281,14 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
this.updateInputDecoration();
}
clearRepl(): void {
async clearRepl(): Promise<void> {
const session = this.tree.getInput();
if (session) {
session.removeReplExpressions();
if (session.state === State.Inactive) {
// Ignore inactive sessions which got cleared - so they are not shown any more
sessionsToIgnore.add(session);
this.selectSession();
await this.selectSession();
this.updateTitleArea();
}
}
......@@ -998,7 +999,7 @@ class SelectReplAction extends Action {
if (session && session.state !== State.Inactive && session !== this.debugService.getViewModel().focusedSession) {
await this.debugService.focusStackFrame(undefined, undefined, session, true);
} else {
this.replService.selectSession(session);
await this.replService.selectSession(session);
}
return Promise.resolve(undefined);
......@@ -1015,11 +1016,9 @@ export class ClearReplAction extends Action {
super(id, label, 'debug-action codicon-clear-all');
}
run(): Promise<any> {
async run(): Promise<any> {
const repl = <Repl>this.panelService.openPanel(REPL_ID);
repl.clearRepl();
await repl.clearRepl();
aria.status(nls.localize('debugConsoleCleared', "Debug console was cleared"));
return Promise.resolve(undefined);
}
}
......@@ -65,7 +65,7 @@ export class ExpressionContainer implements IExpressionContainer {
private async doGetChildren(): Promise<IExpression[]> {
if (!this.hasChildren) {
return Promise.resolve([]);
return [];
}
if (!this.getChildrenInChunks) {
......@@ -224,7 +224,7 @@ export class Variable extends ExpressionContainer implements IExpression {
async setVariable(value: string): Promise<any> {
if (!this.session) {
return Promise.resolve(undefined);
return;
}
try {
......@@ -345,9 +345,11 @@ export class StackFrame implements IStackFrame {
return sourceToString === UNKNOWN_SOURCE_LABEL ? this.name : `${this.name} (${sourceToString})`;
}
openInEditor(editorService: IEditorService, preserveFocus?: boolean, sideBySide?: boolean, pinned?: boolean): Promise<ITextEditor | undefined> {
return !this.source.available ? Promise.resolve(undefined) :
this.source.openInEditor(editorService, this.range, preserveFocus, sideBySide, pinned);
async openInEditor(editorService: IEditorService, preserveFocus?: boolean, sideBySide?: boolean, pinned?: boolean): Promise<ITextEditor | undefined> {
if (this.source.available) {
return this.source.openInEditor(editorService, this.range, preserveFocus, sideBySide, pinned);
}
return undefined;
}
equals(other: IStackFrame): boolean {
......
......@@ -133,7 +133,6 @@ export class SocketDebugAdapter extends StreamDebugAdapter {
this.socket.end();
this.socket = undefined;
}
return Promise.resolve(undefined);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册