Skip to content

Commit

Permalink
debug: add StackFrame.range to model
Browse files Browse the repository at this point in the history
  • Loading branch information
isidorn committed May 10, 2017
1 parent dc7edcc commit f4cc58b
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ export class DebugEditorModelManager implements IWorkbenchContribution {
}

// only show decorations for the currently focussed thread.
const columnUntilEOLRange = new Range(stackFrame.lineNumber, stackFrame.column, stackFrame.lineNumber, Constants.MAX_SAFE_SMALL_INTEGER);
const range = new Range(stackFrame.lineNumber, stackFrame.column, stackFrame.lineNumber, stackFrame.column + 1);
const columnUntilEOLRange = new Range(stackFrame.range.startLineNumber, stackFrame.range.startColumn, stackFrame.range.startLineNumber, Constants.MAX_SAFE_SMALL_INTEGER);
const range = new Range(stackFrame.range.startLineNumber, stackFrame.range.startColumn, stackFrame.range.startLineNumber, stackFrame.range.startColumn + 1);

// compute how to decorate the editor. Different decorations are used if this is a top stack frame, focussed stack frame,
// an exception or a stack frame that did not change the line number (we only decorate the columns, not the whole line).
Expand All @@ -147,7 +147,7 @@ export class DebugEditorModelManager implements IWorkbenchContribution {

if (this.modelDataMap.has(modelUriStr)) {
const modelData = this.modelDataMap.get(modelUriStr);
if (modelData.topStackFrameRange && modelData.topStackFrameRange.startLineNumber === stackFrame.lineNumber && modelData.topStackFrameRange.startColumn !== stackFrame.column) {
if (modelData.topStackFrameRange && modelData.topStackFrameRange.startLineNumber === stackFrame.range.startLineNumber && modelData.topStackFrameRange.startColumn !== stackFrame.range.startColumn) {
result.push({
options: DebugEditorModelManager.TOP_STACK_FRAME_INLINE_DECORATION,
range: columnUntilEOLRange
Expand Down
3 changes: 1 addition & 2 deletions src/vs/workbench/parts/debug/common/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,9 +180,8 @@ export interface IScope extends IExpressionContainer {
export interface IStackFrame extends ITreeElement {
thread: IThread;
name: string;
lineNumber: number;
column: number;
frameId: number;
range: IRange;
source: Source;
getScopes(): TPromise<IScope[]>;
getMostSpecificScopes(range: IRange): TPromise<IScope[]>;
Expand Down
14 changes: 9 additions & 5 deletions src/vs/workbench/parts/debug/common/debugModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,7 @@ export class StackFrame implements IStackFrame {
public frameId: number,
public source: Source,
public name: string,
public lineNumber: number,
public column: number
public range: IRange
) {
this.scopes = null;
}
Expand Down Expand Up @@ -352,7 +351,7 @@ export class StackFrame implements IStackFrame {
}

public toString(): string {
return `${this.name} (${this.source.inMemory ? this.source.name : this.source.uri.fsPath}:${this.lineNumber})`;
return `${this.name} (${this.source.inMemory ? this.source.name : this.source.uri.fsPath}:${this.range.startLineNumber})`;
}

public openInEditor(editorService: IWorkbenchEditorService, preserveFocus?: boolean, sideBySide?: boolean): TPromise<any> {
Expand All @@ -362,7 +361,7 @@ export class StackFrame implements IStackFrame {
description: this.source.origin,
options: {
preserveFocus,
selection: { startLineNumber: this.lineNumber, startColumn: 1 },
selection: { startLineNumber: this.range.startLineNumber, startColumn: 1 },
revealIfVisible: true,
revealInCenterIfOutsideViewport: true,
pinned: !preserveFocus
Expand Down Expand Up @@ -444,7 +443,12 @@ export class Thread implements IThread {
this.process.sources.set(source.uri.toString(), source);
}

return new StackFrame(this, rsf.id, source, rsf.name, rsf.line, rsf.column);
return new StackFrame(this, rsf.id, source, rsf.name, new Range(
rsf.line,
rsf.column,
rsf.endLine === undefined ? rsf.line : rsf.endLine,
rsf.endColumn === undefined ? rsf.column : rsf.endColumn
));
});
}, (err: Error) => {
if (this.stoppedDetails) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,8 @@ export class DebugEditorContribution implements IDebugEditorContribution {
this.closeExceptionWidget();
} else if (sameUri) {
focusedSf.thread.exceptionInfo.then(exceptionInfo => {
if (exceptionInfo && exceptionSf.lineNumber && exceptionSf.column) {
this.showExceptionWidget(exceptionInfo, exceptionSf.lineNumber, exceptionSf.column);
if (exceptionInfo && exceptionSf.range.startLineNumber && exceptionSf.range.startColumn) {
this.showExceptionWidget(exceptionInfo, exceptionSf.range.startLineNumber, exceptionSf.range.startColumn);
}
});
}
Expand Down Expand Up @@ -467,11 +467,11 @@ export class DebugEditorContribution implements IDebugEditorContribution {

this.removeInlineValuesScheduler.cancel();

stackFrame.getMostSpecificScopes(new Range(stackFrame.lineNumber, stackFrame.column, stackFrame.lineNumber, stackFrame.column))
stackFrame.getMostSpecificScopes(stackFrame.range)
// Get all top level children in the scope chain
.then(scopes => TPromise.join(scopes.map(scope => scope.getChildren()
.then(children => {
let range = new Range(0, 0, stackFrame.lineNumber, stackFrame.column);
let range = new Range(0, 0, stackFrame.range.startLineNumber, stackFrame.range.startColumn);
if (scope.range) {
range = range.setStartPosition(scope.range.startLineNumber, scope.range.startColumn);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ export class DebugService implements debug.IDebugService {
const stackFrameToFocus = first(callStack, sf => sf.source && sf.source.available, callStack[0]);
this.focusStackFrameAndEvaluate(stackFrameToFocus).done(null, errors.onUnexpectedError);
this.windowService.getWindow().focus();
aria.alert(nls.localize('debuggingPaused', "Debugging paused, reason {0}, {1} {2}", event.body.reason, stackFrameToFocus.source ? stackFrameToFocus.source.name : '', stackFrameToFocus.lineNumber));
aria.alert(nls.localize('debuggingPaused', "Debugging paused, reason {0}, {1} {2}", event.body.reason, stackFrameToFocus.source ? stackFrameToFocus.source.name : '', stackFrameToFocus.range.startLineNumber));

return stackFrameToFocus.openInEditor(this.editorService);
}
Expand Down
10 changes: 5 additions & 5 deletions src/vs/workbench/parts/debug/electron-browser/debugViewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -538,10 +538,10 @@ export class CallStackRenderer implements IRenderer {
data.label.textContent = stackFrame.name;
data.label.title = stackFrame.name;
data.fileName.textContent = getSourceName(stackFrame.source, this.contextService);
if (stackFrame.lineNumber !== undefined) {
data.lineNumber.textContent = `${stackFrame.lineNumber}`;
if (stackFrame.column) {
data.lineNumber.textContent += `:${stackFrame.column}`;
if (stackFrame.range.startLineNumber !== undefined) {
data.lineNumber.textContent = `${stackFrame.range.startLineNumber}`;
if (stackFrame.range.startColumn) {
data.lineNumber.textContent += `:${stackFrame.range.startColumn}`;
}
dom.removeClass(data.lineNumber, 'unavailable');
} else {
Expand All @@ -565,7 +565,7 @@ export class CallstackAccessibilityProvider implements IAccessibilityProvider {
return nls.localize('threadAriaLabel', "Thread {0}, callstack, debug", (<Thread>element).name);
}
if (element instanceof StackFrame) {
return nls.localize('stackFrameAriaLabel', "Stack Frame {0} line {1} {2}, callstack, debug", (<StackFrame>element).name, (<StackFrame>element).lineNumber, getSourceName((<StackFrame>element).source, this.contextService));
return nls.localize('stackFrameAriaLabel', "Stack Frame {0} line {1} {2}, callstack, debug", (<StackFrame>element).name, (<StackFrame>element).range.startLineNumber, getSourceName((<StackFrame>element).source, this.contextService));
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ suite('Debug - View Model', () => {
const mockSession = new MockSession();
const process = new Process({ name: 'mockProcess', type: 'node', request: 'launch' }, mockSession);
const thread = new Thread(process, 'myThread', 1);
const frame = new StackFrame(thread, 1, null, 'app.js', 1, 1);
const frame = new StackFrame(thread, 1, null, 'app.js', { startColumn: 1, startLineNumber: 1, endColumn: undefined, endLineNumber: undefined });
model.setFocusedStackFrame(frame, process);

assert.equal(model.focusedStackFrame.getId(), frame.getId());
Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/parts/debug/test/node/debugModel.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ suite('Debug - Model', () => {
assert.equal(model.getWatchExpressions().length, 0);
const process = new Process({ name: 'mockProcess', type: 'node', request: 'launch' }, rawSession);
const thread = new Thread(process, 'mockthread', 1);
const stackFrame = new StackFrame(thread, 1, null, 'app.js', 1, 1);
const stackFrame = new StackFrame(thread, 1, null, 'app.js', { startLineNumber: 1, startColumn: 1, endLineNumber: undefined, endColumn: undefined });
model.addWatchExpression(process, stackFrame, 'console').done();
model.addWatchExpression(process, stackFrame, 'console').done();
let watchExpressions = model.getWatchExpressions();
Expand Down Expand Up @@ -338,7 +338,7 @@ suite('Debug - Model', () => {
assert.equal(model.getReplElements().length, 0);
const process = new Process({ name: 'mockProcess', type: 'node', request: 'launch' }, rawSession);
const thread = new Thread(process, 'mockthread', 1);
const stackFrame = new StackFrame(thread, 1, null, 'app.js', 1, 1);
const stackFrame = new StackFrame(thread, 1, null, 'app.js', { startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 10 });
model.addReplExpression(process, stackFrame, 'myVariable').done();
model.addReplExpression(process, stackFrame, 'myVariable').done();
model.addReplExpression(process, stackFrame, 'myVariable').done();
Expand Down

0 comments on commit f4cc58b

Please sign in to comment.