From 5932f09fa83c088363be5e9ee1fee5fc3359af9c Mon Sep 17 00:00:00 2001 From: shalousun <836575280@qq.com> Date: Sat, 13 Jan 2024 18:01:16 +0800 Subject: [PATCH] fix test --- src/grammar/lexer.flex | 11 +++++------ src/test/java/com/thoughtworks/qdox/PermitsTest.java | 4 ++-- src/test/java/com/thoughtworks/qdox/RecordsTest.java | 7 ++++++- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/grammar/lexer.flex b/src/grammar/lexer.flex index 4816e059..904bbd22 100644 --- a/src/grammar/lexer.flex +++ b/src/grammar/lexer.flex @@ -268,7 +268,6 @@ JavadocEnd = "*"+ "/" "new" { return Parser.NEW; } "sealed" { return Parser.SEALED; } "non-sealed" { return Parser.NON_SEALED; } - "permits" { return Parser.PERMITS; } "[" { nestingDepth++; return Parser.SQUAREOPEN; } "]" { nestingDepth--; return Parser.SQUARECLOSE; } @@ -317,11 +316,11 @@ JavadocEnd = "*"+ "/" return Parser.RECORD; } "permits" / {WhiteSpace}+ {Id} { - markAnnotatedElementLine(); - classDepth++; - braceMode = CODEBLOCK; - pushState(NAME); - return Parser.PERMITS; + markAnnotatedElementLine(); + classDepth++; + braceMode = TYPE; + pushState(NAME); + return Parser.PERMITS; } "@" { markAnnotatedElementLine(); diff --git a/src/test/java/com/thoughtworks/qdox/PermitsTest.java b/src/test/java/com/thoughtworks/qdox/PermitsTest.java index e8123ee6..1d2ffd5d 100644 --- a/src/test/java/com/thoughtworks/qdox/PermitsTest.java +++ b/src/test/java/com/thoughtworks/qdox/PermitsTest.java @@ -8,7 +8,6 @@ import java.io.StringReader; public class PermitsTest { - private JavaProjectBuilder builder = new JavaProjectBuilder(); @Test public void permitsAsTypeAndIdentifiers() { @@ -30,6 +29,7 @@ public void permitsAsTypeAndIdentifiers() { " this.permits = permits;\n" + " }\n" + "}"; - builder.addSource( new StringReader(source) ); + JavaProjectBuilder javaDocBuilder = new JavaProjectBuilder(); + javaDocBuilder.addSource( new StringReader(source) ); } } diff --git a/src/test/java/com/thoughtworks/qdox/RecordsTest.java b/src/test/java/com/thoughtworks/qdox/RecordsTest.java index da3b9fbc..74255ad8 100644 --- a/src/test/java/com/thoughtworks/qdox/RecordsTest.java +++ b/src/test/java/com/thoughtworks/qdox/RecordsTest.java @@ -22,7 +22,12 @@ public class RecordsTest @Test public void withTwoFields() { - String source = "record Rectangle(double length, double width) { }"; + String source = "/**\n" + + " * \n" + + " * @param length length\n" + + " * @param width width\n" + + " */\n" + + "public record Rectangle(double length, double width) { }"; JavaProjectBuilder javaDocBuilder = new JavaProjectBuilder(); javaDocBuilder.addSource( new StringReader(source) );