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

FontoXML / fontoxpath / 6107185957

07 Sep 2023 08:15AM UTC coverage: 91.555%. Remained the same
6107185957

push

github

DrRataplan
3.30.1

4938 of 5738 branches covered (0.0%)

Branch coverage included in aggregate %.

10640 of 11277 relevant lines covered (94.35%)

97908.84 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 {
9✔
5
        public staticContext?: StaticContext;
6

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

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

17
        public getVariable(varName: string): SequenceType {
18
                for (let i = this._scopeIndex; i >= 0; i--) {
18,327✔
19
                        const variableType = this._variableScope[i][varName];
28,662✔
20
                        if (variableType) {
28,662✔
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,204✔
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,648✔
62
                        const namespaceURI = this._namespaceScope[i][prefix];
66,243✔
63
                        if (namespaceURI !== undefined) {
66,243!
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,648✔
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

© 2025 Coveralls, Inc