• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

rokucommunity / vscode-brightscript-language / 30096694707

24 Jul 2026 01:23PM UTC coverage: 59.949% (+0.04%) from 59.908%
30096694707

Pull #802

github

web-flow
Merge 333fa7808 into e465804e3
Pull Request #802: Route extension logs through the BrightScript Extension output channel

2592 of 4745 branches covered (54.63%)

Branch coverage included in aggregate %.

19 of 23 new or added lines in 3 files covered. (82.61%)

732 existing lines in 18 files now uncovered.

4036 of 6311 relevant lines covered (63.95%)

43.79 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

91.86
/src/commands/ProfilingCommands.ts
1
import * as vscode from 'vscode';
1✔
2
import { vscodeContextManager } from '../managers/VscodeContextManager';
1✔
3
import { isProfilingEnabledEvent, isProfilingStartEvent, isProfilingStopEvent, isProfilingErrorEvent } from 'roku-debug';
1✔
4

5
export class ProfilingCommands {
1✔
6

7
    public register(
8
        context: vscode.ExtensionContext
9
    ) {
10
        context.subscriptions.push(
45✔
11
            vscode.debug.onDidReceiveDebugSessionCustomEvent(async (event: unknown) => {
12
                //set various context keys based on profiling events to control visibility and state of UI elements (buttons, status bar items, etc.)
13
                if (isProfilingEnabledEvent(event)) {
8✔
14
                    if (event.body.types.includes('trace')) {
4✔
15
                        void vscodeContextManager.set('brightscript.tracingEnabled', true);
3✔
16
                    }
17
                    if (event.body.types.includes('heapSnapshot')) {
4✔
18
                        void vscodeContextManager.set('brightscript.heapSnapshotEnabled', true);
3✔
19
                    }
20
                } else if (isProfilingStartEvent(event)) {
4✔
21
                    if (event.body.type === 'trace') {
1!
22
                        await vscodeContextManager.set('brightscript.tracingActive', true);
1✔
UNCOV
23
                    } else if (event.body.type === 'heapSnapshot') {
×
UNCOV
24
                        await vscodeContextManager.set('brightscript.heapSnapshotActive', true);
×
25
                    }
26

27
                } else if (isProfilingStopEvent(event)) {
3✔
28
                    if (event.body.type === 'trace') {
2✔
29
                        await vscodeContextManager.set('brightscript.tracingActive', false);
1✔
30

31
                    } else if (event.body.type === 'heapSnapshot') {
1!
32
                        void vscodeContextManager.set('brightscript.heapSnapshotActive', false);
1✔
33
                    }
34
                    //open the profile in an editor
35
                    if (event.body.result) {
2✔
36
                        void vscode.commands.executeCommand('vscode.open', vscode.Uri.file(event.body.result));
1✔
37
                    }
38

39
                } else if (isProfilingErrorEvent(event)) {
1!
40
                    void vscode.window.showErrorMessage(`Profiling error: ${event.body.error.message}`);
1✔
41
                }
42
            })
43
        );
44

45
        function cleanContext(session: vscode.DebugSession) {
46
            if (session.type === 'brightscript') {
5✔
47
                void vscodeContextManager.set('brightscript.tracingEnabled', false);
4✔
48
                void vscodeContextManager.set('brightscript.tracingActive', false);
4✔
49
                void vscodeContextManager.set('brightscript.heapSnapshotActive', false);
4✔
50
            }
51
        }
52
        //hide profiling-related buttons at the start and end of the session
53
        context.subscriptions.push(vscode.debug.onDidStartDebugSession(cleanContext));
45✔
54
        context.subscriptions.push(vscode.debug.onDidTerminateDebugSession(cleanContext));
45✔
55

56
        // Start tracing
57
        context.subscriptions.push(
45✔
58
            vscode.commands.registerCommand('extension.brightscript.startTracing',
59
                async () => {
60
                    const session = vscode.debug.activeDebugSession;
8✔
61

62
                    if (!session) {
8✔
63
                        void vscode.window.showErrorMessage(`Cannot start tracing: there's no active debug session`);
1✔
64
                        return;
1✔
65
                    }
66

67
                    try {
7✔
68
                        await session.customRequest('startPerfettoTracing');
7✔
69
                        await vscodeContextManager.set('brightscript.tracingActive', true);
6✔
70
                    } catch (e) {
71
                        console.error(`Failed to start tracing`, e);
1✔
72
                    }
73
                }
74
            )
75
        );
76

77
        // Stop tracing
78
        context.subscriptions.push(
45✔
79
            vscode.commands.registerCommand('extension.brightscript.stopTracing',
80
                async () => {
81
                    const session = vscode.debug.activeDebugSession;
5✔
82
                    if (!session) {
5✔
83
                        return;
1✔
84
                    }
85

86
                    try {
4✔
87
                        await session.customRequest('stopPerfettoTracing');
4✔
88
                    } catch (e) {
89
                        console.error(`Failed to stop tracing:`, e);
1✔
90
                    }
91
                }
92
            )
93
        );
94

95
        async function captureHeapSnapshot() {
96
            const session = vscode.debug.activeDebugSession;
12✔
97

98
            if (!session) {
12✔
99
                void vscode.window.showErrorMessage(`Cannot capture heap snapshot: there's no active debug session`);
1✔
100
                return;
1✔
101
            }
102

103
            try {
11✔
104
                await session.customRequest('captureHeapSnapshot');
11✔
105
            } catch (e) {
106
                console.error(`Failed to capture snapshot:`, e);
1✔
107
            }
108
        }
109

110
        // Start capturing snapshot
111
        context.subscriptions.push(
45✔
112
            vscode.commands.registerCommand('extension.brightscript.captureHeapSnapshot', captureHeapSnapshot)
113
        );
114

115
        // Register capturing snapshot button (disabled, shows "Capturing snapshot..." tooltip when clicked)
116
        context.subscriptions.push(
45✔
117
            vscode.commands.registerCommand('extension.brightscript.heapSnapshotActive', captureHeapSnapshot)
118
        );
119
    }
120
}
121

122
export const profilingCommands = new ProfilingCommands();
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc