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

rokucommunity / brighterscript / #12931

13 Aug 2024 05:02PM UTC coverage: 86.193% (-1.7%) from 87.933%
#12931

push

web-flow
Merge 58ad447a2 into 0e968f1c3

10630 of 13125 branches covered (80.99%)

Branch coverage included in aggregate %.

6675 of 7284 new or added lines in 99 files covered. (91.64%)

84 existing lines in 18 files now uncovered.

12312 of 13492 relevant lines covered (91.25%)

26867.76 hits per line

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

92.96
/src/types/ComponentType.ts
1
import type { GetSymbolTypeOptions } from '../SymbolTable';
2
import type { SymbolTypeFlag } from '../SymbolTypeFlag';
3
import { SymbolTable } from '../SymbolTable';
1✔
4
import { isComponentType, isDynamicType, isObjectType } from '../astUtils/reflection';
1✔
5
import type { ExtraSymbolData, TypeCompatibilityData } from '../interfaces';
6
import type { BaseFunctionType } from './BaseFunctionType';
7
import type { BscType } from './BscType';
8
import { BscTypeKind } from './BscTypeKind';
1✔
9
import { BuiltInInterfaceAdder } from './BuiltInInterfaceAdder';
1✔
10
import { InheritableType } from './InheritableType';
1✔
11
import { isUnionTypeCompatible } from './helpers';
1✔
12
import util from '../util';
1✔
13

14
export class ComponentType extends InheritableType {
1✔
15

16
    constructor(public name: string, superComponent?: ComponentType) {
147,743✔
17
        super(name, superComponent);
147,743✔
18
        this.callFuncMemberTable = new SymbolTable(`${this.name}: CallFunc`, () => this.parentComponent?.callFuncMemberTable);
147,743✔
19
    }
20

21
    public readonly kind = BscTypeKind.ComponentType;
147,743✔
22

23
    public get parentComponent() {
24
        return this.parentType as ComponentType;
3✔
25
    }
26

27
    public isTypeCompatible(targetType: BscType, data?: TypeCompatibilityData) {
28
        if (this.isEqual(targetType)) {
29✔
29
            return true;
19✔
30
        } else if (isDynamicType(targetType) ||
10✔
31
            isObjectType(targetType) ||
32
            isUnionTypeCompatible(this, targetType, data)) {
33
            return true;
2✔
34
        } else if (isComponentType(targetType)) {
8!
35
            return this.isTypeDescendent(targetType);
8✔
36
        }
NEW
37
        return false;
×
38
    }
39

40
    public static instance = new ComponentType('Node');
1✔
41

42
    isEqual(targetType: BscType): boolean {
43
        return isComponentType(targetType) && this.name.toLowerCase() === targetType.name.toLowerCase();
50✔
44
    }
45

46
    public toString() {
47
        return util.getSgNodeTypeName(this.name);
429✔
48
    }
49

50
    private builtInMemberTable: SymbolTable;
51

52
    getBuiltInMemberTable(): SymbolTable {
53
        if (!this.parentType) {
147,741✔
54
            if (this.builtInMemberTable) {
9,321!
NEW
55
                return this.builtInMemberTable;
×
56
            }
57
            this.builtInMemberTable = new SymbolTable(`${this.__identifier} Built-in Members`);
9,321✔
58
            this.pushMemberProvider(() => this.builtInMemberTable);
9,321✔
59
            return this.builtInMemberTable;
9,321✔
60
        }
61
    }
62

63

64
    addBuiltInInterfaces() {
65
        if (!this.hasAddedBuiltInInterfaces) {
286,242✔
66
            if (this.parentType) {
147,741✔
67
                this.parentType.addBuiltInInterfaces();
138,420✔
68
            }
69
            BuiltInInterfaceAdder.addBuiltInInterfacesToType(this);
147,741✔
70
        }
71
        this.hasAddedBuiltInInterfaces = true;
286,242✔
72
        this.addBuiltInFields();
286,242✔
73
    }
74

75
    private hasAddedBuiltInFields = false;
147,743✔
76

77
    addBuiltInFields() {
78
        if (!this.hasAddedBuiltInFields) {
424,643✔
79
            if (isComponentType(this.parentType)) {
147,741✔
80
                this.parentType.addBuiltInFields();
138,401✔
81
            }
82
            BuiltInInterfaceAdder.addBuiltInFieldsToNodeType(this);
147,741✔
83
        }
84
        this.hasAddedBuiltInFields = true;
424,643✔
85
    }
86

87
    public readonly callFuncMemberTable: SymbolTable;
88

89
    addCallFuncMember(name: string, data: ExtraSymbolData, type: BaseFunctionType, flags: SymbolTypeFlag) {
90
        this.callFuncMemberTable.addSymbol(name, data, type, flags);
30✔
91
    }
92

93
    getCallFuncTable() {
NEW
94
        return this.callFuncMemberTable;
×
95
    }
96

97
    getCallFuncType(name: string, options: GetSymbolTypeOptions) {
98
        return this.callFuncMemberTable.getSymbolType(name, options);
4✔
99
    }
100
}
101

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