Skip to content

Commit

Permalink
debug: remove Source.fromUri and always try to match source to a sour…
Browse files Browse the repository at this point in the history
…ce from the active stack trace.

fixes #1793
  • Loading branch information
isidorn authored and jrieken committed Jan 6, 2016
1 parent 1d2b103 commit f05c9c2
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 23 deletions.
8 changes: 4 additions & 4 deletions src/vs/workbench/parts/debug/common/debugModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ export class Model extends ee.EventEmitter implements debug.IModel {
}

public addBreakpoints(rawData: debug.IRawBreakpoint[]): void {
this.breakpoints = this.breakpoints.concat(rawData.map(rawBp => new Breakpoint(Source.fromUri(rawBp.uri), rawBp.lineNumber, rawBp.enabled, rawBp.condition)));
this.breakpoints = this.breakpoints.concat(rawData.map(rawBp => new Breakpoint(new Source(Source.toRawSource(rawBp.uri, this)), rawBp.lineNumber, rawBp.enabled, rawBp.condition)));
this.breakpointsActivated = true;
this.emit(debug.ModelEvents.BREAKPOINTS_UPDATED);
}
Expand Down Expand Up @@ -610,10 +610,10 @@ export class Model extends ee.EventEmitter implements debug.IModel {
this.threads[data.threadId].callStack = data.callStack.map(
(rsf, level) => {
if (!rsf) {
return new StackFrame(data.threadId, 0, Source.fromUri(uri.parse('unknown')), nls.localize('unknownStack', "Unknown stack location"), undefined, undefined);
return new StackFrame(data.threadId, 0, new Source({ name: 'unknown' }), nls.localize('unknownStack', "Unknown stack location"), undefined, undefined);
}

return new StackFrame(data.threadId, rsf.id, rsf.source ? new Source(rsf.source) : Source.fromUri(uri.parse('unknown')), rsf.name, rsf.line, rsf.column);
return new StackFrame(data.threadId, rsf.id, rsf.source ? new Source(rsf.source) : new Source({ name: 'unknown' }), rsf.name, rsf.line, rsf.column);
});

this.threads[data.threadId].stoppedReason = data.stoppedReason;
Expand Down
7 changes: 0 additions & 7 deletions src/vs/workbench/parts/debug/common/debugSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,6 @@ export class Source {
{ path: paths.normalize(uri.fsPath, true) };
}

public static fromUri(uri: uri): Source {
return new Source({
name: Source.getName(uri),
path: uri.fsPath,
});
}

private static getName(uri: uri): string {
const uriStr = uri.toString();
return uriStr.substr(uriStr.lastIndexOf('/') + 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService
private registerListeners(eventService: IEventService, lifecycleService: ILifecycleService): void {
this.toDispose.push(eventService.addListener2(EventType.FILE_CHANGES, (e: FileChangesEvent) => this.onFileChanges(e)));


if (this.taskService) {
this.toDispose.push(this.taskService.addListener2(TaskServiceEvents.Active, (e: TaskEvent) => {
this.lastTaskEvent = e;
Expand Down Expand Up @@ -312,7 +311,7 @@ export class DebugService extends ee.EventEmitter implements debug.IDebugService
private loadBreakpoints(): debug.IBreakpoint[] {
try {
return JSON.parse(this.storageService.get(DEBUG_BREAKPOINTS_KEY, StorageScope.WORKSPACE, '[]')).map((breakpoint: any) => {
return new model.Breakpoint(breakpoint.source.raw ? new Source(breakpoint.source.raw) : Source.fromUri(uri.parse(breakpoint.source.uri)),
return new model.Breakpoint(new Source(breakpoint.source.raw ? breakpoint.source.raw : { path: uri.parse(breakpoint.source.uri).fsPath, name: breakpoint.source.name }),
breakpoint.desiredLineNumber || breakpoint.lineNumber, breakpoint.enabled, breakpoint.condition);
});
} catch (e) {
Expand Down
10 changes: 0 additions & 10 deletions src/vs/workbench/parts/debug/test/common/debugSource.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,6 @@ import { Source } from 'vs/workbench/parts/debug/common/debugSource';

suite('Debug - Source', () => {

test('from uri', () => {
const u = uri.file('/a/b/c/d');
const source = Source.fromUri(u);

assert.equal(source.available, true);
assert.equal(source.inMemory, false);
assert.equal(source.uri.toString(), u.toString());
assert.equal(source.name, 'd');
});

test('from raw source', () => {
const rawSource = {
name: 'zz',
Expand Down

0 comments on commit f05c9c2

Please sign in to comment.