Program: 15806
Project: 15806
Buggy source:
/** 
 * Parse an component definition specified in the given element.
 * @param bNativeContent whether to consider the child elements all nativeIt is true if a component definition with text-as is found
 * @return native item for optimization
 */
private Object parseItem(PageDefinition pgdef,NodeInfo parent,Element el,AnnotationHelper annHelper,boolean bNativeContent,ParsingState parsingState) throws Exception {
  final String nm=el.getLocalName();
  final Namespace ns=el.getNamespace();
  final String pref=ns != null ? ns.getPrefix() : "String_Node_Str";
  final String uri=ns != null ? ns.getURI() : "String_Node_Str";
  LanguageDefinition langdef=pgdef.getLanguageDefinition();
  final String langName=langdef.getName();
  if (LanguageDefinition.ANNOTATION_NAMESPACE.equals(uri) || "String_Node_Str".equals(uri))   throw new UiException(message("String_Node_Str" + uri + "String_Node_Str",el));
  if (parsingState != ParsingState.SECOND) {
    if ("String_Node_Str".equals(nm) && isZkElement(langdef,nm,pref,uri,bNativeContent)) {
      if (!(parent instanceof ComponentInfo))       throw new UiException(message("String_Node_Str",el));
      parseAttribute(pgdef,(ComponentInfo)parent,el,annHelper);
    }
 else     if ("String_Node_Str".equals(nm) && isZkElement(langdef,nm,pref,uri,bNativeContent)) {
      parseItems(pgdef,parseTemplate(parent,el,annHelper),el.getChildren(),annHelper,bNativeContent);
    }
  }
  if (parsingState != ParsingState.FIRST) {
    if ("String_Node_Str".equals(nm) || "String_Node_Str".equals(nm))     return null;
    if ("String_Node_Str".equals(nm) && isZkElement(langdef,nm,pref,uri)) {
      checkZScriptEnabled(el);
      parseZScript(parent,el,annHelper);
    }
 else     if ("String_Node_Str".equals(nm) && isZkElement(langdef,nm,pref,uri,bNativeContent)) {
      parseCustomAttributes(langdef,parent,el,annHelper);
    }
 else     if ("String_Node_Str".equals(nm) && isZkElement(langdef,nm,pref,uri,bNativeContent)) {
      parseVariables(langdef,parent,el,annHelper);
    }
 else     if ("String_Node_Str".equals(nm) && isZkElement(langdef,nm,pref,uri)) {
      parseItems(pgdef,parseZk(parent,el,annHelper),el.getChildren(),annHelper,bNativeContent);
    }
 else     if (isShadowElement(langdef,pgdef,nm,pref,uri,bNativeContent)) {
      parseItems(pgdef,parseShadowElement(pgdef,parent,el,annHelper),el.getChildren(),annHelper,bNativeContent);
    }
 else {
      if (isZkSwitch(parent))       throw new UiException(message("String_Node_Str",el));
      boolean prefRequired=uri.startsWith(LanguageDefinition.NATIVE_NAMESPACE_PREFIX);
      boolean bNative=bNativeContent || prefRequired || LanguageDefinition.NATIVE_NAMESPACE.equals(uri)|| "String_Node_Str".equals(uri);
      if (!bNative && langdef.isNative() && !langdef.getNamespace().equals(uri))       bNative=prefRequired=("String_Node_Str".equals(pref) && "String_Node_Str".equals(uri)) || !LanguageDefinition.exists(uri);
      final ComponentInfo compInfo;
      if (bNative) {
        if (annHelper.clear())         log.warn(message("String_Node_Str",el));
        final NativeInfo ni;
        compInfo=ni=new NativeInfo(parent,langdef.getNativeDefinition(),prefRequired && pref.length() > 0 ? pref + "String_Node_Str" + nm : nm);
        final Collection<Namespace> dns=el.getDeclaredNamespaces();
        if (!dns.isEmpty())         addDeclaredNamespace(ni,dns,langdef);
      }
 else {
        final boolean defaultNS=isDefaultNS(langdef,pref,uri);
        final LanguageDefinition complangdef=defaultNS ? langdef : LanguageDefinition.lookup(uri);
        ComponentDefinition compdef=defaultNS ? pgdef.getComponentDefinitionMap().get(nm) : null;
        if (compdef != null) {
          compInfo=new ComponentInfo(parent,compdef,nm);
        }
 else         if (complangdef.hasComponentDefinition(nm)) {
          compdef=complangdef.getComponentDefinition(nm);
          compInfo=new ComponentInfo(parent,compdef,nm);
          langdef=complangdef;
        }
 else {
          compdef=complangdef.getDynamicTagDefinition();
          if (compdef == null)           throw new DefinitionNotFoundException(message("String_Node_Str" + nm + "String_Node_Str"+ complangdef,el));
          compInfo=new ComponentInfo(parent,compdef,nm);
          langdef=complangdef;
        }
        String use=el.getAttributeValue("String_Node_Str");
        if (use != null) {
          use=use.trim();
          if (use.length() != 0)           compInfo.setImplementation(use);
        }
      }
      String ifc=null, unless=null, forEach=null, forEachBegin=null, forEachEnd=null, forEachStep=null;
      AnnotationHelper attrAnnHelper=null;
      boolean isMVVM=false;
      for (      final Attribute attr : el.getAttributeItems()) {
        final Namespace attrns=attr.getNamespace();
        final String attURI=attrns != null ? attrns.getURI() : "String_Node_Str";
        final String attnm=attr.getLocalName();
        final String attval=attr.getValue();
        final String attPref=attrns != null ? attrns.getPrefix() : "String_Node_Str";
        if (isNativeNamespace(uri) || isXmlNamespace(uri) || "String_Node_Str".equals(langName)|| "String_Node_Str".equals(langName)) {
          if (!isZkAttr(langdef,attrns) && !isZKNamespace(attURI) && !"String_Node_Str".equals(attPref)&& !("String_Node_Str".equals(attnm) && "String_Node_Str".equals(attPref))&& !"String_Node_Str".equals(attURI)) {
            boolean handled=false;
            for (            NamespaceParser nsParser : _nsParsers) {
              if (nsParser.isMatched(attURI)) {
                if (nsParser.parse(attr,compInfo,pgdef)) {
                  handled=true;
                  break;
                }
              }
            }
            if (!handled) {
              compInfo.addProperty(attr.getName(),attval,null);
            }
            continue;
          }
 else           if (isClientNamespace(attURI) || isClientAttrNamespace(attURI)) {
            compInfo.addProperty(attnm,attval,null);
            continue;
          }
        }
        if ("String_Node_Str".equals(attnm) && isZkAttr(langdef,attrns)) {
          compInfo.setApply(attval);
        }
 else         if ("String_Node_Str".equals(attnm) && isZkAttr(langdef,attrns)) {
          compInfo.setForward(attval);
        }
 else         if ("String_Node_Str".equals(attnm) && isZkAttr(langdef,attrns)) {
          ifc=attval;
        }
 else         if ("String_Node_Str".equals(attnm) && isZkAttr(langdef,attrns)) {
          unless=attval;
        }
 else         if ("String_Node_Str".equals(attnm) && isZkAttr(langdef,attrns)) {
          forEach=attval;
        }
 else         if ("String_Node_Str".equals(attnm) && isZkAttr(langdef,attrns)) {
          forEachStep=attval;
        }
 else         if ("String_Node_Str".equals(attnm) && isZkAttr(langdef,attrns)) {
          forEachBegin=attval;
        }
 else         if ("String_Node_Str".equals(attnm) && isZkAttr(langdef,attrns)) {
          forEachEnd=attval;
        }
 else         if ("String_Node_Str".equals(attnm) && isZkAttr(langdef,attrns,bNativeContent)) {
          compInfo.setFulfill(attval);
        }
 else         if (LanguageDefinition.ANNOTATION_NAMESPACE.equals(attURI) || "String_Node_Str".equals(attURI)) {
          if (attrAnnHelper == null)           attrAnnHelper=new AnnotationHelper();
          applyAttrAnnot(attrAnnHelper,compInfo,attnm,attval.trim(),true,location(attr));
        }
 else         if (!"String_Node_Str".equals(attnm) || !isZkAttr(langdef,attrns,bNativeContent)) {
          final String attvaltrim;
          if (!"String_Node_Str".equals(attPref) && !("String_Node_Str".equals(attnm) && "String_Node_Str".equals(attPref)) && !"String_Node_Str".equals(attURI)) {
            if (!bNativeContent && !bNative && (attURI.length() == 0 || LanguageDefinition.ZK_NAMESPACE.endsWith(attURI))&& AnnotationHelper.isAnnotation(attvaltrim=attval.trim())) {
              if (attrAnnHelper == null)               attrAnnHelper=new AnnotationHelper();
              applyAttrAnnot(attrAnnHelper,compInfo,attnm,attvaltrim,true,location(attr));
              Configuration config=WebApps.getCurrent().getConfiguration();
              if (config.getBinderInitAttribute().equals(attnm))               isMVVM=true;
              Set<String> binderAnnotations=config.getBinderAnnotations();
              for (              String annot : binderAnnotations) {
                if (attvaltrim.contains(annot)) {
                  compInfo.enableBindingAnnotation();
                  break;
                }
              }
            }
 else {
              boolean handled=false;
              for (              NamespaceParser nsParser : _nsParsers) {
                if (nsParser.isMatched(attURI)) {
                  if (nsParser.parse(attr,compInfo,pgdef)) {
                    handled=true;
                    break;
                  }
                }
              }
              if (!handled) {
                addAttribute(compInfo,attrns,attnm,attval,null,attr.getLocator());
                if (attrAnnHelper != null)                 attrAnnHelper.applyAnnotations(compInfo,attnm,true);
              }
            }
          }
        }
      }
      if (isMVVM) {
        String apply=compInfo.getApply();
        String bindComposerStr="String_Node_Str";
        if (apply != null && apply.contains(bindComposerStr) && !apply.contains("String_Node_Str")) {
          log.warn(message("String_Node_Str" + bindComposerStr + "String_Node_Str"+ "String_Node_Str"+ bindComposerStr+ "String_Node_Str",el));
        }
 else         if (apply == null || apply.length() == 0) {
          compInfo.setApply(bindComposerStr);
        }
      }
      compInfo.setCondition(ConditionImpl.getInstance(ifc,unless));
      compInfo.setForEach(forEach,forEachBegin,forEachEnd,forEachStep);
      annHelper.applyAnnotations(compInfo,null,true);
      if (compInfo.getAnnotationMap() != null && el.getLocator() != null) {
        compInfo.addAnnotation(null,"String_Node_Str",null,Locators.toLocation(el.getLocator()));
      }
      final Collection<Item> items=el.getChildren();
      String textAs=null;
      if (!bNativeContent && !items.isEmpty() && (textAs=compInfo.getTextAs()) != null) {
        if (compInfo.isChildAllowedInTextAs() || !textAsAllowed(langdef,items,bNativeContent))         textAs=null;
      }
      if (textAs != null)       parseAsProperty(pgdef,compInfo,textAs,items,annHelper,null);
 else       parseItems(pgdef,compInfo,items,annHelper,bNativeContent);
      if (compInfo instanceof NativeInfo && !compInfo.getChildren().isEmpty()) {
        optimizeNativeInfos((NativeInfo)compInfo);
        return compInfo;
      }
    }
  }
  return null;
}

