From cabc10fc4a5d76feb40d441fb808e7f186264849 Mon Sep 17 00:00:00 2001 From: isidor Date: Thu, 25 Aug 2016 11:01:55 +0200 Subject: [PATCH] debug: adopt completions api --- src/vs/workbench/parts/debug/common/debug.ts | 4 ++++ .../parts/debug/common/debugSource.ts | 4 ++-- .../debug/electron-browser/debugService.ts | 19 +++++++++++++++++++ .../debug/electron-browser/rawDebugSession.ts | 4 ++++ .../debug/test/common/mockDebugService.ts | 6 ++++++ 5 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/parts/debug/common/debug.ts b/src/vs/workbench/parts/debug/common/debug.ts index 454433434e5..3ecae97d403 100644 --- a/src/vs/workbench/parts/debug/common/debug.ts +++ b/src/vs/workbench/parts/debug/common/debug.ts @@ -9,6 +9,8 @@ import Event from 'vs/base/common/event'; import severity from 'vs/base/common/severity'; import {createDecorator} from 'vs/platform/instantiation/common/instantiation'; import editor = require('vs/editor/common/editorCommon'); +import {Position} from 'vs/editor/common/core/position'; +import {ISuggestion} from 'vs/editor/common/modes'; import {Source} from 'vs/workbench/parts/debug/common/debugSource'; import {Range} from 'vs/editor/common/core/range'; import {RawContextKey, ContextKeyExpr} from 'vs/platform/contextkey/common/contextkey'; @@ -19,6 +21,7 @@ export const DEBUG_SERVICE_ID = 'debugService'; export const CONTEXT_IN_DEBUG_MODE = new RawContextKey('inDebugMode', false); export const CONTEXT_NOT_IN_DEBUG_MODE:ContextKeyExpr = CONTEXT_IN_DEBUG_MODE.toNegated(); export const EDITOR_CONTRIBUTION_ID = 'editor.contrib.debug'; +export const DEBUG_SCHEME = 'debug'; // raw @@ -414,6 +417,7 @@ export interface IDebugService { continue(threadId: number): TPromise; pause(threadId: number): TPromise; restartFrame(frameId: number): TPromise; + completions(text: string, position: Position): TPromise; } // Editor interfaces diff --git a/src/vs/workbench/parts/debug/common/debugSource.ts b/src/vs/workbench/parts/debug/common/debugSource.ts index 974b5bf229d..ad440c30612 100644 --- a/src/vs/workbench/parts/debug/common/debugSource.ts +++ b/src/vs/workbench/parts/debug/common/debugSource.ts @@ -5,14 +5,14 @@ import uri from 'vs/base/common/uri'; import paths = require('vs/base/common/paths'); -import {IModel} from 'vs/workbench/parts/debug/common/debug'; +import {IModel, DEBUG_SCHEME} from 'vs/workbench/parts/debug/common/debug'; export class Source { public uri: uri; public available: boolean; - private static INTERNAL_URI_PREFIX = 'debug://internal/'; + private static INTERNAL_URI_PREFIX = `${DEBUG_SCHEME}://internal/`; constructor(public raw: DebugProtocol.Source, available = true) { this.uri = raw.path ? uri.file(paths.normalize(raw.path)) : uri.parse(Source.INTERNAL_URI_PREFIX + raw.name); diff --git a/src/vs/workbench/parts/debug/electron-browser/debugService.ts b/src/vs/workbench/parts/debug/electron-browser/debugService.ts index f1bf9a18995..7e1e42fc831 100644 --- a/src/vs/workbench/parts/debug/electron-browser/debugService.ts +++ b/src/vs/workbench/parts/debug/electron-browser/debugService.ts @@ -17,6 +17,8 @@ import severity from 'vs/base/common/severity'; import {TPromise} from 'vs/base/common/winjs.base'; import aria = require('vs/base/browser/ui/aria/aria'); import editorbrowser = require('vs/editor/browser/editorBrowser'); +import {ISuggestion} from 'vs/editor/common/modes'; +import {Position} from 'vs/editor/common/core/position'; import {IContextKeyService, IContextKey} from 'vs/platform/contextkey/common/contextkey'; import {IMarkerService} from 'vs/platform/markers/common/markers'; import {ILifecycleService} from 'vs/platform/lifecycle/common/lifecycle'; @@ -947,6 +949,23 @@ export class DebugService implements debug.IDebugService { return this.session.restartFrame({ frameId }); } + public completions(text: string, position: Position): TPromise { + if (!this.session) { + return TPromise.as([]); + } + + return this.session.completions({ + frameId: this.viewModel.getFocusedStackFrame().frameId, + text, + column: position.column, + line: position.lineNumber + }).then(response => response.body.targets.map(item => ({ + label: item.label, + insertText: item.text || item.label, + type: 'property' + })), err => []); + } + private lazyTransitionToRunningState(threadId?: number): void { let setNewFocusedStackFrameScheduler: RunOnceScheduler; diff --git a/src/vs/workbench/parts/debug/electron-browser/rawDebugSession.ts b/src/vs/workbench/parts/debug/electron-browser/rawDebugSession.ts index b5a2505a1a1..bfb0bb61b69 100644 --- a/src/vs/workbench/parts/debug/electron-browser/rawDebugSession.ts +++ b/src/vs/workbench/parts/debug/electron-browser/rawDebugSession.ts @@ -274,6 +274,10 @@ export class RawDebugSession extends v8.V8Protocol implements debug.IRawDebugSes return this.send('restartFrame', args); } + public completions(args: DebugProtocol.CompletionsArguments): TPromise { + return this.send('completions', args); + } + public disconnect(restart = false, force = false): TPromise { if (this.stopServerPending && force) { return this.stopServer(); diff --git a/src/vs/workbench/parts/debug/test/common/mockDebugService.ts b/src/vs/workbench/parts/debug/test/common/mockDebugService.ts index d36b4cd86b5..5f02269972b 100644 --- a/src/vs/workbench/parts/debug/test/common/mockDebugService.ts +++ b/src/vs/workbench/parts/debug/test/common/mockDebugService.ts @@ -6,6 +6,8 @@ import Event from 'vs/base/common/event'; import severity from 'vs/base/common/severity'; import {TPromise} from 'vs/base/common/winjs.base'; +import {ISuggestion} from 'vs/editor/common/modes'; +import {Position} from 'vs/editor/common/core/position'; import debug = require('vs/workbench/parts/debug/common/debug'); import {Source} from 'vs/workbench/parts/debug/common/debugSource'; @@ -134,6 +136,10 @@ export class MockDebugService implements debug.IDebugService { public restartFrame(frameId: number): TPromise { return TPromise.as(null); } + + public completions(text: string, position: Position): TPromise { + return TPromise.as([]); + } } -- GitLab