377 } 378 return topDeclaringType(enclosing); 379 } 380 381 @Override 382 public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { 383 if (roundEnv.processingOver()) { 384 return true; 385 } 386 387 Map<Element, OptionsInfo> map = new HashMap<>(); 388 for (Element element : roundEnv.getElementsAnnotatedWith(Option.class)) { 389 if (!processed.contains(element)) { 390 processed.add(element); 391 Element topDeclaringType = topDeclaringType(element); 392 OptionsInfo options = map.get(topDeclaringType); 393 if (options == null) { 394 options = new OptionsInfo(topDeclaringType); 395 map.put(topDeclaringType, options); 396 } 397 processElement(element, options); 398 } 399 } 400 401 boolean ok = true; 402 Map<String, OptionInfo> uniqueness = new HashMap<>(); 403 for (OptionsInfo info : map.values()) { 404 for (OptionInfo option : info.options) { 405 OptionInfo conflict = uniqueness.put(option.name, option); 406 if (conflict != null) { 407 processingEnv.getMessager().printMessage(Kind.ERROR, "Duplicate option names for " + option + " and " + conflict, option.field); 408 ok = false; 409 } 410 } 411 } 412 413 if (ok) { 414 for (OptionsInfo info : map.values()) { 415 createFiles(info); 416 } | 377 } 378 return topDeclaringType(enclosing); 379 } 380 381 @Override 382 public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { 383 if (roundEnv.processingOver()) { 384 return true; 385 } 386 387 Map<Element, OptionsInfo> map = new HashMap<>(); 388 for (Element element : roundEnv.getElementsAnnotatedWith(Option.class)) { 389 if (!processed.contains(element)) { 390 processed.add(element); 391 Element topDeclaringType = topDeclaringType(element); 392 OptionsInfo options = map.get(topDeclaringType); 393 if (options == null) { 394 options = new OptionsInfo(topDeclaringType); 395 map.put(topDeclaringType, options); 396 } 397 if (!element.getEnclosingElement().getSimpleName().toString().endsWith("Options")) { 398 processingEnv.getMessager().printMessage(Kind.ERROR, "Option declaring classes must have a name that ends with 'Options'", element.getEnclosingElement()); 399 } 400 processElement(element, options); 401 } 402 } 403 404 boolean ok = true; 405 Map<String, OptionInfo> uniqueness = new HashMap<>(); 406 for (OptionsInfo info : map.values()) { 407 for (OptionInfo option : info.options) { 408 OptionInfo conflict = uniqueness.put(option.name, option); 409 if (conflict != null) { 410 processingEnv.getMessager().printMessage(Kind.ERROR, "Duplicate option names for " + option + " and " + conflict, option.field); 411 ok = false; 412 } 413 } 414 } 415 416 if (ok) { 417 for (OptionsInfo info : map.values()) { 418 createFiles(info); 419 } |