.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;
}