提交 6437112f 编写于 作者: I isidor

debug: respect supportsEvaluateForHovers capability

fixes #2012
上级 d12d295c
......@@ -3,6 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { TPromise } from 'vs/base/common/winjs.base';
import errors = require('vs/base/common/errors');
import dom = require('vs/base/browser/dom');
import * as nls from 'vs/nls';
......@@ -13,6 +14,7 @@ import editorbrowser = require('vs/editor/browser/editorBrowser');
import editorcommon = require('vs/editor/common/editorCommon');
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import debug = require('vs/workbench/parts/debug/common/debug');
import {evaluateExpression, Expression} from 'vs/workbench/parts/debug/common/debugModel';
import viewer = require('vs/workbench/parts/debug/browser/debugViewer');
const $ = dom.emmet;
......@@ -88,9 +90,40 @@ export class DebugHoverWidget implements editorbrowser.IContentWidget {
.split('.').map(word => word.trim()).filter(word => !!word);
namesToFind.push(hoveringOver);
namesToFind[0] = namesToFind[0].substring(namesToFind[0].lastIndexOf(' ') + 1);
const variables: debug.IExpression[] = [];
focusedStackFrame.getScopes(this.debugService).done(scopes => {
this.getExpression(namesToFind).done(expression => {
if (!expression) {
this.hide();
return;
}
// show it
this.highlightDecorations = this.editor.deltaDecorations(this.highlightDecorations, [{
range: {
startLineNumber: pos.lineNumber,
endLineNumber: pos.lineNumber,
startColumn: wordAtPosition.startColumn,
endColumn: wordAtPosition.endColumn
},
options: {
className: 'hoverHighlight'
}
}]);
this.lastHoveringOver = hoveringOver;
this.doShow(pos, expression);
}, errors.onUnexpectedError);
}
private getExpression(namesToFind: string[]): TPromise<debug.IExpression> {
const session = this.debugService.getActiveSession();
const focusedStackFrame = this.debugService.getViewModel().getFocusedStackFrame();
if (session.capablities.supportsEvaluateForHovers) {
return evaluateExpression(session, focusedStackFrame, new Expression(namesToFind.join('.'), true), 'hover');
}
const variables: debug.IExpression[] = [];
return focusedStackFrame.getScopes(this.debugService).then(scopes => {
// flatten out scopes lists
return scopes.reduce((accum, scopes) => { return accum.concat(scopes); }, [])
......@@ -116,28 +149,9 @@ export class DebugHoverWidget implements editorbrowser.IContentWidget {
}
}
}, errors.onUnexpectedError));
}, errors.onUnexpectedError);
// don't show if there are duplicates across scopes
if (variables.length !== 1) {
this.hide();
return;
}
// show it
this.highlightDecorations = this.editor.deltaDecorations(this.highlightDecorations, [{
range: {
startLineNumber: pos.lineNumber,
endLineNumber: pos.lineNumber,
startColumn: wordAtPosition.startColumn,
endColumn: wordAtPosition.endColumn
},
options: {
className: 'hoverHighlight'
}
}]);
this.lastHoveringOver = hoveringOver;
this.doShow(pos, variables[0]);
// only show if there are no duplicates across scopes
}).then(() => variables.length === 1 ? TPromise.as(variables[0]) : TPromise.as(null));
}
private doShow(position: editorcommon.IEditorPosition, expression: debug.IExpression, forceValueHover = false): void {
......
......@@ -199,6 +199,7 @@ export interface IRawAdapter extends IRawEnvAdapter {
export interface IRawDebugSession extends ee.EventEmitter {
getType(): string;
isAttach: boolean;
capablities: DebugProtocol.Capabilites;
disconnect(restart?: boolean, force?: boolean): TPromise<DebugProtocol.DisconnectResponse>;
next(args: DebugProtocol.NextArguments): TPromise<DebugProtocol.NextResponse>;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册