blob: 96343cb0a8da6a7b676c41d4710fe3dcb2a55ec6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
import * as vscode from "vscode";
import { DebugProtocol } from "@vscode/debugprotocol";
import { DebugSessionTracker } from "../debug-session-tracker";
export interface ModuleProperty {
key: string;
value: string;
}
/** Type to represent both Module and ModuleProperty since TreeDataProvider
* expects one concrete type */
type TreeData = DebugProtocol.Module | ModuleProperty;
function isModule(type: TreeData): type is DebugProtocol.Module {
return (type as DebugProtocol.Module).id !== undefined;
}
class ModuleItem extends vscode.TreeItem {
constructor(module: DebugProtocol.Module) {
super(module.name, vscode.TreeItemCollapsibleState.Collapsed);
this.description = module.symbolStatus;
this.contextValue = "module";
}
static getProperties(module: DebugProtocol.Module): ModuleProperty[] {
// does not include the name and symbol status as it is show in the parent.
let children: ModuleProperty[] = [];
children.push({ key: "id:", value: module.id.toString() });
if (module.addressRange) {
children.push({
key: "load address:",
value: module.addressRange,
});
}
if (module.path) {
children.push({ key: "path:", value: module.path });
}
if (module.version) {
children.push({ key: "version:", value: module.version });
}
if (module.symbolFilePath) {
children.push({ key: "symbol filepath:", value: module.symbolFilePath });
}
return children;
}
}
/** A tree data provider for listing loaded modules for the active debug session. */
export class ModulesDataProvider implements vscode.TreeDataProvider<TreeData> {
private changeTreeData = new vscode.EventEmitter<void>();
readonly onDidChangeTreeData = this.changeTreeData.event;
constructor(private readonly tracker: DebugSessionTracker) {
tracker.onDidChangeModules(() => this.changeTreeData.fire());
}
getTreeItem(module: TreeData): vscode.TreeItem {
if (isModule(module)) {
return new ModuleItem(module);
}
let item = new vscode.TreeItem(module.key);
item.description = module.value;
item.tooltip = `${module.key} ${module.value}`;
item.contextValue = "property";
return item;
}
getChildren(element?: TreeData): TreeData[] {
if (!vscode.debug.activeDebugSession) {
return [];
}
if (!element) {
return this.tracker.debugSessionModules(vscode.debug.activeDebugSession);
}
if (isModule(element)) {
return ModuleItem.getProperties(element);
}
return [];
}
}
|