diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 0aa5090d..c15f95aa 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -9,19 +9,19 @@ jobs:
strategy:
matrix:
os: [ ubuntu-latest , windows-latest ]
- java: [ 8, 11 ]
+ java: [ 11,17 ]
experimental: [ false ]
steps:
- - uses: actions/checkout@v4.1.1
- - uses: actions/cache@v4.0.0
+ - uses: actions/checkout@v4.2.2
+ - uses: actions/cache@v4.1.2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Set up JDK ${{ matrix.java }}
- uses: actions/setup-java@v4.0.0
+ uses: actions/setup-java@v4.5.0
with:
java-version: ${{ matrix.java }}
distribution: adopt
diff --git a/README.md b/README.md
index df14b5aa..773d62ee 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,9 @@ This project used to be on Codehaus, in Subversion. The trunk of that has been g
# Download
-Maven's central repo [holds versions of QDox](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.thoughtworks.qdox%22%20AND%20a%3A%22qdox%22)
+Maven's central repo [holds versions of QDox](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.thoughtworks.qdox%22%20AND%20a%3A%22qdox%22)
+
+Available assets: binary jar | sources jar | javadoc jar | project tar.bz2 | project tar.gz | project zip
# In A Nutshell
@@ -51,20 +53,6 @@ JavaProjectBuilder builder = new JavaProjectBuilder( libraryBuilder );
During the parsing of java files the Parser needs to remember states, which are kept in a stack. Due to recursive calls the stack can become very large. By default the size of this this stack is 500 and it can only be set during compile-time of QDox. Normally 500 per sourcefile will do, but in very, very rare cases this might be too little. The only way to increase this number is by rebuilding it. Download the sources and build it like mvn install -Dqdox.javaparser.stack=750 if you want to change it to 750.
-# Download
-
-QDox is available at the Maven Central. To include the most recent of QDox in your pom, include the following dependency:
-
-```xml
-
- ${project.groupId}
- ${project.artifactId}
- ${project.version}
-
-```
-
-Latest stable release - QDox ${project.rel.org.thoughtworks.qdox:qdox}: binary jar | sources jar | javadoc jar | project tar.bz2 | project tar.gz | project zip
-
# What is using QDox
Project Description How QDox is Used
diff --git a/pom.xml b/pom.xml
index 0a6e20be..02a6af8f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -10,7 +10,7 @@
QDox
com.thoughtworks.qdox
qdox
- 2.1.1-SNAPSHOT
+ 2.2.0-SNAPSHOT
https://github.com/paul-hammant/qdox
@@ -134,17 +134,17 @@
org.apache.maven.plugins
maven-clean-plugin
- 2.4.1
+ 3.4.0
org.apache.maven.plugins
maven-compiler-plugin
- 3.11.0
+ 3.13.0
org.apache.maven.plugins
maven-surefire-plugin
- 3.2.3
+ 3.5.2
false
@@ -152,29 +152,22 @@
org.apache.maven.plugins
maven-jar-plugin
- 3.3.0
-
-
-
- com.thoughtworks.qdox
-
-
-
+ 3.4.2
org.apache.maven.plugins
maven-install-plugin
- 3.1.1
+ 3.1.3
org.apache.maven.plugins
maven-deploy-plugin
- 3.1.1
+ 3.1.3
org.apache.maven.plugins
maven-site-plugin
- 3.8.2
+ 3.21.0
${basedir}/src/site/templates/site.vm
@@ -182,7 +175,7 @@
org.apache.maven.plugins
maven-release-plugin
- 3.0.1
+ 3.1.1
@@ -190,7 +183,7 @@
org.apache.maven.plugins
maven-enforcer-plugin
- 1.3.1
+ 3.5.0
enforce-maven
@@ -202,6 +195,9 @@
3.0
+
+ 11
+
@@ -221,10 +217,37 @@
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+ default-compile
+
+ 8
+
+ module-info.java
+
+
+
+
+ module-descriptor
+
+ compile
+
+
+ 11
+
+ module-info.java
+
+
+
+
+
de.jflex
jflex-maven-plugin
- 1.8.2
+ 1.9.1
@@ -243,7 +266,7 @@
org.codehaus.mojo
exec-maven-plugin
- 3.1.1
+ 3.5.0
javacommentparser
@@ -288,31 +311,10 @@
-
- org.codehaus.mojo
- animal-sniffer-maven-plugin
- 1.7
-
-
- check-java15
- process-classes
-
- check
-
-
-
- org.codehaus.mojo.signature
- java18
- 1.0
-
-
-
-
-
org.apache.maven.plugins
maven-failsafe-plugin
- 2.22.1
+ 3.5.2
@@ -325,7 +327,7 @@
org.apache.maven.plugins
maven-invoker-plugin
- 3.6.0
+ 3.8.1
${project.build.directory}/it
verify
@@ -354,7 +356,7 @@
org.apache.maven.plugins
maven-assembly-plugin
- 3.6.0
+ 3.7.1
project
@@ -383,13 +385,13 @@
org.junit.jupiter
junit-jupiter
- 5.10.0
+ 5.11.3
test
org.assertj
assertj-core
- 3.11.1
+ 3.26.3
test
@@ -494,7 +496,7 @@
org.apache.maven.plugins
maven-project-info-reports-plugin
- 3.5.0
+ 3.8.0
@@ -512,7 +514,7 @@
org.apache.maven.plugins
maven-jxr-plugin
- 2.3
+ 3.6.0
@@ -529,7 +531,7 @@
org.apache.maven.plugins
maven-javadoc-plugin
- 3.6.3
+ 3.11.1
com.thoughtworks.qdox.*
diff --git a/src/grammar/lexer.flex b/src/grammar/lexer.flex
index a17a69eb..faa39e47 100644
--- a/src/grammar/lexer.flex
+++ b/src/grammar/lexer.flex
@@ -203,7 +203,7 @@ UnicodeChar = \\u[a-fA-F0-9]{4}
Id = ([:jletter:]|{UnicodeChar}) ([:jletterdigit:]|{UnicodeChar})*
JavadocEnd = "*"+ "/"
-%state JAVADOC JAVADOCTAG JAVADOCLINE CODEBLOCK PARENBLOCK ASSIGNMENT STRING CHAR SINGLELINECOMMENT MULTILINECOMMENT ANNOTATION ANNOSTRING ANNOCHAR ARGUMENTS NAME
+%state JAVADOC JAVADOCTAG JAVADOCLINE CODEBLOCK PARENBLOCK ASSIGNMENT STRING CHAR SINGLELINECOMMENT MULTILINECOMMENT ANNOTATION ANNOSTRING ANNOCHAR ARGUMENTS NAME
%state ANNOTATIONTYPE ENUM MODULE RECORD TYPE ANNOTATIONNOARG ATANNOTATION
%state NAME_OR_MODIFIER
@@ -511,6 +511,7 @@ JavadocEnd = "*"+ "/"
"++" { return Parser.PLUSPLUS; }
"--" { return Parser.MINUSMINUS; }
+ "\"\"\"" { appendingToCodeBody=true; codeBody.append("\"\"\""); pushState(ANNOSTRING); }
"\"" { appendingToCodeBody=true; codeBody.append("\""); pushState(ANNOSTRING); }
"\'" { appendingToCodeBody=true; codeBody.append("\'"); pushState(ANNOCHAR); }
@@ -565,6 +566,7 @@ JavadocEnd = "*"+ "/"
}
{
+ "\"\"\"" { codeBody.append("\"\"\""); popState(); appendingToCodeBody=false; return Parser.TEXTBLOCK; }
"\"" { codeBody.append("\""); popState(); appendingToCodeBody=false; return Parser.STRING_LITERAL; }
"\\\"" { codeBody.append("\\\""); }
"\\\\" { codeBody.append("\\\\"); }
diff --git a/src/grammar/parser.y b/src/grammar/parser.y
index a96f010b..1d9d0cdd 100644
--- a/src/grammar/parser.y
+++ b/src/grammar/parser.y
@@ -49,7 +49,7 @@ import java.util.Stack;
%token INTEGER_LITERAL
%token FLOAT_LITERAL
%token CHAR_LITERAL
-%token STRING_LITERAL
+%token STRING_LITERAL, TEXTBLOCK
%token VERTLINE2 AMPERSAND2 VERTLINE CIRCUMFLEX AMPERSAND EQUALS2 NOTEQUALS
%token LESSTHAN GREATERTHAN LESSEQUALS GREATEREQUALS LESSTHAN2 GREATERTHAN2 GREATERTHAN3
%token PLUS MINUS STAR SLASH PERCENT TILDE EXCLAMATION
@@ -770,6 +770,7 @@ RecordComponent: Annotations_opt /* ={RecordComponentModifier} */ Type /* =Unann
param.setName($3);
param.setDimensions(0);
param.setVarArgs(false);
+ param.setLineNumber(lexer.getLine());
builder.addParameter(param);
recordHeaderStack.getFirst().addField(param);
param = new FieldDef();
@@ -785,6 +786,7 @@ VariableArityRecordComponent: Annotations_opt /* ={RecordComponentModifier} */ T
param.setName($4);
param.setDimensions(0);
param.setVarArgs(true);
+ param.setLineNumber(lexer.getLine());
builder.addParameter(param);
recordHeaderStack.getFirst().addField(param);
param = new FieldDef();
@@ -2017,6 +2019,10 @@ Literal: INTEGER_LITERAL
{
String s = lexer.getCodeBody();
$$ = new ConstantDef(s, Character.class);
+ }
+ | TEXTBLOCK {
+ String s = lexer.getCodeBody();
+ $$ = new ConstantDef(s, String.class);
}
| STRING_LITERAL
{
diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java
new file mode 100644
index 00000000..0d4b71c2
--- /dev/null
+++ b/src/main/java/module-info.java
@@ -0,0 +1,7 @@
+module com.thoughtworks.qdox {
+ requires java.desktop; // java.beans.Introspector
+
+ exports com.thoughtworks.qdox;
+ exports com.thoughtworks.qdox.model;
+
+}
\ No newline at end of file
diff --git a/src/test/java/com/thoughtworks/qdox/AnnotationsTest.java b/src/test/java/com/thoughtworks/qdox/AnnotationsTest.java
index 257dd8f3..b37b562a 100644
--- a/src/test/java/com/thoughtworks/qdox/AnnotationsTest.java
+++ b/src/test/java/com/thoughtworks/qdox/AnnotationsTest.java
@@ -253,4 +253,36 @@ public void testDoubleEscapedString()
String source = "public class Foo {\n" + "@SuppressWarnings({\"abc\\\\d\"})\n" + "private void bar() { } }";
builder.addSource( new StringReader( source ) );
}
+
+ @Test
+ public void testTextBlock() {
+ JavaProjectBuilder builder = new JavaProjectBuilder();
+ String source = "@SuppressWarnings(\"\"\"\n"
+ + " Lorem ipsum dolor sit amet\n"
+ + " \"\"\")\n"
+ + "public class Thingy {\n"
+ + "}";
+ builder.addSource( new StringReader( source ) );
+ Assertions.assertEquals("\"\"\"\n"
+ + " Lorem ipsum dolor sit amet\n"
+ + " \"\"\"", builder.getClassByName( "Thingy" ).getAnnotations().get( 0 ).getProperty( "value" ).getParameterValue());
+
+ }
+
+ @Test
+ public void testValueArray() {
+ JavaProjectBuilder builder = new JavaProjectBuilder();
+ String source = "@Fields({\n"
+ + " @Field(norms = Norms.NO, analyzer = @Analyzer(definition = \"whitespace_analyzer\")),\n"
+ + " })";
+ builder.addSource( new StringReader( source ) );
+ }
+
+ @Test
+ public void testFQNAnnotation() {
+ JavaProjectBuilder builder = new JavaProjectBuilder();
+ String source = "@Type(type = \"com.example.Type\", parameters = @com.example.Parameter(name = \"class\", value = \"com.example.Object\"))";
+ builder.addSource( new StringReader( source ) );
+ }
+
}
diff --git a/src/test/java/com/thoughtworks/qdox/EnumsTest.java b/src/test/java/com/thoughtworks/qdox/EnumsTest.java
index 269adb4c..689f7d91 100644
--- a/src/test/java/com/thoughtworks/qdox/EnumsTest.java
+++ b/src/test/java/com/thoughtworks/qdox/EnumsTest.java
@@ -227,4 +227,22 @@ public void testMethodInvocation()
new JavaProjectBuilder().addSource(new StringReader(source));
}
+
+ @Test
+ public void testEnumWithLambdaParameter() {
+
+ String source = "public class ClassToTest {\n"
+ + " public static enum Display {\n"
+ + " LOWVALUE(v -> v.toLowerCase() + \"_\");\n"
+ + "\n"
+ + " final Function convert;\n"
+ + "\n"
+ + " private Display(final Function convert) {\n"
+ + " this.convert = convert;\n"
+ + " }\n"
+ + " }\n"
+ + "}";
+
+ new JavaProjectBuilder().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 baa4b9ea..d9f75f24 100644
--- a/src/test/java/com/thoughtworks/qdox/RecordsTest.java
+++ b/src/test/java/com/thoughtworks/qdox/RecordsTest.java
@@ -23,19 +23,25 @@ public class RecordsTest
@Test
public void withTwoFields() {
- String source = "record Rectangle(double length, double width) { }";
+ String source =
+ "/* comment */" +
+ "record Rectangle(double length, double width) { }";
JavaProjectBuilder javaDocBuilder = new JavaProjectBuilder();
javaDocBuilder.addSource( new StringReader(source) );
JavaClass cls = javaDocBuilder.getClassByName("Rectangle");
+ Assertions.assertTrue( cls.getLineNumber() == 1 );
Assertions.assertTrue( cls.isRecord() );
JavaField field = cls.getFieldByName("length");
+ Assertions.assertTrue( field.getLineNumber() == 1 );
Assertions.assertTrue( field.getType().isA("double") );
JavaConstructor constructor = cls.getConstructors().get(0);
JavaParameter lengthParam = constructor.getParameterByName("length");
Assertions.assertTrue( lengthParam != null );
JavaMethod lengthGetter = cls.getMethod( "length", new LinkedList(), false );
Assertions.assertTrue( lengthGetter.getReturns().isA( "double" ) );
+ JavaMethod widthGetter = cls.getMethod( "width", new LinkedList(), false );
+ Assertions.assertTrue( widthGetter.getLineNumber() == 1 );
}
@Test