@@ -172,13 +172,12 @@ public void merge() {
172
172
}
173
173
174
174
private void mergeSpringBootApplicationClassAnnotations () throws IOException {
175
-
176
175
logger .debug ("Looking for @SpringBootApplication in directory " + this .toMergeProjectPath .toFile ());
177
176
Optional <File > springBootApplicationFile = RootPackageFinder
178
- .findSpringBootApplicationFile (this .toMergeProjectPath .toFile ());
177
+ .findSpringBootApplicationFile (this .toMergeProjectPath .toFile ());
179
178
180
179
if (springBootApplicationFile .isPresent ()) {
181
- CollectAnnotationAndImportInformationRecipe collectAnnotationAndImportInformationRecipe = new CollectAnnotationAndImportInformationRecipe ();
180
+ CollectAnnotationAndImportInformationRecipe annotationImportRecipe = new CollectAnnotationAndImportInformationRecipe ();
182
181
Consumer <Throwable > onError = e -> {
183
182
logger .error ("error in javaParser execution" , e );
184
183
};
@@ -187,11 +186,10 @@ private void mergeSpringBootApplicationClassAnnotations() throws IOException {
187
186
paths .add (springBootApplicationFile .get ().toPath ());
188
187
JavaParser javaParser = new Java17Parser .Builder ().build ();
189
188
List <SourceFile > compilationUnits = javaParser .parse (paths , null , executionContext ).toList ();
190
- collectAnnotationAndImportInformationRecipe .run (new InMemoryLargeSourceSet (compilationUnits ),
191
- executionContext );
189
+ annotationImportRecipe .run (new InMemoryLargeSourceSet (compilationUnits ), executionContext );
192
190
193
- List <Annotation > declaredAnnotations = collectAnnotationAndImportInformationRecipe .getDeclaredAnnotations ();
194
- List <String > declaredImports = collectAnnotationAndImportInformationRecipe .getDeclaredImports ();
191
+ List <Annotation > declaredAnnotations = annotationImportRecipe .getDeclaredAnnotations ();
192
+ List <String > declaredImports = annotationImportRecipe .getDeclaredImports ();
195
193
196
194
Map <String , String > annotationImportMap = new HashMap <>();
197
195
for (Annotation declaredAnnotation : declaredAnnotations ) {
@@ -208,7 +206,7 @@ private void mergeSpringBootApplicationClassAnnotations() throws IOException {
208
206
209
207
logger .debug ("Looking for @SpringBootApplication in directory " + this .currentProjectPath .toFile ());
210
208
Optional <File > currentSpringBootApplicationFile = RootPackageFinder
211
- .findSpringBootApplicationFile (this .currentProjectPath .toFile ());
209
+ .findSpringBootApplicationFile (this .currentProjectPath .toFile ());
212
210
if (currentSpringBootApplicationFile .isPresent ()) {
213
211
executionContext = new InMemoryExecutionContext (onError );
214
212
paths = new ArrayList <>();
@@ -221,9 +219,9 @@ private void mergeSpringBootApplicationClassAnnotations() throws IOException {
221
219
AddImport addImport = new AddImport (importStatement , null , false );
222
220
AddImportRecipe addImportRecipe = new AddImportRecipe (addImport );
223
221
List <Result > results = addImportRecipe
224
- .run (new InMemoryLargeSourceSet (compilationUnits ), executionContext )
225
- .getChangeset ()
226
- .getAllResults ();
222
+ .run (new InMemoryLargeSourceSet (compilationUnits ), executionContext )
223
+ .getChangeset ()
224
+ .getAllResults ();
227
225
updateSpringApplicationClass (currentSpringBootApplicationFile .get ().toPath (), results );
228
226
229
227
AttributedStringBuilder sb = new AttributedStringBuilder ();
@@ -232,15 +230,9 @@ private void mergeSpringBootApplicationClassAnnotations() throws IOException {
232
230
terminalMessage .print (sb .toAttributedString ());
233
231
234
232
injectAnnotation (currentSpringBootApplicationFile .get ().toPath (), annotation );
235
- // AddAnnotationToClassRecipe addAnnotationToClassRecipe = new
236
- // AddAnnotationToClassRecipe(annotation);
237
- // results = addAnnotationToClassRecipe.run(compilationUnits);
238
- // updateSpringApplicationClass(currentSpringBootApplicationFile.get().toPath(),
239
- // results);
240
233
}
241
234
}
242
235
}
243
-
244
236
}
245
237
246
238
private void injectAnnotation (Path pathToFile , String annotation ) {
0 commit comments