Skip to content

Commit 8b815c4

Browse files
authored
Merge branch 'paul-hammant:master' into master
2 parents f9f3683 + f578b01 commit 8b815c4

File tree

9 files changed

+131
-70
lines changed

9 files changed

+131
-70
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ jobs:
99
strategy:
1010
matrix:
1111
os: [ ubuntu-latest , windows-latest ]
12-
java: [ 8, 11 ]
12+
java: [ 11,17 ]
1313
experimental: [ false ]
1414

1515
steps:
16-
- uses: actions/checkout@v4.1.1
17-
- uses: actions/cache@v4.0.0
16+
- uses: actions/checkout@v4.2.2
17+
- uses: actions/cache@v4.1.2
1818
with:
1919
path: ~/.m2/repository
2020
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
2121
restore-keys: |
2222
${{ runner.os }}-maven-
2323
- name: Set up JDK ${{ matrix.java }}
24-
uses: actions/setup-java@v4.0.0
24+
uses: actions/setup-java@v4.5.0
2525
with:
2626
java-version: ${{ matrix.java }}
2727
distribution: adopt

README.md

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ This project used to be on Codehaus, in Subversion. The trunk of that has been g
1212

1313
# Download
1414

15-
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)
15+
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)
16+
17+
Available assets: binary jar | sources jar | javadoc jar | project tar.bz2 | project tar.gz | project zip
1618

1719
# In A Nutshell
1820

@@ -51,20 +53,6 @@ JavaProjectBuilder builder = new JavaProjectBuilder( libraryBuilder );
5153

5254
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.
5355

54-
# Download
55-
56-
QDox is available at the Maven Central. To include the most recent of QDox in your pom, include the following dependency:
57-
58-
```xml
59-
<dependency>
60-
<groupId>${project.groupId}</groupId>
61-
<artifactId>${project.artifactId}</artifactId>
62-
<version>${project.version}</version>
63-
</dependency>
64-
```
65-
66-
Latest stable release - QDox ${project.rel.org.thoughtworks.qdox:qdox}: binary jar | sources jar | javadoc jar | project tar.bz2 | project tar.gz | project zip
67-
6856
# What is using QDox
6957

7058
Project Description How QDox is Used

pom.xml

Lines changed: 50 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<name>QDox</name>
1111
<groupId>com.thoughtworks.qdox</groupId>
1212
<artifactId>qdox</artifactId>
13-
<version>2.1.1-SNAPSHOT</version>
13+
<version>2.2.0-SNAPSHOT</version>
1414

