Skip to content

Commit

Permalink
Merge pull request #328 from SentryMan/format
Browse files Browse the repository at this point in the history
[http-client] Generated Client Formatting
  • Loading branch information
SentryMan authored Oct 20, 2023
2 parents b9b6548 + 14d5da2 commit 3d53d55
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ final class AnnotationUtil {
private AnnotationUtil() {}

public static void writeAnnotations(Append writer, Element element) {
writeAnnotations(writer, element, "");
}

public static void writeAnnotations(Append writer, Element element, String indent) {
for (final AnnotationMirror annotationMirror : element.getAnnotationMirrors()) {
final var type = UType.parse(annotationMirror.getAnnotationType().asElement().asType());
if (type.mainType().startsWith("io.avaje.http") || type.mainType().startsWith("io.swagger")) {
continue;
}
final String annotationName = annotationMirror.getAnnotationType().toString();
final StringBuilder sb = new StringBuilder(" @").append(annotationName).append("(");
final StringBuilder sb = new StringBuilder(indent).append("@").append(annotationName).append("(");
boolean first = true;

for (final var entry : annotationMirror.getElementValues().entrySet()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,17 @@ private void methodStart(Append writer) {
}
method.checkArgumentNames();

segmentPropertyMap.forEach((k, v) -> {
writer.append(" private static final String %s = ", v);
final String getProperty = useConfig ? "Config.get(" : "System.getProperty(";
writer.append(getProperty).append("\"%s\");", k).eol();
});

writer.append(" // %s %s", webMethod, method.webMethodPath()).eol();

segmentPropertyMap.forEach(
(k, v) -> {
writer.append(" private static final String %s = ", v);
final String getProperty = useConfig ? "Config.get(" : "System.getProperty(";
writer.append(getProperty).append("\"%s\");", k).eol();
});

writer.append(" @Override").eol();
AnnotationUtil.writeAnnotations(writer, method.element());
AnnotationUtil.writeAnnotations(writer, method.element()," ");
writer.append(" public %s%s %s(", methodGenericParams, returnType.shortType(), method.simpleName());
int count = 0;
List<MethodParam> params = method.params();
Expand Down

0 comments on commit 3d53d55

Please sign in to comment.