diff --git a/spring-javaformat/spring-javaformat-formatter-tests/src/test/resources/FormatterTests-expected/record-with-param.txt b/spring-javaformat/spring-javaformat-formatter-tests/src/test/resources/FormatterTests-expected/record-with-param.txt new file mode 100644 index 00000000..57e16f3c --- /dev/null +++ b/spring-javaformat/spring-javaformat-formatter-tests/src/test/resources/FormatterTests-expected/record-with-param.txt @@ -0,0 +1,16 @@ +package simple; + +/** + * Settings that can be applied when creating a {@link ClientHttpRequestFactory}. + * + * @param connectTimeout the connect timeout + * @param readTimeout the read timeout + * @param bufferRequestBody if request body buffering is used + * @author Andy Wilkinson + * @author Phillip Webb + * @since 3.0.0 + * @see ClientHttpRequestFactories + */ +public record Simple(String name) { + +} diff --git a/spring-javaformat/spring-javaformat-formatter-tests/src/test/resources/FormatterTests-expected/simple.txt b/spring-javaformat/spring-javaformat-formatter-tests/src/test/resources/FormatterTests-expected/simple.txt new file mode 100644 index 00000000..63ca9a5c --- /dev/null +++ b/spring-javaformat/spring-javaformat-formatter-tests/src/test/resources/FormatterTests-expected/simple.txt @@ -0,0 +1,15 @@ +package simple; + +/** + * Simple. + * + * @author Phillip Webb + * @since 1.0.0 + */ +public class Simple { + + public static void main(String[] args) throws Exception { + // FIXME + } + +} diff --git a/spring-javaformat/spring-javaformat-formatter-tests/src/test/resources/expected/record-with-param.txt b/spring-javaformat/spring-javaformat-formatter-tests/src/test/resources/expected/record-with-param.txt new file mode 100644 index 00000000..164c5351 --- /dev/null +++ b/spring-javaformat/spring-javaformat-formatter-tests/src/test/resources/expected/record-with-param.txt @@ -0,0 +1,16 @@ +package simple; + +/** + * Settings that can be applied when creating a {@link ClientHttpRequestFactory}. + * + * @param connectTimeout the connect timeout + * @param readTimeout the read timeout + * @param bufferRequestBody if request body buffering is used + * @author Andy Wilkinson + * @author Phillip Webb + * @since 3.0.0 + * @see ClientHttpRequestFactories + */ +public record Simple(String name) { + +} diff --git a/spring-javaformat/spring-javaformat-formatter-tests/src/test/resources/source/record-with-param.txt b/spring-javaformat/spring-javaformat-formatter-tests/src/test/resources/source/record-with-param.txt new file mode 100644 index 00000000..37149688 --- /dev/null +++ b/spring-javaformat/spring-javaformat-formatter-tests/src/test/resources/source/record-with-param.txt @@ -0,0 +1,15 @@ +package simple; + +/** + * Settings that can be applied when creating a {@link ClientHttpRequestFactory}. + * @param connectTimeout the connect timeout + * @param readTimeout the read timeout + * @param bufferRequestBody if request body buffering is used + * @author Andy Wilkinson + * @author Phillip Webb + * @since 3.0.0 + * @see ClientHttpRequestFactories + */ + public record Simple(String name) { + +} diff --git a/spring-javaformat/spring-javaformat-formatter-tests/src/test/resources/source/simple.txt b/spring-javaformat/spring-javaformat-formatter-tests/src/test/resources/source/simple.txt index a12ac39e..62d2a493 100644 --- a/spring-javaformat/spring-javaformat-formatter-tests/src/test/resources/source/simple.txt +++ b/spring-javaformat/spring-javaformat-formatter-tests/src/test/resources/source/simple.txt @@ -2,7 +2,6 @@ package simple; /** * Simple. - * * @author Phillip Webb * @since 1.0.0 */ diff --git a/spring-javaformat/spring-javaformat-formatter/src/main/java/io/spring/javaformat/formatter/jdk11/eclipse/CodeLineBreakPreparator.java b/spring-javaformat/spring-javaformat-formatter/src/main/java/io/spring/javaformat/formatter/jdk11/eclipse/CodeLineBreakPreparator.java index 6b3ee9d8..15057474 100644 --- a/spring-javaformat/spring-javaformat-formatter/src/main/java/io/spring/javaformat/formatter/jdk11/eclipse/CodeLineBreakPreparator.java +++ b/spring-javaformat/spring-javaformat-formatter/src/main/java/io/spring/javaformat/formatter/jdk11/eclipse/CodeLineBreakPreparator.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2021 the original author or authors. + * Copyright 2017-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ import io.spring.javaformat.eclipse.jdt.jdk11.internal.formatter.TokenManager; /** - * {@link Preparator} to fine tune curly-brace line breaks. + * {@link Preparator} to finetune curly-brace line breaks. * * @author Phillip Webb */ diff --git a/spring-javaformat/spring-javaformat-formatter/src/main/java/io/spring/javaformat/formatter/jdk11/eclipse/JavadocLineBreakPreparator.java b/spring-javaformat/spring-javaformat-formatter/src/main/java/io/spring/javaformat/formatter/jdk11/eclipse/JavadocLineBreakPreparator.java index 1e77a4ff..e367de90 100644 --- a/spring-javaformat/spring-javaformat-formatter/src/main/java/io/spring/javaformat/formatter/jdk11/eclipse/JavadocLineBreakPreparator.java +++ b/spring-javaformat/spring-javaformat-formatter/src/main/java/io/spring/javaformat/formatter/jdk11/eclipse/JavadocLineBreakPreparator.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2021 the original author or authors. + * Copyright 2017-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,12 +22,12 @@ import io.spring.javaformat.eclipse.jdt.jdk11.core.dom.ASTNode; import io.spring.javaformat.eclipse.jdt.jdk11.core.dom.ASTVisitor; +import io.spring.javaformat.eclipse.jdt.jdk11.core.dom.AbstractTypeDeclaration; import io.spring.javaformat.eclipse.jdt.jdk11.core.dom.Comment; import io.spring.javaformat.eclipse.jdt.jdk11.core.dom.CompilationUnit; import io.spring.javaformat.eclipse.jdt.jdk11.core.dom.Javadoc; import io.spring.javaformat.eclipse.jdt.jdk11.core.dom.TagElement; import io.spring.javaformat.eclipse.jdt.jdk11.core.dom.TextElement; -import io.spring.javaformat.eclipse.jdt.jdk11.core.dom.TypeDeclaration; import io.spring.javaformat.eclipse.jdt.jdk11.core.formatter.CodeFormatter; import io.spring.javaformat.eclipse.jdt.jdk11.internal.compiler.parser.TerminalTokens; import io.spring.javaformat.eclipse.jdt.jdk11.internal.formatter.Preparator; @@ -35,7 +35,7 @@ import io.spring.javaformat.eclipse.jdt.jdk11.internal.formatter.TokenManager; /** - * {@link Preparator} to fine tune Javadoc whitespace. + * {@link Preparator} to finetune Javadoc whitespace. * * @author Phillip Webb */ @@ -112,15 +112,15 @@ public boolean visit(TagElement node) { int startIndex = this.commentTokenManager.findIndex(node.getStartPosition(), -1, false); Token token = this.commentTokenManager.get(startIndex); token.clearLineBreaksBefore(); - token.putLineBreaksBefore( - this.declaration instanceof TypeDeclaration && this.firstTagElement && this.hasText ? 2 : 1); + boolean isTypeDeclaration = this.declaration instanceof AbstractTypeDeclaration; + token.putLineBreaksBefore(isTypeDeclaration && this.firstTagElement && this.hasText ? 2 : 1); this.firstTagElement = false; } return true; } private boolean isSquashRequired(TagElement node, ASTNode declaration) { - if (declaration instanceof TypeDeclaration) { + if (declaration instanceof AbstractTypeDeclaration) { String tagName = node.getTagName(); return (!node.isNested() && tagName != null && tagName.startsWith("@")); } diff --git a/spring-javaformat/spring-javaformat-formatter/src/main/java/io/spring/javaformat/formatter/jdk8/eclipse/CodeLineBreakPreparator.java b/spring-javaformat/spring-javaformat-formatter/src/main/java/io/spring/javaformat/formatter/jdk8/eclipse/CodeLineBreakPreparator.java index 29d16a3d..df26a623 100644 --- a/spring-javaformat/spring-javaformat-formatter/src/main/java/io/spring/javaformat/formatter/jdk8/eclipse/CodeLineBreakPreparator.java +++ b/spring-javaformat/spring-javaformat-formatter/src/main/java/io/spring/javaformat/formatter/jdk8/eclipse/CodeLineBreakPreparator.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2021 the original author or authors. + * Copyright 2017-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,7 +31,7 @@ import io.spring.javaformat.eclipse.jdt.jdk8.internal.formatter.TokenManager; /** - * {@link Preparator} to fine tune curly-brace line breaks. + * {@link Preparator} to finetune curly-brace line breaks. * * @author Phillip Webb */ diff --git a/spring-javaformat/spring-javaformat-formatter/src/main/java/io/spring/javaformat/formatter/jdk8/eclipse/JavadocLineBreakPreparator.java b/spring-javaformat/spring-javaformat-formatter/src/main/java/io/spring/javaformat/formatter/jdk8/eclipse/JavadocLineBreakPreparator.java index 6a7a4752..68723201 100644 --- a/spring-javaformat/spring-javaformat-formatter/src/main/java/io/spring/javaformat/formatter/jdk8/eclipse/JavadocLineBreakPreparator.java +++ b/spring-javaformat/spring-javaformat-formatter/src/main/java/io/spring/javaformat/formatter/jdk8/eclipse/JavadocLineBreakPreparator.java @@ -1,5 +1,5 @@ /* - * Copyright 2017-2021 the original author or authors. + * Copyright 2017-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,12 +22,12 @@ import io.spring.javaformat.eclipse.jdt.jdk8.core.dom.ASTNode; import io.spring.javaformat.eclipse.jdt.jdk8.core.dom.ASTVisitor; +import io.spring.javaformat.eclipse.jdt.jdk8.core.dom.AbstractTypeDeclaration; import io.spring.javaformat.eclipse.jdt.jdk8.core.dom.Comment; import io.spring.javaformat.eclipse.jdt.jdk8.core.dom.CompilationUnit; import io.spring.javaformat.eclipse.jdt.jdk8.core.dom.Javadoc; import io.spring.javaformat.eclipse.jdt.jdk8.core.dom.TagElement; import io.spring.javaformat.eclipse.jdt.jdk8.core.dom.TextElement; -import io.spring.javaformat.eclipse.jdt.jdk8.core.dom.TypeDeclaration; import io.spring.javaformat.eclipse.jdt.jdk8.core.formatter.CodeFormatter; import io.spring.javaformat.eclipse.jdt.jdk8.internal.compiler.parser.TerminalTokens; import io.spring.javaformat.eclipse.jdt.jdk8.internal.formatter.Preparator; @@ -35,7 +35,7 @@ import io.spring.javaformat.eclipse.jdt.jdk8.internal.formatter.TokenManager; /** - * {@link Preparator} to fine tune Javadoc whitespace. + * {@link Preparator} to finetune Javadoc whitespace. * * @author Phillip Webb */ @@ -112,15 +112,15 @@ public boolean visit(TagElement node) { int startIndex = this.commentTokenManager.findIndex(node.getStartPosition(), -1, false); Token token = this.commentTokenManager.get(startIndex); token.clearLineBreaksBefore(); - token.putLineBreaksBefore( - this.declaration instanceof TypeDeclaration && this.firstTagElement && this.hasText ? 2 : 1); + boolean isTypeDeclaration = this.declaration instanceof AbstractTypeDeclaration; + token.putLineBreaksBefore(isTypeDeclaration && this.firstTagElement && this.hasText ? 2 : 1); this.firstTagElement = false; } return true; } private boolean isSquashRequired(TagElement node, ASTNode declaration) { - if (declaration instanceof TypeDeclaration) { + if (declaration instanceof AbstractTypeDeclaration) { String tagName = node.getTagName(); return (!node.isNested() && tagName != null && tagName.startsWith("@")); }