1515
<url>https://github.com/paul-hammant/qdox</url>
1616
<description>
@@ -134,63 +134,56 @@
134134
<plugin>
135135
<groupId>org.apache.maven.plugins</groupId>
136136
<artifactId>maven-clean-plugin</artifactId>
137-
<version>2.4.1</version>
137+
<version>3.4.0</version>
138138
</plugin>
139139
<plugin>
140140
<groupId>org.apache.maven.plugins</groupId>
141141
<artifactId>maven-compiler-plugin</artifactId>
142-
<version>3.11.0</version>
142+
<version>3.13.0</version>
143143
</plugin>
144144
<plugin>
145145
<groupId>org.apache.maven.plugins</groupId>
146146
<artifactId>maven-surefire-plugin</artifactId>
147-
<version>3.2.3</version>
147+
<version>3.5.2</version>
148148
<configuration>
149149
<reuseForks>false</reuseForks>
150150
</configuration>
151151
</plugin>
152152
<plugin>
153153
<groupId>org.apache.maven.plugins</groupId>
154154
<artifactId>maven-jar-plugin</artifactId>
155-
<version>3.3.0</version>
156-
<configuration>
157-
<archive>
158-
<manifestEntries>
159-
<Automatic-Module-Name>com.thoughtworks.qdox</Automatic-Module-Name>
160-
</manifestEntries>
161-
</archive>
162-
</configuration>
155+
<version>3.4.2</version>
163156
</plugin>
164157
<plugin>
165158
<groupId>org.apache.maven.plugins</groupId>
166159
<artifactId>maven-install-plugin</artifactId>
167-
<version>3.1.1</version>
160+
<version>3.1.3</version>
168161
</plugin>
169162
<plugin>
170163
<groupId>org.apache.maven.plugins</groupId>
171164
<artifactId>maven-deploy-plugin</artifactId>
172-
<version>3.1.1</version>
165+
<version>3.1.3</version>
173166
</plugin>
174167
<plugin>
175168
<groupId>org.apache.maven.plugins</groupId>
176169
<artifactId>maven-site-plugin</artifactId>
177-
<version>3.8.2</version>
170+
<version>3.21.0</version>
178171
<configuration>
179172
<templateFile>${basedir}/src/site/templates/site.vm</templateFile>
180173
</configuration>
181174
</plugin>
182175
<plugin>
183176
<groupId>org.apache.maven.plugins</groupId>
184177
<artifactId>maven-release-plugin</artifactId>
185-
<version>3.0.1</version>
178+
<version>3.1.1</version>
186179
</plugin>
187180
</plugins>
188181
</pluginManagement>
189182
<plugins>
190183
<plugin>
191184
<groupId>org.apache.maven.plugins</groupId>
192185
<artifactId>maven-enforcer-plugin</artifactId>
193-
<version>1.3.1</version>
186+
<version>3.5.0</version>
194187
<executions>
195188
<execution>
196189
<id>enforce-maven</id>
@@ -202,6 +195,9 @@
202195
<requireMavenVersion>
203196
<version>3.0</version>
204197
</requireMavenVersion>
198+
<requireJavaVersion>
199+
<version>11</version>
200+
</requireJavaVersion>
205201
</rules>
206202
</configuration>
207203
</execution>
@@ -221,10 +217,37 @@
221217
</execution>
222218
</executions>
223219
</plugin>
220+
<plugin>
221+
<groupId>org.apache.maven.plugins</groupId>
222+
<artifactId>maven-compiler-plugin</artifactId>
223+
<executions>
224+
<execution>
225+
<id>default-compile</id>
226+
<configuration>
227+
<release>8</release>
228+
<excludes>
229+
<exclude>module-info.java</exclude>
230+
</excludes>
231+
</configuration>
232+
</execution>
233+
<execution>
234+
<id>module-descriptor</id>
235+
<goals>
236+
<goal>compile</goal>
237+
</goals>
238+
<configuration>
239+
<release>11</release>
240+
<includes>
241+
<include>module-info.java</include>
242+
</includes>
243+
</configuration>
244+
</execution>
245+
</executions>
246+
</plugin>
224247
<plugin>
225248
<groupId>de.jflex</groupId>
226249
<artifactId>jflex-maven-plugin</artifactId>
227-
<version>1.8.2</version>
250+
<version>1.9.1</version>
228251
<executions>
229252
<execution>
230253
<goals>
@@ -243,7 +266,7 @@
243266
<plugin>
244267
<groupId>org.codehaus.mojo</groupId>
245268
<artifactId>exec-maven-plugin</artifactId>
246-
<version>3.1.1</version>
269+
<version>3.5.0</version>
247270
<executions>
248271
<execution>
249272
<id>javacommentparser</id>
@@ -288,31 +311,10 @@
288311
</execution>
289312
</executions>
290313
</plugin>
291-
<plugin>
292-
<groupId>org.codehaus.mojo</groupId>
293-
<artifactId>animal-sniffer-maven-plugin</artifactId>
294-
<version>1.7</version>
295-
<executions>
296-
<execution>
297-
<id>check-java15</id>
298-
<phase>process-classes</phase>
299-
<goals>
300-
<goal>check</goal>
301-
</goals>
302-
<configuration>
303-
<signature>
304-
<groupId>org.codehaus.mojo.signature</groupId>
305-
<artifactId>java18</artifactId>
306-
<version>1.0</version>
307-
</signature>
308-
</configuration>
309-
</execution>
310-
</executions>
311-
</plugin>
312314
<plugin>
313315
<groupId>org.apache.maven.plugins</groupId>
314316
<artifactId>maven-failsafe-plugin</artifactId>
315-
<version>2.22.1</version>
317+
<version>3.5.2</version>
316318
<executions>
317319
<execution>
318320
<goals>
@@ -325,7 +327,7 @@
325327
<plugin>
326328
<groupId>org.apache.maven.plugins</groupId>
327329
<artifactId>maven-invoker-plugin</artifactId>
328-
<version>3.6.0</version>
330+
<version>3.8.1</version>
329331
<configuration>
330332
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
331333
<postBuildHookScript>verify</postBuildHookScript>
@@ -354,7 +356,7 @@
354356
<plugin>
355357
<groupId>org.apache.maven.plugins</groupId>
356358
<artifactId>maven-assembly-plugin</artifactId>
357-
<version>3.6.0</version>
359+
<version>3.7.1</version>
358360
<configuration>
359361
<descriptorRefs>
360362
<descriptorRef>project</descriptorRef>
@@ -383,13 +385,13 @@
383385
<dependency>
384386
<groupId>org.junit.jupiter</groupId>
385387
<artifactId>junit-jupiter</artifactId>
386-
<version>5.10.0</version>
388+
<version>5.11.3</version>
387389
<scope>test</scope>
388390
</dependency>
389391
<dependency>
390392
<groupId>org.assertj</groupId>
391393
<artifactId>assertj-core</artifactId>
392-
<version>3.11.1</version>
394+
<version>3.26.3</version>
393395
<scope>test</scope>
394396
</dependency>
395397
<dependency>
@@ -494,7 +496,7 @@
494496
<plugin>
495497
<groupId>org.apache.maven.plugins</groupId>
496498
<artifactId>maven-project-info-reports-plugin</artifactId>
497-
<version>3.5.0</version>
499+
<version>3.8.0</version>
498500
<reportSets>
499501
<reportSet>
500502
<reports>
@@ -512,7 +514,7 @@
512514
<plugin>
513515
<groupId>org.apache.maven.plugins</groupId>
514516
<artifactId>maven-jxr-plugin</artifactId>
515-
<version>2.3</version>
517+
<version>3.6.0</version>
516518
<reportSets>
517519
<reportSet>
518520
<reports>
@@ -529,7 +531,7 @@
529531
<plugin>
530532
<groupId>org.apache.maven.plugins</groupId>
531533
<artifactId>maven-javadoc-plugin</artifactId>
532-
<version>3.6.3</version>
534+
<version>3.11.1</version>
533535
<configuration>
534536
<packagenames>com.thoughtworks.qdox.*</packagenames>
535537
<tag name="noinspection" description="IntelliJ Inspection Ignore tag" enabled="false" />

