Skip to content

Commit

Permalink
Merge branch 'paul-hammant:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
shalousun authored Nov 25, 2024
2 parents f9f3683 + f578b01 commit 8b815c4
Show file tree
Hide file tree
Showing 9 changed files with 131 additions and 70 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 3 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
</dependency>
```

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
Expand Down
98 changes: 50 additions & 48 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<name>QDox</name>
<groupId>com.thoughtworks.qdox</groupId>
<artifactId>qdox</artifactId>
<version>2.1.1-SNAPSHOT</version>
<version>2.2.0-SNAPSHOT</version>

<url>https://github.com/paul-hammant/qdox</url>
<description>
Expand Down Expand Up @@ -134,63 +134,56 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4.1</version>
<version>3.4.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<version>3.13.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.3</version>
<version>3.5.2</version>
<configuration>
<reuseForks>false</reuseForks>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<archive>
<manifestEntries>
<Automatic-Module-Name>com.thoughtworks.qdox</Automatic-Module-Name>
</manifestEntries>
</archive>
</configuration>
<version>3.4.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>3.1.1</version>
<version>3.1.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>3.1.1</version>
<version>3.1.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.8.2</version>
<version>3.21.0</version>
<configuration>
<templateFile>${basedir}/src/site/templates/site.vm</templateFile>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>3.0.1</version>
<version>3.1.1</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.3.1</version>
<version>3.5.0</version>
<executions>
<execution>
<id>enforce-maven</id>
Expand All @@ -202,6 +195,9 @@
<requireMavenVersion>
<version>3.0</version>
</requireMavenVersion>
<requireJavaVersion>
<version>11</version>
</requireJavaVersion>
</rules>
</configuration>
</execution>
Expand All @@ -221,10 +217,37 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>default-compile</id>
<configuration>
<release>8</release>
<excludes>
<exclude>module-info.java</exclude>
</excludes>
</configuration>
</execution>
<execution>
<id>module-descriptor</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<release>11</release>
<includes>
<include>module-info.java</include>
</includes>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>de.jflex</groupId>
<artifactId>jflex-maven-plugin</artifactId>
<version>1.8.2</version>
<version>1.9.1</version>
<executions>
<execution>
<goals>
Expand All @@ -243,7 +266,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.1.1</version>
<version>3.5.0</version>
<executions>
<execution>
<id>javacommentparser</id>
Expand Down Expand Up @@ -288,31 +311,10 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>animal-sniffer-maven-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>check-java15</id>
<phase>process-classes</phase>
<goals>
<goal>check</goal>
</goals>
<configuration>
<signature>
<groupId>org.codehaus.mojo.signature</groupId>
<artifactId>java18</artifactId>
<version>1.0</version>
</signature>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.22.1</version>
<version>3.5.2</version>
<executions>
<execution>
<goals>
Expand All @@ -325,7 +327,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-invoker-plugin</artifactId>
<version>3.6.0</version>
<version>3.8.1</version>
<configuration>
<cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
<postBuildHookScript>verify</postBuildHookScript>
Expand Down Expand Up @@ -354,7 +356,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.6.0</version>
<version>3.7.1</version>
<configuration>
<descriptorRefs>
<descriptorRef>project</descriptorRef>
Expand Down Expand Up @@ -383,13 +385,13 @@
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.10.0</version>
<version>5.11.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.11.1</version>
<version>3.26.3</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -494,7 +496,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>3.5.0</version>
<version>3.8.0</version>
<reportSets>
<reportSet>
<reports>
Expand All @@ -512,7 +514,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jxr-plugin</artifactId>
<version>2.3</version>
<version>3.6.0</version>
<reportSets>
<reportSet>
<reports>
Expand All @@ -529,7 +531,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.6.3</version>
<version>3.11.1</version>
<configuration>
<packagenames>com.thoughtworks.qdox.*</packagenames>
<tag name="noinspection" description="IntelliJ Inspection Ignore tag" enabled="false" />
Expand Down
4 changes: 3 additions & 1 deletion src/grammar/lexer.flex
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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); }

Expand Down Expand Up @@ -565,6 +566,7 @@ JavadocEnd = "*"+ "/"
}

<ANNOSTRING> {
"\"\"\"" { codeBody.append("\"\"\""); popState(); appendingToCodeBody=false; return Parser.TEXTBLOCK; }
"\"" { codeBody.append("\""); popState(); appendingToCodeBody=false; return Parser.STRING_LITERAL; }
"\\\"" { codeBody.append("\\\""); }
"\\\\" { codeBody.append("\\\\"); }
Expand Down
8 changes: 7 additions & 1 deletion src/grammar/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ import java.util.Stack;
%token <sval> INTEGER_LITERAL
%token <sval> FLOAT_LITERAL
%token <sval> CHAR_LITERAL
%token <sval> STRING_LITERAL
%token <sval> STRING_LITERAL, TEXTBLOCK
%token <ival> VERTLINE2 AMPERSAND2 VERTLINE CIRCUMFLEX AMPERSAND EQUALS2 NOTEQUALS
%token <ival> LESSTHAN GREATERTHAN LESSEQUALS GREATEREQUALS LESSTHAN2 GREATERTHAN2 GREATERTHAN3
%token <ival> PLUS MINUS STAR SLASH PERCENT TILDE EXCLAMATION
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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
{
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module com.thoughtworks.qdox {
requires java.desktop; // java.beans.Introspector

exports com.thoughtworks.qdox;
exports com.thoughtworks.qdox.model;

}
32 changes: 32 additions & 0 deletions src/test/java/com/thoughtworks/qdox/AnnotationsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
}

}
Loading

0 comments on commit 8b815c4

Please sign in to comment.