Skip to content

Fix JDT Errors and Fix for duplicate generated fields #288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ final class AdapterName {
final String fullName;

AdapterName(TypeElement origin) {
String originPackage = APContext.elements().getPackageOf(origin).toString();
String originPackage = APContext.elements().getPackageOf(origin).getQualifiedName().toString();
var name = shortName(origin);
shortName = name.substring(0, name.length() - 1);
if ("".equals(originPackage)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ static String lookupType(TypeMirror typeMirror) {
private AnnotationUtil() {}

static String annotationAttributeMap(AnnotationMirror annotationMirror, Element target) {
final Element element = annotationMirror.getAnnotationType().asElement();
final Handler handler = handlers.get(element.toString());
final var element = APContext.asTypeElement(annotationMirror.getAnnotationType());
final Handler handler = handlers.get(element.getQualifiedName().toString());
return Objects.requireNonNullElse(handler, defaultHandler)
.attributes(annotationMirror, element, target);
}
Expand Down Expand Up @@ -381,7 +381,7 @@ public String message(AnnotationMirror annotationMirror, Element target) {
@Override
public boolean isSupported(Element target, String _type) {
boolean isMetaConstraint = hasMetaConstraintAnnotation(target);
return isMetaConstraint || (allowUnknown && _type == null) || (_type != null && supportedTypes.contains(_type));
return isMetaConstraint || allowUnknown && _type == null || _type != null && supportedTypes.contains(_type);
}
}

Expand Down Expand Up @@ -463,7 +463,7 @@ public String attributes(AnnotationMirror annotationMirror, Element element, Ele
@Override
String messageKey(AnnotationValue defaultValue) {
final AnnotationValue inclusiveValue = memberValue("inclusive");
final boolean inclusive = (inclusiveValue == null || "true".equals(inclusiveValue.toString()));
final boolean inclusive = inclusiveValue == null || "true".equals(inclusiveValue.toString());
String messageKey = super.messageKey(defaultValue);
if (!inclusive) {
messageKey = messageKey.replace(".message", ".exclusive.message");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.io.IOException;
import java.io.Writer;

import javax.lang.model.element.TypeElement;
import javax.tools.JavaFileObject;

final class SimpleParamBeanWriter {
Expand All @@ -19,15 +20,14 @@ final class SimpleParamBeanWriter {
SimpleParamBeanWriter(ValidMethodReader beanReader) {
this.beanReader = beanReader;
final var method = beanReader.getBeanType();
this.adapterPackage = ProcessorUtils.packageOf(method.getEnclosingElement().asType().toString());
this.adapterPackage = ProcessorUtils.packageOf(((TypeElement) method.getEnclosingElement()).getQualifiedName().toString());
this.adapterFullName = adapterPackage
+ "."
+ method
.getSimpleName()
.toString()
.transform(str -> str.substring(0, 1).toUpperCase() + str.substring(1))
+ "ParamProvider";

this.adapterShortName = Util.shortName(adapterFullName);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.avaje.validation.generator;

import static io.avaje.validation.generator.APContext.asTypeElement;
import static io.avaje.validation.generator.APContext.logNote;
import static io.avaje.validation.generator.APContext.logError;
import static io.avaje.validation.generator.APContext.logNote;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -83,8 +83,9 @@ void read(TypeElement type) {
}

for (final FieldReader localField : localFields) {
allFields.add(localField);
allFieldMap.put(localField.fieldName(), localField);
if (allFieldMap.put(localField.fieldName(), localField) == null) {
allFields.add(localField);
}
}
}

Expand Down