Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Commit 29e9f69

Browse files
author
ritvik
committed
Refactor Long identifier
1 parent 937068d commit 29e9f69

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

src/main/java/org/springframework/cli/merger/ProjectMerger.java

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -172,13 +172,12 @@ public void merge() {
172172
}
173173

174174
private void mergeSpringBootApplicationClassAnnotations() throws IOException {
175-
176175
logger.debug("Looking for @SpringBootApplication in directory " + this.toMergeProjectPath.toFile());
177176
Optional<File> springBootApplicationFile = RootPackageFinder
178-
.findSpringBootApplicationFile(this.toMergeProjectPath.toFile());
177+
.findSpringBootApplicationFile(this.toMergeProjectPath.toFile());
179178

180179
if (springBootApplicationFile.isPresent()) {
181-
CollectAnnotationAndImportInformationRecipe collectAnnotationAndImportInformationRecipe = new CollectAnnotationAndImportInformationRecipe();
180+
CollectAnnotationAndImportInformationRecipe annotationImportRecipe = new CollectAnnotationAndImportInformationRecipe();
182181
Consumer<Throwable> onError = e -> {
183182
logger.error("error in javaParser execution", e);
184183
};
@@ -187,11 +186,10 @@ private void mergeSpringBootApplicationClassAnnotations() throws IOException {
187186
paths.add(springBootApplicationFile.get().toPath());
188187
JavaParser javaParser = new Java17Parser.Builder().build();
189188
List<SourceFile> compilationUnits = javaParser.parse(paths, null, executionContext).toList();
190-
collectAnnotationAndImportInformationRecipe.run(new InMemoryLargeSourceSet(compilationUnits),
191-
executionContext);
189+
annotationImportRecipe.run(new InMemoryLargeSourceSet(compilationUnits), executionContext);
192190

193-
List<Annotation> declaredAnnotations = collectAnnotationAndImportInformationRecipe.getDeclaredAnnotations();
194-
List<String> declaredImports = collectAnnotationAndImportInformationRecipe.getDeclaredImports();
191+
List<Annotation> declaredAnnotations = annotationImportRecipe.getDeclaredAnnotations();
192+
List<String> declaredImports = annotationImportRecipe.getDeclaredImports();
195193

196194
Map<String, String> annotationImportMap = new HashMap<>();
197195
for (Annotation declaredAnnotation : declaredAnnotations) {
@@ -208,7 +206,7 @@ private void mergeSpringBootApplicationClassAnnotations() throws IOException {
208206

209207
logger.debug("Looking for @SpringBootApplication in directory " + this.currentProjectPath.toFile());
210208
Optional<File> currentSpringBootApplicationFile = RootPackageFinder
211-
.findSpringBootApplicationFile(this.currentProjectPath.toFile());
209+
.findSpringBootApplicationFile(this.currentProjectPath.toFile());
212210
if (currentSpringBootApplicationFile.isPresent()) {
213211
executionContext = new InMemoryExecutionContext(onError);
214212
paths = new ArrayList<>();
@@ -221,9 +219,9 @@ private void mergeSpringBootApplicationClassAnnotations() throws IOException {
221219
AddImport addImport = new AddImport(importStatement, null, false);
222220
AddImportRecipe addImportRecipe = new AddImportRecipe(addImport);
223221
List<Result> results = addImportRecipe
224-
.run(new InMemoryLargeSourceSet(compilationUnits), executionContext)
225-
.getChangeset()
226-
.getAllResults();
222+
.run(new InMemoryLargeSourceSet(compilationUnits), executionContext)
223+
.getChangeset()
224+
.getAllResults();
227225
updateSpringApplicationClass(currentSpringBootApplicationFile.get().toPath(), results);
228226

229227
AttributedStringBuilder sb = new AttributedStringBuilder();
@@ -232,15 +230,9 @@ private void mergeSpringBootApplicationClassAnnotations() throws IOException {
232230
terminalMessage.print(sb.toAttributedString());
233231

234232
injectAnnotation(currentSpringBootApplicationFile.get().toPath(), annotation);
235-
// AddAnnotationToClassRecipe addAnnotationToClassRecipe = new
236-
// AddAnnotationToClassRecipe(annotation);
237-
// results = addAnnotationToClassRecipe.run(compilationUnits);
238-
// updateSpringApplicationClass(currentSpringBootApplicationFile.get().toPath(),
239-
// results);
240233
}
241234
}
242235
}
243-
244236
}
245237

246238
private void injectAnnotation(Path pathToFile, String annotation) {

0 commit comments

Comments
 (0)