• 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

75.0
/src/LogDocumentLinkProvider.ts
1
import * as path from 'path';
1✔
2
import * as rokuDeploy from 'roku-deploy';
1✔
3
import { DocumentLink, Position, Range } from 'vscode';
1✔
4
import * as vscode from 'vscode';
1✔
5
import BrightscriptFileUtils from './BrightScriptFileUtils';
1✔
6
import type { BrightScriptLaunchConfiguration } from './DebugConfigurationProvider';
7

8
export class CustomDocumentLink {
1✔
9
    constructor(outputLine: number, startChar: number, length: number, pkgPath: string, lineNumber: number, filename: string) {
10
        this.outputLine = outputLine;
27✔
11
        this.startChar = startChar;
27✔
12
        this.length = length;
27✔
13
        this.pkgPath = pkgPath;
27✔
14
        this.lineNumber = lineNumber;
27✔
15
        this.filename = filename;
27✔
16
    }
17

18
    public outputLine: number;
19
    public startChar: number;
20
    public length: number;
21
    public pkgPath: string;
22
    public filename: string;
23
    public lineNumber: number;
24
}
25
/**
26
 * Provides file links in any output window that has the pkg:/ format.
27
 * This only works after a debug session has started,  because the file mappings are provided in the debug launch arguments
28
 */
29
export class LogDocumentLinkProvider implements vscode.DocumentLinkProvider {
1✔
30
    constructor() {
31
        this.customLinks = [];
49✔
32
        this.fileUtils = new BrightscriptFileUtils();
49✔
33
    }
34

35
    //add import as property so it can be mocked in tests
36
    private rokuDeploy = rokuDeploy;
49✔
37
    public fileUtils: BrightscriptFileUtils;
38

39
    public async setLaunchConfig(launchConfig: BrightScriptLaunchConfiguration) {
40
        this.fileMaps = {};
1✔
41

42
        let sourceRootDir = launchConfig.sourceDirs ? launchConfig.sourceDirs : [launchConfig.rootDir];
1!
43
        let paths = [];
1✔
44
        for (const rootDir of sourceRootDir) {
1✔
45
            let pathsFromRoot = await this.rokuDeploy.getFilePaths(launchConfig.files, rootDir);
1✔
46
            paths = paths.concat(pathsFromRoot);
1✔
47
        }
48
        //get every file used in this project
49

50
        let outDir = path.normalize(launchConfig.outDir);
1✔
51

52
        //convert every path into a pkg link, which maps back to the source location of the file
53
        for (let fileMap of paths) {
1✔
54

55
            //make the dest path relative. (fileMap.dest IS already relative to pkg path, but this line doesn't hurt anything so leave it here)
56
            let pkgPath = 'pkg:/' + path.normalize(fileMap.dest).replace(outDir, '');
2✔
57
            //replace windows slashes with 'nix ones
58
            pkgPath = pkgPath.replace(/\\/g, '/');
2✔
59
            //replace double slashes with single ones
60
            pkgPath = pkgPath.replace(/\/\//g, '/');
2✔
61
            this.fileMaps[pkgPath] = {
2✔
62
                pkgPath: pkgPath,
63
                ...fileMap
64
            };
65
        }
66
    }
67

68
    public fileMaps: Record<string, { src: string; dest: string; pkgPath: string }>;
69
    public customLinks: DocumentLink[];
70

71
    public provideDocumentLinks(doc: vscode.TextDocument, token: vscode.CancellationToken) {
UNCOV
72
        return this.customLinks;
×
73
    }
74

75
    public getFileMap(pkgPath) {
UNCOV
76
        return this.fileMaps[pkgPath];
×
77
    }
78

79
    public addCustomFileLink(customLink: CustomDocumentLink) {
80
        let range = new Range(new Position(customLink.outputLine, customLink.startChar), new Position(customLink.outputLine, customLink.startChar + customLink.length));
1✔
81
        let uri = vscode.Uri.parse(`vscode://rokucommunity.brightscript/openFile/${customLink.pkgPath}#${customLink.lineNumber}`);
1✔
82
        this.customLinks.push(new DocumentLink(range, uri));
1✔
83
    }
84

85
    public addCustomPkgLink(customLink: CustomDocumentLink) {
86
        let fileMap = this.getFileMap(customLink.pkgPath);
2✔
87
        if (fileMap) {
2!
88
            let range = new Range(new Position(customLink.outputLine, customLink.startChar), new Position(customLink.outputLine, customLink.startChar + customLink.length));
2✔
89
            let uri = vscode.Uri.parse(`vscode://rokucommunity.brightscript/openFile/${customLink.pkgPath}#${customLink.lineNumber}`);
2✔
90
            this.customLinks.push(new DocumentLink(range, uri));
2✔
91
        } else {
UNCOV
92
            console.log('could not find matching file for link with path ' + customLink.pkgPath);
×
93
        }
94
    }
95

96
    public resetCustomLinks() {
97
        this.customLinks = [];
152✔
98
    }
99

100
    public convertPkgPathToFsPath(pkgPath: string) {
UNCOV
101
        let mappedPath = this.getFileMap(pkgPath);
×
UNCOV
102
        if (!mappedPath) {
×
103
            //if a .brs file gets in here, that comes from a .brs file, but no sourcemap is present, then try to find the alternate source file.
104
            //this issue can arise when sourcemaps are nto present
105
            mappedPath = this.getFileMap(this.fileUtils.getAlternateBrsFileName(pkgPath));
×
106
        }
UNCOV
107
        return mappedPath ? mappedPath.src : undefined;
×
108
    }
109
}
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