Skip to content

Commit e94ebb9

Browse files
committed
debugSource.getSourceReference()
1 parent 0214d86 commit e94ebb9

2 files changed

Lines changed: 11 additions & 0 deletions

File tree

src/vs/workbench/parts/debug/common/debugSource.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,13 @@ export class Source {
3838
public static isInMemory(uri: uri): boolean {
3939
return uri.toString().indexOf(Source.INTERNAL_URI_PREFIX) === 0;
4040
}
41+
42+
public static getSourceReference(uri: uri): number {
43+
if (!Source.isInMemory(uri)) {
44+
return 0;
45+
}
46+
47+
const uriStr = uri.toString();
48+
return parseInt(uriStr.substring(Source.INTERNAL_URI_PREFIX.length, uriStr.lastIndexOf('/')));
49+
}
4150
}

src/vs/workbench/parts/debug/test/common/debugSource.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ suite('Debug - Source', () => {
2222
assert.equal(source.inMemory, false);
2323
assert.equal(source.reference, rawSource.sourceReference);
2424
assert.equal(source.uri.toString(), uri.file(rawSource.path).toString());
25+
assert.equal(Source.getSourceReference(source.uri), 0);
2526
});
2627

2728
test('from raw internal source', () => {
@@ -35,5 +36,6 @@ suite('Debug - Source', () => {
3536
assert.equal(source.name, rawSource.name);
3637
assert.equal(source.inMemory, true);
3738
assert.equal(source.reference, rawSource.sourceReference);
39+
assert.equal(Source.getSourceReference(source.uri), 11);
3840
});
3941
});

0 commit comments

Comments
 (0)