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

rokucommunity / brighterscript / #15903

11 May 2026 06:41PM UTC coverage: 86.896% (-2.2%) from 89.094%
#15903

push

web-flow
Merge 70dfd6181 into ce68f5cb7

15597 of 18958 branches covered (82.27%)

Branch coverage included in aggregate %.

9 of 9 new or added lines in 3 files covered. (100.0%)

955 existing lines in 53 files now uncovered.

16351 of 17808 relevant lines covered (91.82%)

27326.16 hits per line

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

90.91
/src/XmlScope.ts
1
import { Scope } from './Scope';
1✔
2
import type { XmlFile } from './files/XmlFile';
3
import type { Program } from './Program';
4
import util from './util';
1✔
5
import { SymbolTypeFlag } from './SymbolTypeFlag';
1✔
6
import type { BscFile } from './files/BscFile';
7
import { DynamicType } from './types/DynamicType';
1✔
8
import type { BaseFunctionType } from './types/BaseFunctionType';
9
import { ComponentType } from './types/ComponentType';
1✔
10
import type { ExtraSymbolData } from './interfaces';
11

12
export class XmlScope extends Scope {
1✔
13
    constructor(
14
        public xmlFile: XmlFile,
530✔
15
        public program: Program
530✔
16
    ) {
17
        super(xmlFile.destPath, program);
530✔
18
    }
19

20
    public get dependencyGraphKey() {
21
        return this.xmlFile.dependencyGraphKey;
1,741✔
22
    }
23

24
    /**
25
     * Get the parent scope of this scope. If we could find the scope for our parentComponent, use that.
26
     * Otherwise default to global scope
27
     */
28
    public getParentScope() {
29
        return this.cache.getOrAdd('parentScope', () => {
3,971✔
30
            let scope: Scope | undefined;
31
            let parentComponentName = this.xmlFile.parentComponentName?.text;
1,015✔
32
            if (parentComponentName) {
1,015✔
33
                scope = this.program.getComponentScope(parentComponentName);
976✔
34
            }
35
            if (scope) {
1,015✔
36
                return scope;
69✔
37
            } else {
38
                return this.program.globalScope ?? null;
946!
39
            }
40
        });
41
    }
42

43
    public getComponentType() {
44
        let componentElement = this.xmlFile.ast.componentElement;
469✔
45
        if (!componentElement?.name) {
469!
UNCOV
46
            return;
×
47
        }
48
        const parentComponentType = componentElement?.extends
469!
49
            ? this.symbolTable.getSymbolType(util.getSgNodeTypeName(componentElement?.extends), { flags: SymbolTypeFlag.typetime, fullName: componentElement?.extends, tableProvider: () => this.symbolTable })
76!
50
            : undefined;
51
        const result = new ComponentType(componentElement.name, parentComponentType as ComponentType);
469✔
52
        result.addBuiltInInterfaces();
469✔
53
        const iface = componentElement.interfaceElement;
469✔
54
        if (!iface) {
469✔
55
            return result;
371✔
56
        }
57
        //add functions
58
        for (const func of iface.functions ?? []) {
98!
59
            if (func.name) {
87✔
60
                const extraData: ExtraSymbolData = {};
84✔
61
                const componentFuncType = this.symbolTable.getSymbolType(func.name, { flags: SymbolTypeFlag.runtime, data: extraData, fullName: func.name, tableProvider: () => this.symbolTable });
84✔
62
                result.addCallFuncMember(func.name, extraData, componentFuncType as BaseFunctionType, SymbolTypeFlag.runtime, () => this.symbolTable);
84✔
63
            }
64
        }
65
        //add fields
66
        for (const field of iface.fields ?? []) {
98!
67
            if (field.id) {
48✔
68
                const actualFieldType = field.type ? util.getNodeFieldType(field.type, this.symbolTable) : DynamicType.instance;
45✔
69
                //TODO: add documentation - need to get previous comment from XML
70
                result.addMember(field.id, {}, actualFieldType, SymbolTypeFlag.runtime);
45✔
71
            }
72
        }
73
        return result;
98✔
74
    }
75

76
    public getAllFiles() {
77
        return this.cache.getOrAdd('getAllFiles-xmlScope', () => {
10,385✔
78
            const allFiles = super.getAllFiles();
1,193✔
79
            allFiles.push(this.xmlFile);
1,193✔
80
            return allFiles;
1,193✔
81
        });
82
    }
83

84
    /**
85
     * Get the list of files referenced by this scope that are actually loaded in the program.
86
     * This does not account for parent scope.
87
     */
88
    public getOwnFiles() {
89
        return this.cache.getOrAdd('getOwnFiles', () => {
45,787✔
90
            let result = [
1,616✔
91
                this.xmlFile
92
            ] as BscFile[];
93
            let scriptDestPaths = this.xmlFile.getOwnDependencies();
1,616✔
94
            for (let destPath of scriptDestPaths) {
1,616✔
95
                let file = this.program.getFile(destPath, false);
4,758✔
96
                if (file) {
4,758✔
97
                    result.push(file);
2,782✔
98
                }
99
            }
100
            return result;
1,616✔
101
        });
102
    }
103
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc