diff --git a/src/grammar/lexer.flex b/src/grammar/lexer.flex index 40c84cab..682aba1e 100644 --- a/src/grammar/lexer.flex +++ b/src/grammar/lexer.flex @@ -239,7 +239,7 @@ JavadocEnd = "*"+ "/" { {WhiteSpace} { popState(); } } - { + { "." { return Parser.DOT; } "..." { return Parser.DOTDOTDOT; } "," { return Parser.COMMA; } @@ -265,7 +265,6 @@ JavadocEnd = "*"+ "/" "implements" { return Parser.IMPLEMENTS; } "super" { return Parser.SUPER; } "new" { return Parser.NEW; } - "record" { return Parser.RECORD; } "sealed" { return Parser.SEALED; } "non-sealed" { return Parser.NON_SEALED; } "permits" { return Parser.PERMITS; } @@ -309,6 +308,13 @@ JavadocEnd = "*"+ "/" pushState(NAME); return Parser.ENUM; } + "record" / {WhiteSpace}* {Id} { + markAnnotatedElementLine(); + classDepth++; + braceMode = CODEBLOCK; + pushState(NAME); + return Parser.RECORD; + } "@" { markAnnotatedElementLine(); pushState(ATANNOTATION); @@ -430,7 +436,7 @@ JavadocEnd = "*"+ "/" } } } - { + { "default" { return Parser.DEFAULT; } } { @@ -441,7 +447,7 @@ JavadocEnd = "*"+ "/" {Id} / {WhiteSpace}* [;{(] { resetAnnotatedElementLine(); popState(); return Parser.IDENTIFIER; } {Id} { popState(); return Parser.IDENTIFIER; } } - { + { {Id} { return Parser.IDENTIFIER; } } @@ -657,12 +663,12 @@ JavadocEnd = "*"+ "/" } } - { + { "\"" { if (appendingToCodeBody) { codeBody.append('"'); } pushState(STRING); } \' { if (appendingToCodeBody) { codeBody.append('\''); } pushState(CHAR); } } - { + { "//" { if (appendingToCodeBody) { codeBody.append("//"); } pushState(SINGLELINECOMMENT); } "/*" { if (appendingToCodeBody) { codeBody.append("/*"); } pushState(MULTILINECOMMENT); } "/**/" { if (appendingToCodeBody) { codeBody.append("/**/"); } } diff --git a/src/test/java/com/thoughtworks/qdox/RecordsTest.java b/src/test/java/com/thoughtworks/qdox/RecordsTest.java index 9947e1e5..1e833640 100644 --- a/src/test/java/com/thoughtworks/qdox/RecordsTest.java +++ b/src/test/java/com/thoughtworks/qdox/RecordsTest.java @@ -138,4 +138,30 @@ public void withAnnotatedParameters() { + " @GreaterThanZero double width) { }"; builder.addSource( new StringReader(source) ); } + + @Test + public void withAnnotation() { + String source = "@Deprecated\n" + + "record Line(int lenght) { }"; + builder.addSource( new StringReader(source) ); + } + + + @Test + public void recordAsTypeAndIdentifiers() { + String source = "package record.record.record;\n" + + "\n" + + "public class record\n" + + "{\n" + + " private Object record;\n" + + " \n" + + " public record() {\n" + + " }\n" + + " \n" + + " private Object record(Object record) {\n" + + " return record;\n" + + " }\n" + + "}"; + builder.addSource( new StringReader(source) ); + } }