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

FontoXML / fontoxpath / 3950402240

pending completion
3950402240

Pull #572

github

GitHub
Merge 86c7961a3 into de815bf32
Pull Request #572: Update dependencies

4882 of 5680 branches covered (85.95%)

Branch coverage included in aggregate %.

10480 of 11118 relevant lines covered (94.26%)

97761.7 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;
15,177✔
9
        private _variableScope: { [key: string]: SequenceType }[];
10

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

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