|
15 | 15 | import javax.lang.model.util.Elements;
|
16 | 16 |
|
17 | 17 | import static java.util.stream.Collectors.joining;
|
| 18 | +import static java.util.stream.Collectors.toList; |
| 19 | + |
18 | 20 | import java.io.IOException;
|
19 | 21 | import java.nio.file.Files;
|
20 | 22 | import java.nio.file.StandardOpenOption;
|
@@ -243,7 +245,7 @@ private static Map<String, AspectImportPrism> importedAspects(RoundEnvironment r
|
243 | 245 |
|
244 | 246 | private void readScopes(Set<? extends Element> scopes) {
|
245 | 247 | for (final Element element : scopes) {
|
246 |
| - if ((element.getKind() == ElementKind.ANNOTATION_TYPE) && (element instanceof TypeElement)) { |
| 248 | + if (element.getKind() == ElementKind.ANNOTATION_TYPE && element instanceof TypeElement) { |
247 | 249 | final var type = (TypeElement) element;
|
248 | 250 | allScopes.addScopeAnnotation(type);
|
249 | 251 | }
|
@@ -323,6 +325,19 @@ private ScopeInfo findScope(Element element) {
|
323 | 325 | * Read the existing meta-data from InjectModule (if found) and the factory bean (if exists).
|
324 | 326 | */
|
325 | 327 | private void readModule(RoundEnvironment roundEnv) {
|
| 328 | + var moduleList = |
| 329 | + maybeElements(roundEnv, InjectModulePrism.PRISM_TYPE).stream() |
| 330 | + .flatMap(Set::stream) |
| 331 | + .filter(e -> !ScopePrism.isPresent(e)) |
| 332 | + .filter(e -> !GeneratedPrism.isPresent(e)) |
| 333 | + .collect(toList()); |
| 334 | + |
| 335 | + if (moduleList.size() > 1) { |
| 336 | + for (var element : moduleList) { |
| 337 | + logError(element, "There should only be one default scope @InjectModule annotation in a module"); |
| 338 | + } |
| 339 | + } |
| 340 | + |
326 | 341 | if (readModuleInfo) {
|
327 | 342 | // only read the module meta data once
|
328 | 343 | return;
|
|
0 commit comments