proposed API for creating debug uri

This commit is contained in:
Andre Weinand
2019-11-13 18:17:42 +01:00
parent c4a5657ec1
commit 4a61f33994
4 changed files with 52 additions and 1 deletions

View File

@@ -138,6 +138,32 @@ export class ExtHostDebugService implements IExtHostDebugService, ExtHostDebugSe
});
}
public asDebugSourceUri(src: vscode.DebugSource, session?: vscode.DebugSession): URI {
const source = <any>src;
if (typeof source.sourceReference === 'number') {
// src can be retrieved via DAP's "source" request
let debug = `debug:${encodeURIComponent(source.path || '')}`;
let sep = '?';
if (session) {
debug += `${sep}session=${encodeURIComponent(session.id)}`;
sep = '&';
}
debug += `${sep}ref=${source.sourceReference}`;
return vscode.Uri.parse(debug);
} else if (source.path) {
// src is just a local file path
return vscode.Uri.file(source.path);
} else {
throw new Error(`cannot create uri from DAP 'source' object; properties 'path' and 'sourceReference' are both missing.`);
}
}
private registerAllDebugTypes(extensionRegistry: ExtensionDescriptionRegistry) {
const debugTypes: string[] = [];