| 636 | } |
| 637 | |
| 638 | export class ComponentParser implements XmlStateConsumer { |
| 639 | private static KNOWNCOLLECTIONS = 'knownCollections'; |
| 640 | private static KNOWNTEMPLATES = 'knownTemplates'; |
| 641 | private static KNOWNMULTITEMPLATES = 'knownMultiTemplates'; |
| 642 | |
| 643 | public rootComponentModule: ComponentModule; |
| 644 | |
| 645 | private context: any; |
| 646 | |
| 647 | private currentRootView: View; |
| 648 | private parents = new Array<ComponentModule>(); |
| 649 | private complexProperties = new Array<ComponentParser.ComplexProperty>(); |
| 650 | |
| 651 | private error: ErrorFormatter; |
| 652 | private sourceTracker: SourceTracker; |
| 653 | |
| 654 | constructor( |
| 655 | context: any, |
| 656 | errorFormat: ErrorFormatter, |
| 657 | sourceTracker: SourceTracker, |
| 658 | private moduleName?: string, |
| 659 | ) { |
| 660 | this.context = context; |
| 661 | this.error = errorFormat; |
| 662 | this.sourceTracker = sourceTracker; |
| 663 | } |
| 664 | |
| 665 | @profile |
| 666 | private buildComponent(args: xml.ParserEvent): ComponentModule { |
| 667 | if (args.prefix && args.namespace) { |
| 668 | // Custom components |
| 669 | return loadCustomComponent(args.namespace, args.elementName, args.attributes, this.context, this.currentRootView, !this.currentRootView, this.moduleName); |
| 670 | } else { |
| 671 | // Default components |
| 672 | let namespace = args.namespace; |
| 673 | if (defaultNameSpaceMatcher.test(namespace || '')) { |
| 674 | //Ignore the default ...tns.xsd namespace URL |
| 675 | namespace = undefined; |
| 676 | } |
| 677 | |
| 678 | return getComponentModule(args.elementName, namespace, args.attributes, this.context, this.moduleName, !this.currentRootView); |
| 679 | } |
| 680 | } |
| 681 | |
| 682 | public parse(args: xml.ParserEvent): XmlStateConsumer { |
| 683 | // Get the current parent. |
| 684 | const parent = this.parents[this.parents.length - 1]; |
| 685 | const complexProperty = this.complexProperties[this.complexProperties.length - 1]; |
| 686 | |
| 687 | // Create component instance from every element declaration. |
| 688 | if (args.eventType === xml.ParserEventType.StartElement) { |
| 689 | if (ComponentParser.isComplexProperty(args.elementName)) { |
| 690 | const name = ComponentParser.getComplexPropertyName(args.elementName); |
| 691 | |
| 692 | const complexProperty: ComponentParser.ComplexProperty = { |
| 693 | parent: parent, |
| 694 | name: name, |
| 695 | items: [], |
nothing calls this directly
no outgoing calls
no test coverage detected