paul-hammant / qdox

QDox - full extractor of Java class/interface/method definitions (including annotations, parameters, param names)
Other
456 stars 71 forks source link

ParseException on annotation with text block #124

Open SoylentBob opened 1 year ago

SoylentBob commented 1 year ago

Hey there, while playing around with your library I noticed, that given that I have an annotation and a Java class, that sets the annotations value to a java text block, when I call JavaProjectBuilder#addSource for the file a ParseException is thrown.

Thingy.java

@SuppressWarnings("""
        Lorem ipsum dolor sit amet
        """)
public class Thingy {
}

Script:

final JavaProjectBuilder builder = new JavaProjectBuilder();

final JavaSource javaSource = builder.addSource(new FileReader("Thingy.java"));

Stacktrace

syntax error @[3,9]
com.thoughtworks.qdox.parser.ParseException: syntax error @[3,9]
    at app//com.thoughtworks.qdox.parser.impl.Parser.yyerror(Parser.java:1963)
    at app//com.thoughtworks.qdox.parser.impl.Parser.yyparse(Parser.java:2085)
    at app//com.thoughtworks.qdox.parser.impl.Parser.parse(Parser.java:1944)
    at app//com.thoughtworks.qdox.library.SourceLibrary.parse(SourceLibrary.java:232)
    at app//com.thoughtworks.qdox.library.SourceLibrary.parse(SourceLibrary.java:190)
    at app//com.thoughtworks.qdox.library.SourceLibrary.addSource(SourceLibrary.java:94)
    at app//com.thoughtworks.qdox.library.SourceLibrary.addSource(SourceLibrary.java:89)
    at app//com.thoughtworks.qdox.library.SortedClassLibraryBuilder.addSource(SortedClassLibraryBuilder.java:162)
    at app//com.thoughtworks.qdox.JavaProjectBuilder.addSource(JavaProjectBuilder.java:174)

This seems to affect Annotations regardless of where they are placed within the file.

sormuras commented 1 year ago

JetBrains IntelliJ IDEA is also affected by this: https://youtrack.jetbrains.com/issue/IDEA-269534/Parsing-module-info.java-with-text-blocks-in-annotation-usage-fails