Skip to content

Commit

Permalink
Fix printing of false Javadoc attributes
Browse files Browse the repository at this point in the history
This to ensure parse-to-print idempotency.
  • Loading branch information
knutwannheden committed Oct 4, 2023
1 parent f36792d commit 1670c01
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -1707,4 +1707,23 @@ public static void main(String[] args) {
)
);
}

@Test
void emptyAttributes() {
rewriteRun(
java(
"""
/**
* DEFINE TENANCY TenantB AS <TenantB OCID>
* ENDORSE GROUP <TenantA user group name> TO {OBJECTSTORAGE_NAMESPACE_READ} IN TENANCY TenantB
*
* DEFINE TENANCY TenantA AS <TenantA OCID>
* DEFINE GROUP TenantAGroup AS <TenantA user group OCID>
* ADMIT GROUP TenantAGroup OF TENANCY TenantA TO {OBJECTSTORAGE_NAMESPACE_READ} IN TENANCY
*/
class Test {}
"""
)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public JavadocPrinter() {
public Javadoc visitAttribute(Javadoc.Attribute attribute, PrintOutputCapture<P> p) {
beforeSyntax(attribute, p);
p.append(attribute.getName());
if (attribute.getSpaceBeforeEqual() != null) {
if (attribute.getSpaceBeforeEqual() != null && !attribute.getSpaceBeforeEqual().isEmpty()) {
visit(attribute.getSpaceBeforeEqual(), p);
if (attribute.getValue() != null) {
p.append('=');
Expand Down

0 comments on commit 1670c01

Please sign in to comment.