This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 271381
Collapse All | Expand All

(-)a/xml.schema.completion/src/org/netbeans/modules/xml/schema/completion/util/CompletionUtil.java (-3 / +27 lines)
Lines 609-615 Link Here
609
        
609
        
610
        AXIComponent child = null;
610
        AXIComponent child = null;
611
        for(QName qname : path) {
611
        for(QName qname : path) {
612
            child = findChildElement(parent, qname);
612
            child = findChildElement(parent, qname,context);
613
            parent = child;
613
            parent = child;
614
        }
614
        }
615
        
615
        
Lines 620-626 Link Here
620
    }
620
    }
621
    
621
    
622
    private static AXIComponent findChildElement(AXIComponent parent,
622
    private static AXIComponent findChildElement(AXIComponent parent,
623
            QName qname) {
623
            QName qname, CompletionContextImpl context) {
624
        if(parent == null)
624
        if(parent == null)
625
            return null;
625
            return null;
626
        for(AXIComponent element : parent.getChildElements()) {
626
        for(AXIComponent element : parent.getChildElements()) {
Lines 630-636 Link Here
630
            Element e = (Element)element;
630
            Element e = (Element)element;
631
            if(qname.getLocalPart().equals(e.getName()))
631
            if(qname.getLocalPart().equals(e.getName()))
632
                return element;
632
                return element;
633
            
634
             if(e.isReference()){
635
                Element ref=e.getReferent();
636
                if(qname.getLocalPart().equals(ref.getName())){
637
                    return ref;
638
                }
639
                // check substitutions
640
                AXIModel model = ref.getModel();
641
                String nsUri = ref.getTargetNamespace();
642
                String localName = ref.getName();
643
                for (CompletionModel completionModel : context.getCompletionModels()) {
644
                    SchemaModel schemaModel = completionModel.getSchemaModel();
645
                    Set<GlobalElement> substitutions = FindSubstitutions.resolveSubstitutions(schemaModel, nsUri, localName);
646
                    for (GlobalElement substitution : substitutions) {
647
                        AXIComponent substitutionElement = getAxiComponent(model, substitution);
648
                        if(substitutionElement instanceof Element){
649
                            if(qname.getLocalPart().equals(((Element)substitutionElement).getName())){
650
                                return substitutionElement;
651
                            }
652
                        }
653
                    }
654
                }
655
            }
633
        }
656
        }
657
        
634
        for (AXIComponent c : parent.getChildren()) {
658
        for (AXIComponent c : parent.getChildren()) {
635
            if (c instanceof SchemaReference) {
659
            if (c instanceof SchemaReference) {
636
                SchemaReference ref = (SchemaReference)c;
660
                SchemaReference ref = (SchemaReference)c;
Lines 639-645 Link Here
639
                try {
663
                try {
640
                    model = in.resolveReferencedModel();
664
                    model = in.resolveReferencedModel();
641
                    AXIModel am = AXIModelFactory.getDefault().getModel(model);
665
                    AXIModel am = AXIModelFactory.getDefault().getModel(model);
642
                    AXIComponent check = findChildElement(am.getRoot(), qname);
666
                    AXIComponent check = findChildElement(am.getRoot(), qname,context);
643
                    if (check != null) {
667
                    if (check != null) {
644
                        return check;
668
                        return check;
645
                    }
669
                    }

Return to bug 271381