Program: 11894
Project: 11894
Buggy source:
/** 
 * Walks the type either as an EClass or an ENum to analyze either the methods or the fields.
 */
protected void analyzeType(JType type){
  String modelAnnotation=getModelAnnotation(type.getComment());
  boolean isEClassifier=false;
  String kind=null;
  if (modelAnnotation != null) {
    kind=getModelAnnotationAttribute(modelAnnotation,"String_Node_Str");
    isEClassifier=!"String_Node_Str".equals(kind);
  }
  if (isEClassifier) {
    EPackage ePackage=getEPackage(type);
    if ((type.getFlags() & Flags.AccInterface) != 0 || "String_Node_Str".equals(kind)) {
      EClass eClass=EcoreFactory.eINSTANCE.createEClass();
      eModelElementToJNodeMap.put(eClass,type);
      eClass.setName(type.getName());
      ePackage.getEClassifiers().add(eClass);
      eClass.getEAnnotations().addAll(extractEAnnotations(modelAnnotation));
      EcoreUtil.setDocumentation(eClass,getModelDocumentation(type.getComment()));
      String[] superInterfaces=type.getSuperInterfaces();
      String extend=getExtendsAnnotation(type.getComment());
      if (extend != null && superInterfaces != null) {
        List<String> superInterfaceList=new ArrayList<String>(Arrays.asList(superInterfaces));
        for (StringTokenizer stringTokenizer=new StringTokenizer(extend,"String_Node_Str"); stringTokenizer.hasMoreTokens(); ) {
          superInterfaceList.remove(stringTokenizer.nextToken());
        }
        superInterfaces=new String[superInterfaceList.size()];
        superInterfaceList.toArray(superInterfaces);
      }
      eClassToSuperTypeNamesMap.put(eClass,superInterfaces);
      String isAbstract=getModelAnnotationAttribute(modelAnnotation,"String_Node_Str");
      eClass.setAbstract("String_Node_Str".equals(isAbstract));
      String isInterface=getModelAnnotationAttribute(modelAnnotation,"String_Node_Str");
      eClass.setInterface("String_Node_Str".equals(isInterface));
      for (      JMethod method : facadeHelper.getChildren(type,JMethod.class)) {
        analyzeMethod(eClass,method);
      }
      String features=getModelAnnotationAttribute(modelAnnotation,"String_Node_Str");
      if (features != null) {
        for (StringTokenizer stringTokenizer=new StringTokenizer(features,"String_Node_Str"); stringTokenizer.hasMoreTokens(); ) {
          String feature=stringTokenizer.nextToken();
          if (eClass.getEStructuralFeature(feature) == null) {
            analyzeMethod(eClass,getFilteredModelAnnotations(modelAnnotation,feature),"String_Node_Str" + Character.toUpperCase(feature.charAt(0)) + feature.substring(1),"String_Node_Str",null,null,null);
          }
 else {
            warning(CodeGenEcorePlugin.INSTANCE.getString("String_Node_Str",new Object[]{feature,eClass.getName()}));
          }
        }
      }
    }
 else {
      EEnum eEnum=EcoreFactory.eINSTANCE.createEEnum();
      eModelElementToJNodeMap.put(eEnum,type);
      eEnum.setName(type.getName());
      ePackage.getEClassifiers().add(eEnum);
      eEnum.getEAnnotations().addAll(extractEAnnotations(modelAnnotation));
      EcoreUtil.setDocumentation(eEnum,getModelDocumentation(type.getComment()));
      for (      JField field : facadeHelper.getChildren(type,JField.class)) {
        analyzeEnumLiteral(eEnum,field);
      }
    }
  }
 else {
    JPackage jPackage=facadeHelper.getPackage(type);
    String qualifiedPackageName=jPackage != null ? jPackage.getQualifiedName() : null;
    String typeName=type.getName();
    boolean isEPackage=false;
    if (typeName.endsWith("String_Node_Str") && typeName.length() > 7) {
      String packagePrefix=typeName.substring(0,typeName.length() - 7);
      if ("String_Node_Str".equals(kind)) {
        isEPackage=true;
      }
      int index=qualifiedPackageName == null ? -1 : qualifiedPackageName.lastIndexOf("String_Node_Str");
      @SuppressWarnings("String_Node_Str") String name=index == -1 ? qualifiedPackageName : qualifiedPackageName.substring(index + 1);
      String nsURI="String_Node_Str" + (qualifiedPackageName == null ? "String_Node_Str" : qualifiedPackageName.replace('.','/')) + "String_Node_Str";
      String nsPrefix=qualifiedPackageName == null ? "String_Node_Str" : qualifiedPackageName;
      List<EClass> eClasses=new ArrayList<EClass>();
      List<EDataType> eDataTypes=new ArrayList<EDataType>();
      Map<Object,Integer> ordering=new HashMap<Object,Integer>();
      for (      JNode node : type.getChildren()) {
        if (node instanceof JField) {
          JField field=(JField)node;
          String fieldName=field.getName();
          String fieldType=field.getType();
          if ("String_Node_Str".equals(fieldName)) {
            isEPackage=true;
            name=field.getInitializer();
            name=name.substring(1,name.length() - 1);
          }
 else           if ("String_Node_Str".equals(fieldName)) {
            isEPackage=true;
            nsURI=field.getInitializer();
            nsURI=nsURI.substring(1,nsURI.length() - 1);
          }
 else           if ("String_Node_Str".equals(fieldName)) {
            isEPackage=true;
            nsPrefix=field.getInitializer();
            nsPrefix=nsPrefix.substring(1,nsPrefix.length() - 1);
          }
 else           if ("String_Node_Str".equals(fieldType) && !fieldName.endsWith("String_Node_Str")) {
            try {
              String initializer=field.getInitializer();
              int plusIndex=initializer.lastIndexOf("String_Node_Str");
              if (plusIndex != -1) {
                initializer=initializer.substring(plusIndex + 1);
              }
              initializer=initializer.trim();
              int value=Integer.parseInt(initializer);
              ordering.put(fieldName,value);
            }
 catch (            NumberFormatException exception) {
            }
          }
        }
 else         if (node instanceof JMethod) {
          JMethod method=(JMethod)node;
          String methodAnnotation=getModelAnnotation(method.getComment());
          if (methodAnnotation != null) {
            String returnType=method.getReturnType();
            if (returnType != null) {
              if (returnType.endsWith("String_Node_Str")) {
                EDataType eDataType=EcoreFactory.eINSTANCE.createEDataType();
                eDataType.setInstanceClassName(getModelAnnotationAttribute(methodAnnotation,"String_Node_Str"));
                eDataType.setName(method.getName().substring(3));
                String isSerializable=getModelAnnotationAttribute(methodAnnotation,"String_Node_Str");
                if ("String_Node_Str".equals(isSerializable)) {
                  eDataType.setSerializable(false);
                }
                eDataTypes.add(eDataType);
                eDataType.getEAnnotations().addAll(extractEAnnotations(methodAnnotation));
                EcoreUtil.setDocumentation(eDataType,getModelDocumentation(method.getComment()));
              }
 else               if (returnType.endsWith("String_Node_Str")) {
                EClass eClass=EcoreFactory.eINSTANCE.createEClass();
                String instanceClass=getModelAnnotationAttribute(methodAnnotation,"String_Node_Str");
                if (instanceClass != null) {
                  eClass.setInterface(true);
                  eClass.setAbstract(true);
                  eClass.setInstanceClassName(instanceClass);
                  eClass.setName(method.getName().substring(3));
                  eClasses.add(eClass);
                }
 else {
                  eClass.setInstanceClassName("String_Node_Str");
                  eClass.setName(method.getName().substring(3));
                  eClasses.add(eClass);
                  String features=getModelAnnotationAttribute(methodAnnotation,"String_Node_Str");
                  if (features != null) {
                    for (StringTokenizer stringTokenizer=new StringTokenizer(features,"String_Node_Str"); stringTokenizer.hasMoreTokens(); ) {
                      String feature=stringTokenizer.nextToken();
                      analyzeMethod(eClass,getFilteredModelAnnotations(methodAnnotation,feature),"String_Node_Str" + Character.toUpperCase(feature.charAt(0)) + feature.substring(1),"String_Node_Str",null,null,null);
                    }
                  }
 else {
                    analyzeMethod(eClass,getFilteredModelAnnotations(methodAnnotation,"String_Node_Str"),"String_Node_Str","String_Node_Str",null,null,null);
                    analyzeMethod(eClass,getFilteredModelAnnotations(methodAnnotation,"String_Node_Str"),"String_Node_Str","String_Node_Str",null,null,null);
                  }
                }
                eClass.getEAnnotations().addAll(extractEAnnotations(methodAnnotation));
                EcoreUtil.setDocumentation(eClass,getModelDocumentation(method.getComment()));
              }
            }
          }
        }
      }
      if (isEPackage || !eClasses.isEmpty() || !eDataTypes.isEmpty()) {
        EPackage ePackage=EcoreFactory.eINSTANCE.createEPackage();
        ePackageToOrderingMap.put(ePackage,ordering);
        eModelElementToJNodeMap.put(ePackage,type);
        ePackage.setNsURI(nsURI);
        ePackage.setNsPrefix(nsPrefix);
        ePackage.setName(name);
        ePackage.getEClassifiers().addAll(eClasses);
        ePackage.getEClassifiers().addAll(eDataTypes);
        if (modelAnnotation != null) {
          ePackage.getEAnnotations().addAll(extractEAnnotations(modelAnnotation));
        }
        EcoreUtil.setDocumentation(ePackage,getModelDocumentation(type.getComment()));
        ePackageToPrefixMap.put(ePackage,packagePrefix);
        EPackage existingEPackage=packageNameToEPackageMap.get(qualifiedPackageName);
        if (existingEPackage != null) {
          ePackage.getEClassifiers().addAll(existingEPackage.getEClassifiers());
        }
        packageNameToEPackageMap.put(qualifiedPackageName,ePackage);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Walks the type either as an EClass or an ENum to analyze either the methods or the fields.
 */
protected void analyzeType(JType type){
  String modelAnnotation=getModelAnnotation(type.getComment());
  boolean isEClassifier=false;
  String kind=null;
  if (modelAnnotation != null) {
    kind=getModelAnnotationAttribute(modelAnnotation,"String_Node_Str");
    isEClassifier=!"String_Node_Str".equals(kind);
  }
  if (isEClassifier) {
    EPackage ePackage=getEPackage(type);
    if ((type.getFlags() & Flags.AccInterface) != 0 || "String_Node_Str".equals(kind)) {
      EClass eClass=EcoreFactory.eINSTANCE.createEClass();
      eModelElementToJNodeMap.put(eClass,type);
      eClass.setName(type.getName());
      ePackage.getEClassifiers().add(eClass);
      eClass.getEAnnotations().addAll(extractEAnnotations(modelAnnotation));
      EcoreUtil.setDocumentation(eClass,getModelDocumentation(type.getComment()));
      String[] superInterfaces=type.getSuperInterfaces();
      String extend=getExtendsAnnotation(type.getComment());
      if (extend != null && superInterfaces != null) {
        List<String> superInterfaceList=new ArrayList<String>(Arrays.asList(superInterfaces));
        for (StringTokenizer stringTokenizer=new StringTokenizer(extend,"String_Node_Str"); stringTokenizer.hasMoreTokens(); ) {
          superInterfaceList.remove(stringTokenizer.nextToken());
        }
        superInterfaces=new String[superInterfaceList.size()];
        superInterfaceList.toArray(superInterfaces);
      }
      eClassToSuperTypeNamesMap.put(eClass,superInterfaces);
      String isInterface=getModelAnnotationAttribute(modelAnnotation,"String_Node_Str");
      eClass.setInterface("String_Node_Str".equals(isInterface));
      String isAbstract=getModelAnnotationAttribute(modelAnnotation,"String_Node_Str");
      eClass.setAbstract("String_Node_Str".equals(isAbstract) || isAbstract == null && eClass.isInterface());
      for (      JMethod method : facadeHelper.getChildren(type,JMethod.class)) {
        analyzeMethod(eClass,method);
      }
      String features=getModelAnnotationAttribute(modelAnnotation,"String_Node_Str");
      if (features != null) {
        for (StringTokenizer stringTokenizer=new StringTokenizer(features,"String_Node_Str"); stringTokenizer.hasMoreTokens(); ) {
          String feature=stringTokenizer.nextToken();
          if (eClass.getEStructuralFeature(feature) == null) {
            analyzeMethod(eClass,getFilteredModelAnnotations(modelAnnotation,feature),"String_Node_Str" + Character.toUpperCase(feature.charAt(0)) + feature.substring(1),"String_Node_Str",EMPTY_STRING_ARRAY,EMPTY_STRING_ARRAY,EMPTY_STRING_ARRAY);
          }
 else {
            warning(CodeGenEcorePlugin.INSTANCE.getString("String_Node_Str",new Object[]{feature,eClass.getName()}));
          }
        }
      }
    }
 else {
      EEnum eEnum=EcoreFactory.eINSTANCE.createEEnum();
      eModelElementToJNodeMap.put(eEnum,type);
      eEnum.setName(type.getName());
      ePackage.getEClassifiers().add(eEnum);
      eEnum.getEAnnotations().addAll(extractEAnnotations(modelAnnotation));
      EcoreUtil.setDocumentation(eEnum,getModelDocumentation(type.getComment()));
      for (      JField field : facadeHelper.getChildren(type,JField.class)) {
        analyzeEnumLiteral(eEnum,field);
      }
    }
  }
 else {
    JPackage jPackage=facadeHelper.getPackage(type);
    String qualifiedPackageName=jPackage != null ? jPackage.getQualifiedName() : null;
    String typeName=type.getName();
    boolean isEPackage=false;
    if (typeName.endsWith("String_Node_Str") && typeName.length() > 7) {
      String packagePrefix=typeName.substring(0,typeName.length() - 7);
      if ("String_Node_Str".equals(kind)) {
        isEPackage=true;
      }
      int index=qualifiedPackageName == null ? -1 : qualifiedPackageName.lastIndexOf("String_Node_Str");
      @SuppressWarnings("String_Node_Str") String name=index == -1 ? qualifiedPackageName : qualifiedPackageName.substring(index + 1);
      String nsURI="String_Node_Str" + (qualifiedPackageName == null ? "String_Node_Str" : qualifiedPackageName.replace('.','/')) + "String_Node_Str";
      String nsPrefix=qualifiedPackageName == null ? "String_Node_Str" : qualifiedPackageName;
      List<EClass> eClasses=new ArrayList<EClass>();
      List<EDataType> eDataTypes=new ArrayList<EDataType>();
      Map<Object,Integer> ordering=new HashMap<Object,Integer>();
      for (      JNode node : type.getChildren()) {
        if (node instanceof JField) {
          JField field=(JField)node;
          String fieldName=field.getName();
          String fieldType=field.getType();
          if ("String_Node_Str".equals(fieldName)) {
            isEPackage=true;
            name=field.getInitializer();
            name=name.substring(1,name.length() - 1);
          }
 else           if ("String_Node_Str".equals(fieldName)) {
            isEPackage=true;
            nsURI=field.getInitializer();
            nsURI=nsURI.substring(1,nsURI.length() - 1);
          }
 else           if ("String_Node_Str".equals(fieldName)) {
            isEPackage=true;
            nsPrefix=field.getInitializer();
            nsPrefix=nsPrefix.substring(1,nsPrefix.length() - 1);
          }
 else           if ("String_Node_Str".equals(fieldType) && !fieldName.endsWith("String_Node_Str")) {
            try {
              String initializer=field.getInitializer();
              int plusIndex=initializer.lastIndexOf("String_Node_Str");
              if (plusIndex != -1) {
                initializer=initializer.substring(plusIndex + 1);
              }
              initializer=initializer.trim();
              int value=Integer.parseInt(initializer);
              ordering.put(fieldName,value);
            }
 catch (            NumberFormatException exception) {
            }
          }
        }
 else         if (node instanceof JMethod) {
          JMethod method=(JMethod)node;
          String methodAnnotation=getModelAnnotation(method.getComment());
          if (methodAnnotation != null) {
            String returnType=method.getReturnType();
            if (returnType != null) {
              if (returnType.endsWith("String_Node_Str")) {
                EDataType eDataType=EcoreFactory.eINSTANCE.createEDataType();
                eDataType.setInstanceClassName(getModelAnnotationAttribute(methodAnnotation,"String_Node_Str"));
                eDataType.setName(method.getName().substring(3));
                String isSerializable=getModelAnnotationAttribute(methodAnnotation,"String_Node_Str");
                if ("String_Node_Str".equals(isSerializable)) {
                  eDataType.setSerializable(false);
                }
                eDataTypes.add(eDataType);
                eDataType.getEAnnotations().addAll(extractEAnnotations(methodAnnotation));
                EcoreUtil.setDocumentation(eDataType,getModelDocumentation(method.getComment()));
              }
 else               if (returnType.endsWith("String_Node_Str")) {
                EClass eClass=EcoreFactory.eINSTANCE.createEClass();
                String instanceClass=getModelAnnotationAttribute(methodAnnotation,"String_Node_Str");
                if (instanceClass != null) {
                  eClass.setInterface(true);
                  eClass.setAbstract(true);
                  eClass.setInstanceClassName(instanceClass);
                  eClass.setName(method.getName().substring(3));
                  eClasses.add(eClass);
                }
 else {
                  eClass.setInstanceClassName("String_Node_Str");
                  eClass.setName(method.getName().substring(3));
                  eClasses.add(eClass);
                  String features=getModelAnnotationAttribute(methodAnnotation,"String_Node_Str");
                  if (features != null) {
                    for (StringTokenizer stringTokenizer=new StringTokenizer(features,"String_Node_Str"); stringTokenizer.hasMoreTokens(); ) {
                      String feature=stringTokenizer.nextToken();
                      analyzeMethod(eClass,getFilteredModelAnnotations(methodAnnotation,feature),"String_Node_Str" + Character.toUpperCase(feature.charAt(0)) + feature.substring(1),"String_Node_Str",EMPTY_STRING_ARRAY,EMPTY_STRING_ARRAY,EMPTY_STRING_ARRAY);
                    }
                  }
 else {
                    analyzeMethod(eClass,getFilteredModelAnnotations(methodAnnotation,"String_Node_Str"),"String_Node_Str","String_Node_Str",EMPTY_STRING_ARRAY,EMPTY_STRING_ARRAY,EMPTY_STRING_ARRAY);
                    analyzeMethod(eClass,getFilteredModelAnnotations(methodAnnotation,"String_Node_Str"),"String_Node_Str","String_Node_Str",EMPTY_STRING_ARRAY,EMPTY_STRING_ARRAY,EMPTY_STRING_ARRAY);
                  }
                }
                eClass.getEAnnotations().addAll(extractEAnnotations(methodAnnotation));
                EcoreUtil.setDocumentation(eClass,getModelDocumentation(method.getComment()));
              }
            }
          }
        }
      }
      if (isEPackage || !eClasses.isEmpty() || !eDataTypes.isEmpty()) {
        EPackage ePackage=EcoreFactory.eINSTANCE.createEPackage();
        ePackageToOrderingMap.put(ePackage,ordering);
        eModelElementToJNodeMap.put(ePackage,type);
        ePackage.setNsURI(nsURI);
        ePackage.setNsPrefix(nsPrefix);
        ePackage.setName(name);
        ePackage.getEClassifiers().addAll(eClasses);
        ePackage.getEClassifiers().addAll(eDataTypes);
        if (modelAnnotation != null) {
          ePackage.getEAnnotations().addAll(extractEAnnotations(modelAnnotation));
        }
        EcoreUtil.setDocumentation(ePackage,getModelDocumentation(type.getComment()));
        ePackageToPrefixMap.put(ePackage,packagePrefix);
        EPackage existingEPackage=packageNameToEPackageMap.get(qualifiedPackageName);
        if (existingEPackage != null) {
          ePackage.getEClassifiers().addAll(existingEPackage.getEClassifiers());
        }
        packageNameToEPackageMap.put(qualifiedPackageName,ePackage);
      }
    }
  }
}