Package org.junithelper.core.meta

Examples of org.junithelper.core.meta.ConstructorMeta


            cons.argNames.set(i, cons.argNames.get(i) + "_");
          }
        }
      }
      // duplicated to constructor arg names
      ConstructorMeta constructor = meta.constructors.get(0);
      for (MethodMeta method : meta.methods) {
        int len = method.argNames.size();
        for (int i = 0; i < len; i++) {
          String targetArgName = method.argNames.get(i);
          List<String> methodArgNames = new ArrayList<String>();
View Full Code Here


        .replaceAll("\\s+?>", ">");

    Matcher matcherGrouping = RegExp.PatternObject.MethodSignatureArea.matcher(sourceCodeString);
    while (matcherGrouping.find()) {

      ConstructorMeta meta = new ConstructorMeta();
      String methodSignatureArea = matcherGrouping.group(0)
          .replaceAll(StringValue.CarriageReturn, StringValue.Empty)
          .replaceAll(StringValue.LineFeed, StringValue.Space);

      // -----------------
      // access modifier
      meta.accessModifier = getAccessModifier(methodSignatureArea);

      // -----------------
      // method signature area without access modifier
      String methodSignatureAreaWithoutAccessModifier
          = trimAccessModifierFromMethodSignatureArea(methodSignatureArea);
      String matchesConstructors = RegExp.Anything_ZeroOrMore_Min
          + RegExp.WhiteSpace.Consecutive_OneOrMore_Max
          + classMeta.name + "\\(" + RegExp.Anything_ZeroOrMore_Min
          + "\\)" + RegExp.Anything_ZeroOrMore_Min;
      if (!methodSignatureAreaWithoutAccessModifier
          .matches(matchesConstructors)) {
        continue;
      }

      // -----------------
      // is constructor
      String constructorString = StringValue.Space
          + methodSignatureAreaWithoutAccessModifier;
      String groupConstructor = RegExp.WhiteSpace.Consecutive_ZeroOrMore_Max
          + classMeta.name
          + "\\(([^\\)]*?)\\)"
          + RegExp.WhiteSpace.Consecutive_ZeroOrMore_Max
          + "(throws .+)*.*?"
          + RegExp.WhiteSpace.Consecutive_ZeroOrMore_Max + "\\{.*";
      Matcher constructorMatcher = Pattern.compile(groupConstructor).matcher(constructorString);
      if (!constructorMatcher.find()) {
        continue;
      }

      // -----------------
      // args
      String argsDefAreaString = constructorMatcher.group(1);
      List<String> argArr = ArgExtractorHelper.getArgListFromArgsDefAreaString(argsDefAreaString);
      int argArrLen = argArr.size();
      for (int i = 0; i < argArrLen; i++) {
        ArgTypeMeta argTypeMeta = new ArgTypeMeta();
        String argTypeFull = argArr.get(i);
        Matcher toGenericsMatcher = Pattern.compile(RegExp.Generics_Group).matcher(argTypeFull);
        while (toGenericsMatcher.find()) {
          String[] generics = toGenericsMatcher.group()
              .replaceAll("<", StringValue.Empty)
              .replaceAll(">", StringValue.Empty)
              .split(StringValue.Comma);
          // convert to java.lang.Object if self class is included
          for (String generic : generics) {
            generic = typeNameConverter.toCompilableType(generic,
                classMeta.importedList,
                classMeta.packageName);
            argTypeMeta.generics.add(generic);
          }
        }
        String argTypeName = argTypeFull
            .replaceAll(RegExp.Generics, StringValue.Empty)
            .replaceAll("final ", StringValue.Empty)
            .split("\\s+")[0]
            .trim();
        if (argTypeName != null && !argTypeName.equals("")) {
          argTypeMeta.name = typeNameConverter.toCompilableType(
              argTypeName,
              argTypeMeta.generics,
              classMeta.importedList,
              classMeta.packageName);
          argTypeMeta.nameInMethodName = typeNameConverter.toAvailableInMethodName(argTypeMeta.name);
          meta.argTypes.add(argTypeMeta);
          Matcher nameMatcher = RegExp.PatternObject.MethodArg_Group.matcher(argTypeFull);
          if (nameMatcher.find()) {
            String argName = nameMatcher.group(1);
            if (argName.matches(".+\\[\\s*\\]")) {
              // ex. String strArr[] = null;
              String arrayPart = "";
              Matcher mat = Pattern.compile("\\[\\s*\\]").matcher(argName);
              while (mat.find()) {
                arrayPart += "[]";
              }
              argName = argName.replaceAll("\\[\\s*\\]", StringValue.Empty);
              argTypeMeta.name = argTypeMeta.name + arrayPart;
              argTypeMeta.nameInMethodName
                  = typeNameConverter.toAvailableInMethodName(argTypeMeta.name);
            }
            meta.argNames.add(argName);
          } else {
            meta.argNames.add("constructorArg" + i);
          }
        }
      }
      dest.add(meta);
    }
    if (dest.size() == 0) {
      ConstructorMeta defaultConstructorMeta = new ConstructorMeta();
      dest.add(defaultConstructorMeta);
    }
    return dest;
  }
View Full Code Here

            cons.argNames.set(i, cons.argNames.get(i) + "_");
          }
        }
      }
      // duplicated to constructor arg names
      ConstructorMeta constructor = meta.constructors.get(0);
      for (MethodMeta method : meta.methods) {
        int len = method.argNames.size();
        for (int i = 0; i < len; i++) {
          String targetArgName = method.argNames.get(i);
          List<String> methodArgNames = new ArrayList<String>();
View Full Code Here

        .replaceAll("\\s+?>", ">");

    Matcher matcherGrouping = RegExp.PatternObject.MethodSignatureArea.matcher(sourceCodeString);
    while (matcherGrouping.find()) {

      ConstructorMeta meta = new ConstructorMeta();
      String methodSignatureArea = matcherGrouping.group(0)
          .replaceAll(StringValue.CarriageReturn, StringValue.Empty)
          .replaceAll(StringValue.LineFeed, StringValue.Space);

      // -----------------
      // access modifier
      meta.accessModifier = getAccessModifier(methodSignatureArea);

      // -----------------
      // method signature area without access modifier
      String methodSignatureAreaWithoutAccessModifier
          = trimAccessModifierFromMethodSignatureArea(methodSignatureArea);
      String matchesConstructors = RegExp.Anything_ZeroOrMore_Min
          + RegExp.WhiteSpace.Consecutive_OneOrMore_Max
          + classMeta.name + "\\(" + RegExp.Anything_ZeroOrMore_Min
          + "\\)" + RegExp.Anything_ZeroOrMore_Min;
      if (!methodSignatureAreaWithoutAccessModifier
          .matches(matchesConstructors)) {
        continue;
      }

      // -----------------
      // is constructor
      String constructorString = StringValue.Space
          + methodSignatureAreaWithoutAccessModifier;
      String groupConstructor = RegExp.WhiteSpace.Consecutive_ZeroOrMore_Max
          + classMeta.name
          + "\\(([^\\)]*?)\\)"
          + RegExp.WhiteSpace.Consecutive_ZeroOrMore_Max
          + "(throws .+)*.*?"
          + RegExp.WhiteSpace.Consecutive_ZeroOrMore_Max + "\\{.*";
      Matcher constructorMatcher = Pattern.compile(groupConstructor).matcher(constructorString);
      if (!constructorMatcher.find()) {
        continue;
      }

      // -----------------
      // args
      String argsDefAreaString = constructorMatcher.group(1);
      List<String> argArr = ArgExtractorHelper.getArgListFromArgsDefAreaString(argsDefAreaString);
      int argArrLen = argArr.size();
      for (int i = 0; i < argArrLen; i++) {
        ArgTypeMeta argTypeMeta = new ArgTypeMeta();
        String argTypeFull = argArr.get(i);
        Matcher toGenericsMatcher = Pattern.compile(RegExp.Generics_Group).matcher(argTypeFull);
        while (toGenericsMatcher.find()) {
          String[] generics = toGenericsMatcher.group()
              .replaceAll("<", StringValue.Empty)
              .replaceAll(">", StringValue.Empty)
              .split(StringValue.Comma);
          // convert to java.lang.Object if self class is included
          for (String generic : generics) {
            generic = typeNameConverter.toCompilableType(generic,
                classMeta.importedList,
                classMeta.packageName);
            argTypeMeta.generics.add(generic);
          }
        }
        String argTypeName = argTypeFull
            .replaceAll(RegExp.Generics, StringValue.Empty)
            .replaceAll("final ", StringValue.Empty)
            .split("\\s+")[0]
            .trim();
        if (argTypeName != null && !argTypeName.equals("")) {
          argTypeMeta.name = typeNameConverter.toCompilableType(
              argTypeName,
              argTypeMeta.generics,
              classMeta.importedList,
              classMeta.packageName);
          argTypeMeta.nameInMethodName = typeNameConverter.toAvailableInMethodName(argTypeMeta.name);
          meta.argTypes.add(argTypeMeta);
          Matcher nameMatcher = RegExp.PatternObject.MethodArg_Group.matcher(argTypeFull);
          if (nameMatcher.find()) {
            String argName = nameMatcher.group(1);
            if (argName.matches(".+\\[\\s*\\]")) {
              // ex. String strArr[] = null;
              String arrayPart = "";
              Matcher mat = Pattern.compile("\\[\\s*\\]").matcher(argName);
              while (mat.find()) {
                arrayPart += "[]";
              }
              argName = argName.replaceAll("\\[\\s*\\]", StringValue.Empty);
              argTypeMeta.name = argTypeMeta.name + arrayPart;
              argTypeMeta.nameInMethodName
                  = typeNameConverter.toAvailableInMethodName(argTypeMeta.name);
            }
            meta.argNames.add(argName);
          } else {
            meta.argNames.add("constructorArg" + i);
          }
        }
      }
      dest.add(meta);
    }
    if (dest.size() == 0) {
      ConstructorMeta defaultConstructorMeta = new ConstructorMeta();
      dest.add(defaultConstructorMeta);
    }
    return dest;
  }
View Full Code Here

    methodMetaExtractor.initialize(classMeta, sourceCodeString);
    constructorMetaExtractor.initialize(classMeta, sourceCodeString);
    List<ConstructorMeta> constructorMetaList
        = constructorMetaExtractor.extract(sourceCodeString);
    if (constructorMetaList.size() == 0) {
      ConstructorMeta defaultConstructor = new ConstructorMeta();
      constructorMetaList.add(defaultConstructor);
    }
    return constructorMetaList;
  }
