fix(scaffold): 기존 UseCase에 툴 추가 시 의존성 주입(RequiredArgsConstructor) 누락 및 필드 위치 오류 수정
All checks were successful
Deploy to OCIWP / deploy (push) Successful in 6m6s
All checks were successful
Deploy to OCIWP / deploy (push) Successful in 6m6s
This commit is contained in:
@@ -340,6 +340,10 @@ public class ToolScaffolder {
|
||||
implementation = addImport(implementation, "import " + integrationPackage + "." + baseName + "Client;");
|
||||
implementation = addImport(implementation, "import " + integrationPackage + ".io." + requestIo + ";");
|
||||
implementation = addImport(implementation, "import " + integrationPackage + ".io." + responseIo + ";");
|
||||
implementation = addImport(implementation, "import lombok.RequiredArgsConstructor;");
|
||||
if (!implementation.contains("@RequiredArgsConstructor")) {
|
||||
implementation = implementation.replaceFirst("public class ", "@RequiredArgsConstructor\npublic class ");
|
||||
}
|
||||
implementation = insertConstructorField(implementation, " private final " + baseName + "Client " + clientVariable + ";");
|
||||
implementation = insertConstructorField(implementation, " private final " + baseName + "Converter " + converterVariable + ";");
|
||||
String call = mci
|
||||
@@ -374,9 +378,17 @@ public class ToolScaffolder {
|
||||
|
||||
private static String insertConstructorField(String content, String field) {
|
||||
if (content.contains(field)) return content;
|
||||
int constructorField = content.indexOf("private final ");
|
||||
if (constructorField < 0) return insertBeforeLastBrace(content, "\n" + field + "\n");
|
||||
int constructorField = content.lastIndexOf("private final ");
|
||||
if (constructorField < 0) {
|
||||
int classDecl = content.indexOf("public class ");
|
||||
if (classDecl >= 0) {
|
||||
int brace = content.indexOf('{', classDecl);
|
||||
if (brace >= 0) return content.substring(0, brace + 1) + "\n" + field + content.substring(brace + 1);
|
||||
}
|
||||
return insertBeforeLastBrace(content, "\n" + field + "\n");
|
||||
}
|
||||
int lineEnd = content.indexOf('\n', constructorField);
|
||||
if (lineEnd < 0) return content + "\n" + field;
|
||||
return content.substring(0, lineEnd + 1) + field + "\n" + content.substring(lineEnd + 1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user