src/grammar/lexer.flex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ UnicodeChar = \\u[a-fA-F0-9]{4}
203203
Id = ([:jletter:]|{UnicodeChar}) ([:jletterdigit:]|{UnicodeChar})*
204204
JavadocEnd = "*"+ "/"
205205

206-
%state JAVADOC JAVADOCTAG JAVADOCLINE CODEBLOCK PARENBLOCK ASSIGNMENT STRING CHAR SINGLELINECOMMENT MULTILINECOMMENT ANNOTATION ANNOSTRING ANNOCHAR ARGUMENTS NAME
206+
%state JAVADOC JAVADOCTAG JAVADOCLINE CODEBLOCK PARENBLOCK ASSIGNMENT STRING CHAR SINGLELINECOMMENT MULTILINECOMMENT ANNOTATION ANNOSTRING ANNOCHAR ARGUMENTS NAME
207207
%state ANNOTATIONTYPE ENUM MODULE RECORD TYPE ANNOTATIONNOARG ATANNOTATION
208208
%state NAME_OR_MODIFIER
209209

@@ -511,6 +511,7 @@ JavadocEnd = "*"+ "/"
511511
"++" { return Parser.PLUSPLUS; }
512512
"--" { return Parser.MINUSMINUS; }
513513

514+
"\"\"\"" { appendingToCodeBody=true; codeBody.append("\"\"\""); pushState(ANNOSTRING); }
514515
"\"" { appendingToCodeBody=true; codeBody.append("\""); pushState(ANNOSTRING); }
515516
"\'" { appendingToCodeBody=true; codeBody.append("\'"); pushState(ANNOCHAR); }
516517

@@ -565,6 +566,7 @@ JavadocEnd = "*"+ "/"
565566
}
566567