View Full Code Here

            cons.argNames.set(i, cons.argNames.get(i) + "_");
          }
        }
      }
      // duplicated to constructor arg names
      ConstructorMeta constructor = meta.constructors.get(0);
      for (MethodMeta method : meta.methods) {
        int len = method.argNames.size();
        for (int i = 0; i < len; i++) {
          String targetArgName = method.argNames.get(i);
          List<String> methodArgNames = new ArrayList<String>();
View Full Code Here

            cons.argNames.set(i, cons.argNames.get(i) + "_");
          }
        }
      }
      // duplicated to constructor arg names
      ConstructorMeta constructor = meta.constructors.get(0);
      for (MethodMeta method : meta.methods) {
        int len = method.argNames.size();
        for (int i = 0; i < len; i++) {
          String targetArgName = method.argNames.get(i);
          List<String> methodArgNames = new ArrayList<String>();
View Full Code Here

                StringValue.Comma + "\\s+?", StringValue.Comma).replaceAll("<\\s+?", "<").replaceAll("\\s+?>", ">");

        Matcher matcherGrouping = RegExp.PatternObject.MethodSignatureArea.matcher(sourceCodeString);
        while (matcherGrouping.find()) {

            ConstructorMeta meta = new ConstructorMeta();
            String methodSignatureArea = matcherGrouping.group(0).replaceAll(StringValue.CarriageReturn,
                    StringValue.Empty).replaceAll(StringValue.LineFeed, StringValue.Space);

            // -----------------
            // access modifier
            meta.accessModifier = getAccessModifier(methodSignatureArea);

            // -----------------
            // method signature area without access modifier
            String methodSignatureAreaWithoutAccessModifier = trimAccessModifierFromMethodSignatureArea(methodSignatureArea);
            String matchesConstructors = RegExp.Anything_ZeroOrMore_Min + RegExp.WhiteSpace.Consecutive_OneOrMore_Max
                    + classMeta.name + "\\(" + RegExp.Anything_ZeroOrMore_Min + "\\)" + RegExp.Anything_ZeroOrMore_Min;
            if (!methodSignatureAreaWithoutAccessModifier.matches(matchesConstructors)) {
                continue;
            }

            // -----------------
            // is constructor
            String constructorString = StringValue.Space + methodSignatureAreaWithoutAccessModifier;
            String groupConstructor = RegExp.WhiteSpace.Consecutive_ZeroOrMore_Max + classMeta.name
                    + "\\(([^\\)]*?)\\)" + RegExp.WhiteSpace.Consecutive_ZeroOrMore_Max + "(throws .+)*.*?"
                    + RegExp.WhiteSpace.Consecutive_ZeroOrMore_Max + "\\{.*";
            Matcher constructorMatcher = Pattern.compile(groupConstructor).matcher(constructorString);
            if (!constructorMatcher.find()) {
                continue;
            }

            // -----------------
            // args
            String argsDefAreaString = constructorMatcher.group(1);
            List<String> argArr = ArgExtractorHelper.getArgListFromArgsDefAreaString(argsDefAreaString);
            int argArrLen = argArr.size();
            for (int i = 0; i < argArrLen; i++) {
                ArgTypeMeta argTypeMeta = new ArgTypeMeta();
                String argTypeFull = argArr.get(i);
                Matcher toGenericsMatcher = Pattern.compile(RegExp.Generics_Group).matcher(argTypeFull);
                while (toGenericsMatcher.find()) {
                    String[] generics = toGenericsMatcher.group().replaceAll("<", StringValue.Empty).replaceAll(">",
                            StringValue.Empty).split(StringValue.Comma);
                    // convert to java.lang.Object if self class is included
                    for (String generic : generics) {
                        generic = typeNameConverter.toCompilableType(generic, classMeta.importedList,
                                classMeta.packageName);
                        argTypeMeta.generics.add(generic);
                    }
                }
                String argTypeName = argTypeFull.replaceAll(RegExp.Generics, StringValue.Empty).replaceAll("final ",
                        StringValue.Empty).split("\\s+")[0].trim();
                if (argTypeName != null && !argTypeName.equals("")) {
                    argTypeMeta.name = typeNameConverter.toCompilableType(argTypeName, argTypeMeta.generics,
                            classMeta.importedList, classMeta.packageName);
                    argTypeMeta.nameInMethodName = typeNameConverter.toAvailableInMethodName(argTypeMeta.name);
                    meta.argTypes.add(argTypeMeta);
                    Matcher nameMatcher = RegExp.PatternObject.MethodArg_Group.matcher(argTypeFull);
                    if (nameMatcher.find()) {
                        String argName = nameMatcher.group(1);
                        if (argName.matches(".+\\[\\s*\\]")) {
                            // ex. String strArr[] = null;
                            String arrayPart = "";
                            Matcher mat = Pattern.compile("\\[\\s*\\]").matcher(argName);
                            while (mat.find()) {
                                arrayPart += "[]";
                            }
                            argName = argName.replaceAll("\\[\\s*\\]", StringValue.Empty);
                            argTypeMeta.name = argTypeMeta.name + arrayPart;
                            argTypeMeta.nameInMethodName = typeNameConverter.toAvailableInMethodName(argTypeMeta.name);
                        }
                        meta.argNames.add(argName);
                    } else {
                        meta.argNames.add("constructorArg" + i);
                    }
                }
            }
            dest.add(meta);
        }
        if (dest.size() == 0) {
            ConstructorMeta defaultConstructorMeta = new ConstructorMeta();
            dest.add(defaultConstructorMeta);
        }
        return dest;
    }
View Full Code Here

            meta.isTypeTest = true;
            addTestMethodMetaToListIfNotExists(dest, meta);
        }
        // is testing instantiation required
        if (!targetClassMeta.isEnum && targetClassMeta.constructors.size() > 0) {
            ConstructorMeta notPrivateConstructor = null;
            for (ConstructorMeta constructor : targetClassMeta.constructors) {
                if (constructor.accessModifier != AccessModifier.Private) {
                    notPrivateConstructor = constructor;
                    break;
                }
View Full Code Here

                        cons.argNames.set(i, cons.argNames.get(i) + "_");
                    }
                }
            }
            // duplicated to constructor arg names
            ConstructorMeta constructor = meta.constructors.get(0);
            for (MethodMeta method : meta.methods) {
                int len = method.argNames.size();
                for (int i = 0; i < len; i++) {
                    String targetArgName = method.argNames.get(i);
                    List<String> methodArgNames = new ArrayList<String>();
View Full Code Here

TOP

Related Classes of org.junithelper.core.meta.ConstructorMeta

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.