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

FontoXML / fontoxpath / 10315429919

09 Aug 2024 07:30AM UTC coverage: 91.567%. Remained the same
10315429919

push

github

DrRataplan
Add test for atomizing DocumentFragments

5002 of 5811 branches covered (86.08%)

Branch coverage included in aggregate %.

10775 of 11419 relevant lines covered (94.36%)

96658.81 hits per line

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

65.79
/src/typeInference/AnnotationContext.ts
1
import { SequenceType } from '../expressions/dataTypes/Value';
2
import StaticContext from '../expressions/StaticContext';
3

4
export class AnnotationContext {
15✔
5
        public staticContext?: StaticContext;
6

7
        private _namespaceScope: { [prefix: string]: string }[];
8
        private _scopeIndex: number = 0;
16,186✔
9
        private _variableScope: { [key: string]: SequenceType }[];
10

11
        constructor(staticContext?: StaticContext) {
12
                this.staticContext = staticContext;
16,186✔
13
                this._variableScope = [{}];
16,186✔
14
                this._namespaceScope = [{}];
16,186✔
15
        }
16

17
        public getVariable(varName: string): SequenceType {
18
                for (let i = this._scopeIndex; i >= 0; i--) {
18,333✔
19
                        const variableType = this._variableScope[i][varName];
28,668✔
20
                        if (variableType) {
28,668✔
21
                                return variableType;
6,123✔
22
                        }
23
                }
24
                // The variable is not found, indicate this to the caller by returning undefined.
25
                return undefined;
12,210✔
26
        }
27

28
        public insertVariable(varName: string, varType: SequenceType): void {
29
                if (this._variableScope[this._scopeIndex][varName]) {
5,487!
30
                        // TODO: change the error being thrown in here to adhere the "error code" code.
31
                        throw new Error(
×
32
                                `Another variable of in the scope ${this._scopeIndex} with the same name ${varName} already exists`,
33
                        );
34
                }
35

36
                this._variableScope[this._scopeIndex][varName] = varType;
5,487✔
37
        }
38

39
        public popScope(): void {
40
                if (this._scopeIndex > 0) {
×
41
                        this._scopeIndex--;
×
42
                        this._variableScope.pop();
×
43
                        this._namespaceScope.pop();
×
44
                        return;
×
45
                }
46

47
                throw new Error('Variable scope out of bound');
×
48
        }
49

50
        public pushScope(): void {
51
                this._scopeIndex++;
5,883✔
52
                this._variableScope.push({});
5,883✔
53
                this._namespaceScope.push({});
5,883✔
54
        }
55

56
        public registerNamespace(prefix: string, uri: string | null) {
57
                this._namespaceScope[this._scopeIndex][prefix] = uri;
×
58
        }
59

60
        public resolveNamespace(prefix: string): string | null {
61
                for (let i = this._scopeIndex; i >= 0; i--) {
36,663✔
62
                        const namespaceURI = this._namespaceScope[i][prefix];
66,258✔
63
                        if (namespaceURI !== undefined) {
66,258!
64
                                return namespaceURI;
×
65
                        }
66
                }
67
                // The namespace is not found. Look it up using the static context if we have it
68
                return this.staticContext ? this.staticContext.resolveNamespace(prefix) : undefined;
36,663✔
69
        }
70
}
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