提交 728ca1dc 编写于 作者: I isidor

debug: completions belong to process not stack frame

fixes #16139
上级 32192ccf
......@@ -105,6 +105,7 @@ export interface IProcess extends ITreeElement {
session: ISession;
getThread(threadId: number): IThread;
getAllThreads(): IThread[];
completions(frameId: number, text: string, position: Position, overwriteBefore: number): TPromise<ISuggestion[]>;
}
export interface IThread extends ITreeElement {
......@@ -170,7 +171,6 @@ export interface IStackFrame extends ITreeElement {
source: Source;
getScopes(): TPromise<IScope[]>;
restart(): TPromise<any>;
completions(text: string, position: Position, overwriteBefore: number): TPromise<ISuggestion[]>;
}
export interface IEnablement extends ITreeElement {
......
......@@ -348,26 +348,6 @@ export class StackFrame implements debug.IStackFrame {
public restart(): TPromise<any> {
return this.thread.process.session.restartFrame({ frameId: this.frameId });
}
public completions(text: string, position: Position, overwriteBefore: number): TPromise<ISuggestion[]> {
if (!this.thread.process.session.configuration.capabilities.supportsCompletionsRequest) {
return TPromise.as([]);
}
return this.thread.process.session.completions({
frameId: this.frameId,
text,
column: position.column,
line: position.lineNumber
}).then(response => {
return response && response.body && response.body.targets ? response.body.targets.map(item => (<ISuggestion>{
label: item.label,
insertText: item.text || item.label,
type: item.type,
overwriteBefore: item.length || overwriteBefore
})) : [];
}, err => []);
}
}
export class Thread implements debug.IThread {
......@@ -566,6 +546,26 @@ export class Process implements debug.IProcess {
}
});
}
public completions(frameId: number, text: string, position: Position, overwriteBefore: number): TPromise<ISuggestion[]> {
if (!this.session.configuration.capabilities.supportsCompletionsRequest) {
return TPromise.as([]);
}
return this.session.completions({
frameId,
text,
column: position.column,
line: position.lineNumber
}).then(response => {
return response && response.body && response.body.targets ? response.body.targets.map(item => (<ISuggestion>{
label: item.label,
insertText: item.text || item.label,
type: item.type,
overwriteBefore: item.length || overwriteBefore
})) : [];
}, err => []);
}
}
export class Breakpoint implements debug.IBreakpoint {
......
......@@ -177,7 +177,9 @@ export class Repl extends Panel implements IPrivateReplService {
const overwriteBefore = word ? word.word.length : 0;
const text = this.replInput.getModel().getLineContent(position.lineNumber);
const focusedStackFrame = this.debugService.getViewModel().focusedStackFrame;
const completions = focusedStackFrame ? focusedStackFrame.completions(text, position, overwriteBefore) : TPromise.as([]);
const frameId = focusedStackFrame ? focusedStackFrame.frameId : undefined;
const focusedProcess = this.debugService.getViewModel().focusedProcess;
const completions = focusedProcess ? focusedProcess.completions(frameId, text, position, overwriteBefore) : TPromise.as([]);
return wireCancellationToken(token, completions.then(suggestions => ({
suggestions: suggestions
})));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册