567568
<ANNOSTRING> {
569+
"\"\"\"" { codeBody.append("\"\"\""); popState(); appendingToCodeBody=false; return Parser.TEXTBLOCK; }
568570
"\"" { codeBody.append("\""); popState(); appendingToCodeBody=false; return Parser.STRING_LITERAL; }
569571
"\\\"" { codeBody.append("\\\""); }
570572
"\\\\" { codeBody.append("\\\\"); }

src/grammar/parser.y

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ import java.util.Stack;
4949
%token <sval> INTEGER_LITERAL
5050
%token <sval> FLOAT_LITERAL
5151
%token <sval> CHAR_LITERAL
52-
%token <sval> STRING_LITERAL
52+
%token <sval> STRING_LITERAL, TEXTBLOCK
5353
%token <ival> VERTLINE2 AMPERSAND2 VERTLINE CIRCUMFLEX AMPERSAND EQUALS2 NOTEQUALS
5454
%token <ival> LESSTHAN GREATERTHAN LESSEQUALS GREATEREQUALS LESSTHAN2 GREATERTHAN2 GREATERTHAN3
5555
%token <ival> PLUS MINUS STAR SLASH PERCENT TILDE EXCLAMATION
@@ -770,6 +770,7 @@ RecordComponent: Annotations_opt /* ={RecordComponentModifier} */ Type /* =Unann
770770
param.setName($3);
771771
param.setDimensions(0);
772772
param.setVarArgs(false);
773+
param.setLineNumber(lexer.getLine());
773774
builder.addParameter(param);
774775
recordHeaderStack.getFirst().addField(param);
775776
param = new FieldDef();
@@ -785,6 +786,7 @@ VariableArityRecordComponent: Annotations_opt /* ={RecordComponentModifier} */ T
785786
param.setName($4);
786787
param.setDimensions(0);
787788
param.setVarArgs(true);
789+
param.setLineNumber(lexer.getLine());
788790
builder.addParameter(param);
789791
recordHeaderStack.getFirst().addField(param);
790792
param = new FieldDef();
@@ -2017,6 +2019,10 @@ Literal: INTEGER_LITERAL
20172019
{
20182020
String s = lexer.getCodeBody();
20192021
$$ = new ConstantDef(s, Character.class);
2022+
}
2023+
| TEXTBLOCK {
2024+
String s = lexer.getCodeBody();
2025+
$$ = new ConstantDef(s, String.class);
20202026
}
20212027
| STRING_LITERAL
20222028
{

src/main/java/module-info.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module com.thoughtworks.qdox {
2+
requires java.desktop; // java.beans.Introspector
3+
4+
exports com.thoughtworks.qdox;
5+
exports com.thoughtworks.qdox.model;
6+
7+
}

src/test/java/com/thoughtworks/qdox/AnnotationsTest.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,4 +253,36 @@ public void testDoubleEscapedString()
253253
String source = "public class Foo {\n" + "@SuppressWarnings({\"abc\\\\d\"})\n" + "private void bar() { } }";
254254
builder.addSource( new StringReader( source ) );
255255
}
256+
257+
@Test
258+
public void testTextBlock() {
259+
JavaProjectBuilder builder = new JavaProjectBuilder();
260+
String source = "@SuppressWarnings(\"\"\"\n"
261+
+ " Lorem ipsum dolor sit amet\n"
262+
+ " \"\"\")\n"
263+
+ "public class Thingy {\n"
264+
+ "}";
265+
builder.addSource( new StringReader( source ) );
266+
Assertions.assertEquals("\"\"\"\n"
267+
+ " Lorem ipsum dolor sit amet\n"
268+
+ " \"\"\"", builder.getClassByName( "Thingy" ).getAnnotations().get( 0 ).getProperty( "value" ).getParameterValue());
269+
270+
}
271+
272+
@Test
273+
public void testValueArray() {
274+
JavaProjectBuilder builder = new JavaProjectBuilder();
275+
String source = "@Fields({\n"
276+
+ " @Field(norms = Norms.NO, analyzer = @Analyzer(definition = \"whitespace_analyzer\")),\n"
277+
+ " })";
278+
builder.addSource( new StringReader( source ) );
279+
}
280+
281+
@Test
282+
public void testFQNAnnotation() {
283+
JavaProjectBuilder builder = new JavaProjectBuilder();
284+
String source = "@Type(type = \"com.example.Type\", parameters = @com.example.Parameter(name = \"class\", value = \"com.example.Object\"))";
285+
builder.addSource( new StringReader( source ) );
286+
}
287+
256288
}

0 commit comments

Comments
 (0)