public static void warning(Context context, String message, Element element) { context.processingEnvironment().getMessager().printMessage(WARNING, message, element); } }
public static void error(Context context, String message, Element element) { context.processingEnvironment().getMessager().printMessage(ERROR, message, element); }
/** * Will call {@link Messager#printMessage(Diagnostic.Kind, CharSequence, Element)} with * {@link Diagnostic.Kind#ERROR} and the given {@code message} for {@code property}. This will * ultimately fail the build, but will not abort it right now. */ public static void error(Context context, Property property, String message) { context.processingEnvironment() .getMessager() .printMessage(ERROR, message, property.element()); }
@Override public String generateClass(Context context, String className, String classToExtend, boolean isFinal) { ProcessingEnvironment env = context.processingEnvironment(); Optional<AnnotationSpec> generatedAnnotationSpec = GeneratedAnnotations.generatedAnnotation(env.getElementUtils()) .map(AutoValueGsonExtension::createGeneratedAnnotationSpec); List<Property> properties = Lists.newArrayList(); for (Map.Entry<String, ExecutableElement> entry : context.properties().entrySet()) { Property property = Property.create(context.processingEnvironment().getMessager(), entry.getKey(), entry.getValue()); if (property == null) { return null; .skipJavaLangImports(true) .build() .writeTo(context.processingEnvironment().getFiler()); } catch (IOException e) { context.processingEnvironment().getMessager() .printMessage(Diagnostic.Kind.ERROR, String.format(
Messager messager = context.processingEnvironment().getMessager(); if (returnedTypeAdapter instanceof ParameterizedTypeName) { ParameterizedTypeName paramReturnType = (ParameterizedTypeName) returnedTypeAdapter;
static List<WithMethod> getWithMethods(Context context) { Messager messager = context.processingEnvironment().getMessager(); Types typeUtils = context.processingEnvironment().getTypeUtils();
@Override public boolean applicable(Context context) { ProcessingEnvironment environment = context.processingEnvironment(); context.properties(), context.processingEnvironment().getTypeUtils(), context.processingEnvironment().getElementUtils()); Filer filer = context.processingEnvironment().getFiler(); context.processingEnvironment().getElementUtils())) .build() .writeTo(filer);
@Override public String generateClass(Context context, String classNameString, String classToExtend, boolean isFinal) { String packageName = context.packageName(); typeUtils = context.processingEnvironment().getTypeUtils(); TypeElement autoValueTypeElement = context.autoValueClass(); Map<String, ExecutableElement> properties = context.properties(); LinkedHashMap<String, TypeName> types = convertPropertiesToTypes(properties); ClassName className = ClassName.get(packageName, classNameString); TypeSpec firebaseValue = TypeSpec.classBuilder(FIREBASEVALUE) .addModifiers(STATIC, FINAL) .addAnnotations(generateFirebaseValueClassAnnotations(autoValueTypeElement)) .addFields(generateFirebaseValueFields(packageName, types)) .addFields(generateAdapterFields(types)) .addMethod(generateEmptyFirebaseValueConstructor()) .addMethod(generateFirebaseValueConstructorWithAutoValueParam( packageName, autoValueTypeElement, types)) .addMethod(generateFirebaseValueToAutoValueMethod( packageName, className, types)) .addMethod(generateToMapMethod(properties)) .addMethods(generateFirebaseValueGetters(packageName, properties)) .build(); TypeSpec generatedClass = TypeSpec.classBuilder(className) .superclass(TypeVariableName.get(classToExtend)) .addMethod(generateStandardAutoValueConstructor(types)) .addType(firebaseValue) .addModifiers(isFinal ? FINAL : ABSTRACT) .build(); return JavaFile.builder(packageName, generatedClass).build().toString(); }