Fixed version (ground truth):
/** 
 * Parse an component definition specified in the given element.
 * @param bNativeContent whether to consider the child elements all nativeIt is true if a component definition with text-as is found
 * @return native item for optimization
 */
private Object parseItem(PageDefinition pgdef,NodeInfo parent,Element el,AnnotationHelper annHelper,boolean bNativeContent,ParsingState parsingState) throws Exception {
  final String nm=el.getLocalName();
  final Namespace ns=el.getNamespace();
  final String pref=ns != null ? ns.getPrefix() : "String_Node_Str";
  final String uri=ns != null ? ns.getURI() : "String_Node_Str";
  LanguageDefinition langdef=pgdef.getLanguageDefinition();
  final String langName=langdef.getName();
  if (LanguageDefinition.ANNOTATION_NAMESPACE.equals(uri) || "String_Node_Str".equals(uri))   throw new UiException(message("String_Node_Str" + uri + "String_Node_Str",el));
  if (parsingState != ParsingState.SECOND) {
    if ("String_Node_Str".equals(nm) && isZkElement(langdef,nm,pref,uri,bNativeContent)) {
      if (!(parent instanceof ComponentInfo))       throw new UiException(message("String_Node_Str",el));
      parseAttribute(pgdef,(ComponentInfo)parent,el,annHelper);
    }
 else     if ("String_Node_Str".equals(nm) && isZkElement(langdef,nm,pref,uri,bNativeContent)) {
      parseItems(pgdef,parseTemplate(parent,el,annHelper),el.getChildren(),annHelper,bNativeContent);
    }
  }
  if (parsingState != ParsingState.FIRST) {
    if ("String_Node_Str".equals(nm) || "String_Node_Str".equals(nm))     return null;
    if ("String_Node_Str".equals(nm) && isZkElement(langdef,nm,pref,uri)) {
      checkZScriptEnabled(el);
      parseZScript(parent,el,annHelper);
    }
 else     if ("String_Node_Str".equals(nm) && isZkElement(langdef,nm,pref,uri,bNativeContent)) {
      parseCustomAttributes(langdef,parent,el,annHelper);
    }
 else     if ("String_Node_Str".equals(nm) && isZkElement(langdef,nm,pref,uri,bNativeContent)) {
      parseVariables(langdef,parent,el,annHelper);
    }
 else     if ("String_Node_Str".equals(nm) && isZkElement(langdef,nm,pref,uri)) {
      parseItems(pgdef,parseZk(parent,el,annHelper),el.getChildren(),annHelper,bNativeContent);
    }
 else     if (isShadowElement(langdef,pgdef,nm,pref,uri,bNativeContent)) {
      NodeInfo nodeInfo=parseShadowElement(pgdef,parent,el,annHelper);
      parseItems(pgdef,nodeInfo,el.getChildren(),annHelper,bNativeContent);
      if (nodeInfo instanceof ShadowInfo && ((ShadowInfo)nodeInfo).isAnnotationNamespacedRoot()) {
        annHelper.setIgnoreAnnotNamespace(false);
      }
 else       if (nodeInfo instanceof TemplateInfo && ((TemplateInfo)nodeInfo).isAnnotationNamespacedRoot()) {
        annHelper.setIgnoreAnnotNamespace(false);
      }
    }
 else {
      if (isZkSwitch(parent))       throw new UiException(message("String_Node_Str",el));
      boolean prefRequired=uri.startsWith(LanguageDefinition.NATIVE_NAMESPACE_PREFIX);
      boolean bNative=bNativeContent || prefRequired || LanguageDefinition.NATIVE_NAMESPACE.equals(uri)|| "String_Node_Str".equals(uri);
      if (!bNative && langdef.isNative() && !langdef.getNamespace().equals(uri))       bNative=prefRequired=("String_Node_Str".equals(pref) && "String_Node_Str".equals(uri)) || !LanguageDefinition.exists(uri);
      final ComponentInfo compInfo;
      if (bNative) {
        if (annHelper.clear())         log.warn(message("String_Node_Str",el));
        final NativeInfo ni;
        compInfo=ni=new NativeInfo(parent,langdef.getNativeDefinition(),prefRequired && pref.length() > 0 ? pref + "String_Node_Str" + nm : nm);
        final Collection<Namespace> dns=el.getDeclaredNamespaces();
        if (!dns.isEmpty())         addDeclaredNamespace(ni,dns,langdef);
      }
 else {
        final boolean defaultNS=isDefaultNS(langdef,pref,uri);
        final LanguageDefinition complangdef=defaultNS ? langdef : LanguageDefinition.lookup(uri);
        ComponentDefinition compdef=defaultNS ? pgdef.getComponentDefinitionMap().get(nm) : null;
        if (compdef != null) {
          compInfo=new ComponentInfo(parent,compdef,nm);
        }
 else         if (complangdef.hasComponentDefinition(nm)) {
          compdef=complangdef.getComponentDefinition(nm);
          compInfo=new ComponentInfo(parent,compdef,nm);
          langdef=complangdef;
        }
 else {
          compdef=complangdef.getDynamicTagDefinition();
          if (compdef == null)           throw new DefinitionNotFoundException(message("String_Node_Str" + nm + "String_Node_Str"+ complangdef,el));
          compInfo=new ComponentInfo(parent,compdef,nm);
          langdef=complangdef;
        }
        String use=el.getAttributeValue("String_Node_Str");
        if (use != null) {
          use=use.trim();
          if (use.length() != 0)           compInfo.setImplementation(use);
        }
      }
      String ifc=null, unless=null, forEach=null, forEachBegin=null, forEachEnd=null, forEachStep=null;
      AnnotationHelper attrAnnHelper=null;
      boolean isMVVM=false;
      boolean _shouldIgnoreAnnotNamespace=annHelper.shouldIgnoreAnnotNamespace();
      for (      final Attribute attr : el.getAttributeItems()) {
        final Namespace attrns=attr.getNamespace();
        final String attURI=attrns != null ? attrns.getURI() : "String_Node_Str";
        final String attnm=attr.getLocalName();
        final String attval=attr.getValue();
        final String attPref=attrns != null ? attrns.getPrefix() : "String_Node_Str";
        if (isNativeNamespace(uri) || isXmlNamespace(uri) || "String_Node_Str".equals(langName)|| "String_Node_Str".equals(langName)) {
          if (!isZkAttr(langdef,attrns) && !isZKNamespace(attURI) && !"String_Node_Str".equals(attPref)&& !("String_Node_Str".equals(attnm) && "String_Node_Str".equals(attPref))&& !"String_Node_Str".equals(attURI)) {
            boolean handled=false;
            for (            NamespaceParser nsParser : _nsParsers) {
              if (nsParser.isMatched(attURI)) {
                if (nsParser.parse(attr,compInfo,pgdef)) {
                  handled=true;
                  break;
                }
              }
            }
            if (!handled) {
              compInfo.addProperty(attr.getName(),attval,null);
            }
            continue;
          }
 else           if (isClientNamespace(attURI) || isClientAttrNamespace(attURI)) {
            compInfo.addProperty(attnm,attval,null);
            continue;
          }
        }
        if ("String_Node_Str".equals(attnm) && isZkAttr(langdef,attrns)) {
          compInfo.setApply(attval);
        }
 else         if ("String_Node_Str".equals(attnm) && isZkAttr(langdef,attrns)) {
          compInfo.setForward(attval);
        }
 else         if ("String_Node_Str".equals(attnm) && isZkAttr(langdef,attrns)) {
          ifc=attval;
        }
 else         if ("String_Node_Str".equals(attnm) && isZkAttr(langdef,attrns)) {
          unless=attval;
        }
 else         if ("String_Node_Str".equals(attnm) && isZkAttr(langdef,attrns)) {
          forEach=attval;
        }
 else         if ("String_Node_Str".equals(attnm) && isZkAttr(langdef,attrns)) {
          forEachStep=attval;
        }
 else         if ("String_Node_Str".equals(attnm) && isZkAttr(langdef,attrns)) {
          forEachBegin=attval;
        }
 else         if ("String_Node_Str".equals(attnm) && isZkAttr(langdef,attrns)) {
          forEachEnd=attval;
        }
 else         if ("String_Node_Str".equals(attnm) && isZkAttr(langdef,attrns,bNativeContent)) {
          compInfo.setFulfill(attval);
        }
 else         if (!_shouldIgnoreAnnotNamespace && (LanguageDefinition.ANNOTATION_NAMESPACE.equals(attURI) || "String_Node_Str".equals(attURI))) {
          if (attrAnnHelper == null)           attrAnnHelper=new AnnotationHelper();
          applyAttrAnnot(attrAnnHelper,compInfo,attnm,attval.trim(),true,location(attr));
        }
 else         if (!"String_Node_Str".equals(attnm) || !isZkAttr(langdef,attrns,bNativeContent)) {
          final String attvaltrim;
          if (!"String_Node_Str".equals(attPref) && !("String_Node_Str".equals(attnm) && "String_Node_Str".equals(attPref)) && !"String_Node_Str".equals(attURI)) {
            if (!bNativeContent && !bNative && (_shouldIgnoreAnnotNamespace || (attURI.length() == 0 || LanguageDefinition.ZK_NAMESPACE.endsWith(attURI)))&& AnnotationHelper.isAnnotation(attvaltrim=attval.trim())) {
              if (attrAnnHelper == null)               attrAnnHelper=new AnnotationHelper();
              applyAttrAnnot(attrAnnHelper,compInfo,attnm,attvaltrim,true,location(attr));
              Configuration config=WebApps.getCurrent().getConfiguration();
              if (config.getBinderInitAttribute().equals(attnm))               isMVVM=true;
              Set<String> binderAnnotations=config.getBinderAnnotations();
              for (              String annot : binderAnnotations) {
                if (attvaltrim.contains(annot)) {
                  compInfo.enableBindingAnnotation();
                  break;
                }
              }
            }
 else {
              boolean handled=false;
              for (              NamespaceParser nsParser : _nsParsers) {
                if (nsParser.isMatched(attURI)) {
                  if (nsParser.parse(attr,compInfo,pgdef)) {
                    handled=true;
                    break;
                  }
                }
              }
              if (!handled) {
                addAttribute(compInfo,attrns,attnm,attval,null,attr.getLocator());
                if (attrAnnHelper != null)                 attrAnnHelper.applyAnnotations(compInfo,attnm,true);
              }
            }
          }
        }
      }
      if (isMVVM) {
        String apply=compInfo.getApply();
        String bindComposerStr="String_Node_Str";
        if (apply != null && apply.contains(bindComposerStr) && !apply.contains("String_Node_Str")) {
          log.warn(message("String_Node_Str" + bindComposerStr + "String_Node_Str"+ "String_Node_Str"+ bindComposerStr+ "String_Node_Str",el));
        }
 else         if (apply == null || apply.length() == 0) {
          compInfo.setApply(bindComposerStr);
        }
      }
      compInfo.setCondition(ConditionImpl.getInstance(ifc,unless));
      compInfo.setForEach(forEach,forEachBegin,forEachEnd,forEachStep);
      annHelper.applyAnnotations(compInfo,null,true);
      if (compInfo.getAnnotationMap() != null && el.getLocator() != null) {
        compInfo.addAnnotation(null,"String_Node_Str",null,Locators.toLocation(el.getLocator()));
      }
      final Collection<Item> items=el.getChildren();
      String textAs=null;
      if (!bNativeContent && !items.isEmpty() && (textAs=compInfo.getTextAs()) != null) {
        if (compInfo.isChildAllowedInTextAs() || !textAsAllowed(langdef,items,bNativeContent))         textAs=null;
      }
      if (textAs != null)       parseAsProperty(pgdef,compInfo,textAs,items,annHelper,null);
 else       parseItems(pgdef,compInfo,items,annHelper,bNativeContent);
      if (compInfo instanceof NativeInfo && !compInfo.getChildren().isEmpty()) {
        optimizeNativeInfos((NativeInfo)compInfo);
        return compInfo;
      }
    }
  }
  return null;
}