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

FontoXML / fontoxpath / 4161802573

pending completion
4161802573

push

github

GitHub
Implement circular dependencies and partial modules

4894 of 5691 branches covered (86.0%)

Branch coverage included in aggregate %.

10517 of 11154 relevant lines covered (94.29%)

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

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

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

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

28
        public insertVariable(varName: string, varType: SequenceType): void {
29
                if (this._variableScope[this._scopeIndex][varName]) {
1,829!
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;
1,829✔
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++;
1,961✔
52
                this._variableScope.push({});
1,961✔
53
                this._namespaceScope.push({});
1,961✔
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--) {
12,204✔
62
                        const namespaceURI = this._namespaceScope[i][prefix];
22,069✔
63
                        if (namespaceURI !== undefined) {
22,069!
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;
12,204✔
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