Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package qdox for openSUSE:Factory checked in at 2022-01-15 21:45:06 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/qdox (Old) and /work/SRC/openSUSE:Factory/.qdox.new.1892 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "qdox" Sat Jan 15 21:45:06 2022 rev:26 rq:946326 version:2.0.1 Changes: -------- --- /work/SRC/openSUSE:Factory/qdox/qdox.changes 2021-05-02 18:35:14.293172239 +0200 +++ /work/SRC/openSUSE:Factory/.qdox.new.1892/qdox.changes 2022-01-15 21:45:09.977613024 +0100 @@ -1,0 +2,20 @@ +Thu Jan 13 11:45:28 UTC 2022 - Fridrich Strba <[email protected]> + +- Update to version 2.0.1: + * Changes: + + Support Lambda Expression + + Add SEALED / NON_SEALED tokens + + #75 CodeBlock for Annotation with FieldReference should prefix + field with canonical name + + Add UnqualifiedClassInstanceCreationExpression + + updating jflex-maven-plugin to 1.8.2 + + Add reference to grammar documentation and hints to transform + it + + Support Text Blocks + + Support Sealed Classes + + #67 Support records + + #76 test with an @@ in comment + + #64 Get interface via javaProjectBuilder.getClassByName +- Generate ant build file from maven pom and build using ant + +------------------------------------------------------------------- Old: ---- qdox-2.0.0-project.tar.bz2 qdox-MANIFEST.MF New: ---- qdox-2.0.1-project.tar.bz2 qdox-build.xml ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ qdox.spec ++++++ --- /var/tmp/diff_new_pack.EkDuSn/_old 2022-01-15 21:45:10.481613291 +0100 +++ /var/tmp/diff_new_pack.EkDuSn/_new 2022-01-15 21:45:10.489613295 +0100 @@ -1,7 +1,7 @@ # # spec file for package qdox # -# Copyright (c) 2021 SUSE LLC +# Copyright (c) 2022 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,14 +17,15 @@ Name: qdox -Version: 2.0.0 +Version: 2.0.1 Release: 0 Summary: Tool to extract class/interface/method definitions from sources License: Apache-2.0 Group: Development/Libraries/Java URL: https://github.com/paul-hammant/qdox Source0: https://repo1.maven.org/maven2/com/thoughtworks/qdox/qdox/%{version}/%{name}-%{version}-project.tar.bz2 -Source1: qdox-MANIFEST.MF +Source1: qdox-build.xml +BuildRequires: ant BuildRequires: byaccj BuildRequires: fdupes BuildRequires: java-cup-bootstrap @@ -47,64 +48,45 @@ %prep %setup -q +cp %{SOURCE1} build.xml find -name *.jar -delete find -name *.class -delete rm -rf bootstrap -# Fix line endings -sed -i "s|\r||" README.md # We don't need these plugins %pom_remove_plugin :animal-sniffer-maven-plugin +%pom_remove_plugin :maven-assembly-plugin %pom_remove_plugin :maven-failsafe-plugin -%pom_remove_plugin :maven-jflex-plugin +%pom_remove_plugin :maven-invoker-plugin +%pom_remove_plugin :jflex-maven-plugin %pom_remove_plugin :maven-enforcer-plugin - -%pom_xpath_set pom:workingDirectory '${basedir}/src/main/java/com/thoughtworks/qdox/parser/impl' +%pom_remove_plugin :exec-maven-plugin %pom_remove_parent . %build # Generate scanners (upstream does this with maven-jflex-plugin) -# Add the --inputstreamctor option if jflex is upgraded to a version 1.6 or higher -CLASSPATH=$(build-classpath java-cup) \ - jflex -d src/main/java/com/thoughtworks/qdox/parser/impl src/grammar/lexer.flex -CLASSPATH=$(build-classpath java-cup) \ - jflex -d src/main/java/com/thoughtworks/qdox/parser/impl src/grammar/commentlexer.flex - -# Generate the parsers using the command-line that the exec-maven-plugin uses -GRAMMAR_PATH=$(pwd)/src/grammar/commentparser.y && \ - (cd src/main/java/com/thoughtworks/qdox/parser/impl && \ - byaccj -v -Jnorun -Jnoconstruct -Jclass=DefaultJavaCommentParser \ - -Jpackage=com.thoughtworks.qdox.parser.impl ${GRAMMAR_PATH}) -GRAMMAR_PATH=$(pwd)/src/grammar/parser.y && \ - (cd src/main/java/com/thoughtworks/qdox/parser/impl && \ - byaccj -v -Jnorun -Jnoconstruct -Jclass=Parser \ - -Jimplements=CommentHandler -Jsemantic=Value \ - -Jpackage=com.thoughtworks.qdox.parser.impl \ - -Jstack=500 ${GRAMMAR_PATH}) - -# Build artifact -mkdir -p build/classes -javac -d build/classes -source 6 -target 6 \ - $(find src/main/java -name \*.java) -jar cf build/%{name}-%{version}.jar -C build/classes . +jflex -d src/main/java/com/thoughtworks/qdox/parser/impl src/grammar/lexer.flex +jflex -d src/main/java/com/thoughtworks/qdox/parser/impl src/grammar/commentlexer.flex -# Inject OSGi manifests -jar ufm build/%{name}-%{version}.jar %{SOURCE1} +# Generate parsers (upstream does this with exec-maven-plugin) +(cd ./src/main/java/com/thoughtworks/qdox/parser/impl + byaccj -v -Jnorun -Jnoconstruct -Jclass=DefaultJavaCommentParser -Jpackage=com.thoughtworks.qdox.parser.impl ../../../../../../../grammar/commentparser.y + byaccj -v -Jnorun -Jnoconstruct -Jclass=Parser -Jimplements=CommentHandler -Jsemantic=Value -Jpackage=com.thoughtworks.qdox.parser.impl -Jstack=500 ../../../../../../../grammar/parser.y +) -mkdir -p build/apidoc -javadoc -d build/apidoc -source 6 -notimestamp $(find src/main/java -name \*.java) +%ant jar javadoc %install # jar install -dm 0755 %{buildroot}%{_javadir} -install -pm 0644 build/%{name}-%{version}.jar %{buildroot}%{_javadir}/%{name}.jar +install -pm 0644 target/%{name}-%{version}.jar %{buildroot}%{_javadir}/%{name}.jar # pom install -dm 0755 %{buildroot}%{_mavenpomdir} install -pm 0644 pom.xml %{buildroot}%{_mavenpomdir}/%{name}.pom %add_maven_depmap %{name}.pom %{name}.jar -a qdox:qdox # javadoc mkdir -p %{buildroot}%{_javadocdir}/%{name} -cp -aL build/apidoc/* %{buildroot}%{_javadocdir}/%{name} +cp -aL target/site/apidocs/* %{buildroot}%{_javadocdir}/%{name} %fdupes -s %{buildroot}%{_javadocdir} %files -f .mfiles ++++++ qdox-2.0.0-project.tar.bz2 -> qdox-2.0.1-project.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qdox-2.0.0/pom.xml new/qdox-2.0.1/pom.xml --- old/qdox-2.0.0/pom.xml 2019-12-06 20:34:41.000000000 +0100 +++ new/qdox-2.0.1/pom.xml 2021-11-13 15:25:20.000000000 +0100 @@ -10,7 +10,7 @@ <name>QDox</name> <groupId>com.thoughtworks.qdox</groupId> <artifactId>qdox</artifactId> - <version>2.0.0</version> + <version>2.0.1</version> <url>https://github.com/paul-hammant/qdox</url> <description> @@ -36,7 +36,7 @@ <connection>scm:git:https://github.com/paul-hammant/qdox.git</connection> <developerConnection>scm:git:ssh://[email protected]/paul-hammant/qdox.git</developerConnection> <url>https://github.com/paul-hammant/qdox</url> - <tag>qdox-2.0.0</tag> + <tag>qdox-2.0.1</tag> </scm> <developers> @@ -209,8 +209,8 @@ </plugin> <plugin> <groupId>de.jflex</groupId> - <artifactId>maven-jflex-plugin</artifactId> - <version>1.4.3</version> + <artifactId>jflex-maven-plugin</artifactId> + <version>1.8.2</version> <executions> <execution> <goals> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qdox-2.0.0/src/grammar/lexer.flex new/qdox-2.0.1/src/grammar/lexer.flex --- old/qdox-2.0.0/src/grammar/lexer.flex 2019-12-06 20:34:41.000000000 +0100 +++ new/qdox-2.0.1/src/grammar/lexer.flex 2021-11-13 15:25:20.000000000 +0100 @@ -20,6 +20,7 @@ */ import com.thoughtworks.qdox.parser.*; +import java.io.InputStreamReader; import java.util.*; %% @@ -167,6 +168,10 @@ this.writer = writer; } + public JFlexLexer( java.io.InputStream stream ) { + this( new InputStreamReader(stream) ); + } + public JFlexLexer( java.io.InputStream stream, java.io.Writer writer ) { this( stream ); this.writer = writer; @@ -199,7 +204,7 @@ JavadocEnd = "*"+ "/" %state JAVADOC JAVADOCTAG JAVADOCLINE CODEBLOCK PARENBLOCK ASSIGNMENT STRING CHAR SINGLELINECOMMENT MULTILINECOMMENT ANNOTATION ANNOSTRING ANNOCHAR ARGUMENTS NAME -%state ANNOTATIONTYPE ENUM MODULE TYPE ANNOTATIONNOARG ATANNOTATION +%state ANNOTATIONTYPE ENUM MODULE RECORD TYPE ANNOTATIONNOARG ATANNOTATION %state NAME_OR_MODIFIER %% @@ -234,7 +239,7 @@ <ANNOTATIONNOARG> { {WhiteSpace} { popState(); } } -<YYINITIAL, ANNOTATIONNOARG, ANNOTATIONTYPE, ENUM, NAME, TYPE> { +<YYINITIAL, ANNOTATIONNOARG, ANNOTATIONTYPE, ENUM, NAME, RECORD, TYPE> { "." { return Parser.DOT; } "..." { return Parser.DOTDOTDOT; } "," { return Parser.COMMA; } @@ -260,6 +265,10 @@ "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; } "[" { nestingDepth++; return Parser.SQUAREOPEN; } "]" { nestingDepth--; return Parser.SQUARECLOSE; } @@ -421,7 +430,7 @@ } } } -<ENUM, TYPE> { +<ENUM, RECORD, TYPE> { "default" { return Parser.DEFAULT; } } <ANNOTATIONTYPE> { @@ -432,7 +441,7 @@ {Id} / {WhiteSpace}* [;{(] { resetAnnotatedElementLine(); popState(); return Parser.IDENTIFIER; } {Id} { popState(); return Parser.IDENTIFIER; } } -<YYINITIAL, ANNOTATIONNOARG, ANNOTATIONTYPE, ENUM, MODULE, TYPE> { +<YYINITIAL, ANNOTATIONNOARG, ANNOTATIONTYPE, ENUM, MODULE, RECORD, TYPE> { {Id} { return Parser.IDENTIFIER; } } @@ -471,6 +480,8 @@ "[" { return Parser.SQUAREOPEN; } "]" { return Parser.SQUARECLOSE; } + "->" { return Parser.ARROW; } + "," { return Parser.COMMA; } "=" { return Parser.EQUALS; } "*=" { return Parser.STAREQUALS; } @@ -646,12 +657,12 @@ } } -<ASSIGNMENT, YYINITIAL, CODEBLOCK, PARENBLOCK, ENUM, ANNOTATIONTYPE, TYPE> { +<ASSIGNMENT, YYINITIAL, CODEBLOCK, PARENBLOCK, ENUM, ANNOTATIONTYPE, RECORD, TYPE> { "\"" { if (appendingToCodeBody) { codeBody.append('"'); } pushState(STRING); } \' { if (appendingToCodeBody) { codeBody.append('\''); } pushState(CHAR); } } -<ASSIGNMENT, YYINITIAL, CODEBLOCK, PARENBLOCK, ENUM, ANNOTATIONTYPE, ANNOTATION, ATANNOTATION, ARGUMENTS, TYPE, NAME, MODULE > { +<ASSIGNMENT, YYINITIAL, CODEBLOCK, PARENBLOCK, ENUM, ANNOTATIONTYPE, ANNOTATION, ATANNOTATION, ARGUMENTS, RECORD, TYPE, NAME, MODULE > { "//" { if (appendingToCodeBody) { codeBody.append("//"); } pushState(SINGLELINECOMMENT); } "/*" { if (appendingToCodeBody) { codeBody.append("/*"); } pushState(MULTILINECOMMENT); } "/**/" { if (appendingToCodeBody) { codeBody.append("/**/"); } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qdox-2.0.0/src/grammar/parser.y new/qdox-2.0.1/src/grammar/parser.y --- old/qdox-2.0.0/src/grammar/parser.y 2019-12-06 20:34:41.000000000 +0100 +++ new/qdox-2.0.1/src/grammar/parser.y 2021-11-13 15:25:20.000000000 +0100 @@ -28,11 +28,11 @@ import java.util.Stack; %} -%token SEMI DOT DOTDOTDOT COMMA STAR PERCENT EQUALS ANNOSTRING ANNOCHAR SLASH PLUS MINUS +%token SEMI DOT DOTDOTDOT COMMA STAR PERCENT EQUALS ANNOSTRING ANNOCHAR SLASH PLUS MINUS ARROW %token STAREQUALS SLASHEQUALS PERCENTEQUALS PLUSEQUALS MINUSEQUALS LESSTHAN2EQUALS GREATERTHAN2EQUALS GREATERTHAN3EQUALS AMPERSANDEQUALS CIRCUMFLEXEQUALS VERTLINEEQUALS -%token PACKAGE IMPORT PUBLIC PROTECTED PRIVATE STATIC FINAL ABSTRACT NATIVE STRICTFP SYNCHRONIZED TRANSIENT VOLATILE DEFAULT +%token PACKAGE IMPORT PUBLIC PROTECTED PRIVATE STATIC FINAL ABSTRACT NATIVE STRICTFP SYNCHRONIZED TRANSIENT VOLATILE DEFAULT SEALED NON_SEALED %token OPEN MODULE REQUIRES TRANSITIVE EXPORTS OPENS TO USES PROVIDES WITH -%token CLASS INTERFACE ENUM ANNOINTERFACE THROWS EXTENDS IMPLEMENTS SUPER DEFAULT NEW +%token CLASS INTERFACE ENUM RECORD ANNOINTERFACE THROWS EXTENDS IMPLEMENTS SUPER DEFAULT NEW PERMITS %token BRACEOPEN BRACECLOSE SQUAREOPEN SQUARECLOSE PARENOPEN PARENCLOSE %token LESSTHAN GREATERTHAN LESSEQUALS GREATEREQUALS %token LESSTHAN2 GREATERTHAN2 GREATERTHAN3 @@ -57,10 +57,10 @@ %token <sval> SUPER %token <sval> EQUALS STAREQUALS SLASHEQUALS PERCENTEQUALS PLUSEQUALS MINUSEQUALS LESSTHAN2EQUALS GREATERTHAN2EQUALS GREATERTHAN3EQUALS AMPERSANDEQUALS CIRCUMFLEXEQUALS VERTLINEEQUALS %type <type> PrimitiveType ReferenceType ArrayType ClassOrInterfaceType TypeVariable -%type <annoval> Expression Literal Annotation ElementValue ElementValueArrayInitializer +%type <annoval> Expression Literal Annotation ElementValue ElementValueArrayInitializer LambdaExpression %type <annoval> ConditionalExpression ConditionalOrExpression ConditionalAndExpression InclusiveOrExpression ExclusiveOrExpression AndExpression %type <annoval> EqualityExpression RelationalExpression ShiftExpression AdditiveExpression MultiplicativeExpression -%type <annoval> UnaryExpression UnaryExpressionNotPlusMinus PreIncrementExpression PreDecrementExpression Primary PrimaryNoNewArray ArrayCreationExpression MethodInvocation MethodReference ClassInstanceCreationExpression +%type <annoval> UnaryExpression UnaryExpressionNotPlusMinus PreIncrementExpression PreDecrementExpression Primary PrimaryNoNewArray ArrayCreationExpression MethodInvocation MethodReference ClassInstanceCreationExpression UnqualifiedClassInstanceCreationExpression %type <annoval> PostfixExpression PostIncrementExpression PostDecrementExpression CastExpression Assignment LeftHandSide AssignmentExpression %type <ival> Dims Dims_opt %type <sval> QualifiedIdentifier TypeDeclSpecifier MethodBody AssignmentOperator ModuleName @@ -68,7 +68,37 @@ %% // Source: Java Language Specification - Third Edition -// The Java(TM) Language Specification - Java SE 8 Edition ( Chapter 19. Syntax ) +// The Java(TM) Language Specification - Java SE 17 Edition ( Chapter 19. Syntax ) +// +// Grammar Notation (Chapter 2.4) +// The syntax {x} on the right-hand side of a production denotes zero or more occurrences of x. +// +// The syntax [x] on the right-hand side of a production denotes zero or one occurrences of x. +// That is, x is an optional symbol. The alternative which contains the optional symbol actually defines two alternatives: one that omits the optional symbol and one that includes it. +// +// ** Transforming ** +// // Statement: {Key} +// Statement: Keys_opt +// ; +// +// // Key: value +// Key: value +// ; +// Keys_opt: +// | Keys_opt Key +// ; +// +// +// // Statement: [Key] +// Statement: Key_opt +// ; +// +// // Key: value +// Key: value +// ; +// Key_opt: +// | Key +// ; // ------------------------------ // Productions from ???7 (Packages) @@ -256,12 +286,14 @@ // ClassDeclaration: // NormalClassDeclaration // EnumDeclaration +// RecordDeclaration ClassDeclaration: NormalClassDeclaration | EnumDeclaration + | RecordDeclaration ; -// NormalClassDeclaration: -// {ClassModifier} class Identifier [TypeParameters] [Superclass] [Superinterfaces] ClassBody +// NormalClassDeclaration: +// {ClassModifier} class TypeIdentifier [TypeParameters] [ClassExtends] [ClassImplements] [ClassPermits] ClassBody NormalClassDeclaration: Modifiers_opt CLASS IDENTIFIER { cls.setType(ClassDef.CLASS); @@ -269,7 +301,7 @@ cls.getModifiers().addAll(modifiers); modifiers.clear(); cls.setName( $3 ); } - TypeParameters_opt Superclass_opt Superinterfaces_opt + TypeParameters_opt Superclass_opt ClassImplements_opt ClassPermits_opt { cls.setTypeParameters(typeParams); builder.beginClass(cls); @@ -308,9 +340,9 @@ } ; -// Superinterfaces: +// ClassImplements: // implements InterfaceTypeList -Superinterfaces_opt: +ClassImplements_opt: | IMPLEMENTS TypeList { cls.getImplements().addAll( typeList ); @@ -322,6 +354,14 @@ // InterfaceType {, InterfaceType} //// -> InterfaceTypeList is for QDox the same as TypeList +// ClassPermits: +// permits TypeName {, TypeName} +ClassPermits: PERMITS TypeList + ; +ClassPermits_opt: + | ClassPermits + ; + // ClassBody: // { { ClassBodyDeclaration } } ClassBody: BRACEOPEN ClassBodyDeclarations_opt BRACECLOSE @@ -609,7 +649,7 @@ // Primary . [TypeArguments] super ( [ArgumentList] ) ; // EnumDeclaration: -// {ClassModifier} enum Identifier [Superinterfaces] EnumBody +// {ClassModifier} enum Identifier [ClassImplements] EnumBody EnumDeclaration: Modifiers_opt ENUM IDENTIFIER { cls.setLineNumber(lexer.getLine()); @@ -620,7 +660,7 @@ cls = new ClassDef(); fieldType = new TypeDef($3, 0); } - Superinterfaces_opt EnumBody + ClassImplements_opt EnumBody ; // EnumBody: @@ -669,6 +709,38 @@ | SEMI ClassBodyDeclarations_opt ; +// RecordDeclaration: +// {ClassModifier} record TypeIdentifier [TypeParameters] RecordHeader [ClassImplements] RecordBody +RecordDeclaration: Modifiers_opt RECORD IDENTIFIER TypeParameters_opt RecordHeader ClassImplements_opt RecordBody + +// RecordHeader: +// ( [RecordComponentList] ) +RecordHeader: PARENOPEN RecordComponentList_opt PARENCLOSE + +// RecordComponentList: +// RecordComponent {, RecordComponent} +RecordComponentList: RecordComponentList COMMA RecordComponent + | RecordComponent + ; +RecordComponentList_opt: + | RecordComponentList + ; + +// RecordComponent: +// {RecordComponentModifier} UnannType Identifier +// VariableArityRecordComponent +RecordComponent: Annotations_opt /* ={RecordComponentModifier} */ Type /* =UnannType */ IDENTIFIER + | VariableArityRecordComponent + ; + +// VariableArityRecordComponent: +// {RecordComponentModifier} UnannType {Annotation} ... Identifier +VariableArityRecordComponent: Annotations_opt /* ={RecordComponentModifier} */ Type /* =UnannType */ DOTDOTDOT IDENTIFIER + +// RecordBody: +// { {RecordBodyDeclaration} } +RecordBody: CODEBLOCK + // ----------------------------- // Productions from ???9 (Interfaces) // ----------------------------- @@ -680,15 +752,15 @@ | AnnotationTypeDeclaration ; -// NormalInterfaceDeclaration: -// {InterfaceModifier} interface Identifier [TypeParameters] [ExtendsInterfaces] InterfaceBody +// NormalInterfaceDeclaration: +// {InterfaceModifier} interface TypeIdentifier [TypeParameters] [InterfaceExtends] [InterfacePermits] InterfaceBody NormalInterfaceDeclaration: Modifiers_opt INTERFACE { cls.setType(ClassDef.INTERFACE); cls.setLineNumber(lexer.getLine()); cls.getModifiers().addAll(modifiers); modifiers.clear(); } - IDENTIFIER TypeParameters_opt ExtendsInterfaces_opt + IDENTIFIER TypeParameters_opt InterfaceExtends_opt InterfacePermits_opt { cls.setName( $4 ); cls.setTypeParameters(typeParams); @@ -703,16 +775,24 @@ // ExtendsInterfaces: // extends InterfaceTypeList -ExtendsInterfaces: EXTENDS TypeList +InterfaceExtends: EXTENDS TypeList { cls.getExtends().addAll( typeList ); typeList.clear(); } ; -ExtendsInterfaces_opt: - | ExtendsInterfaces +InterfaceExtends_opt: + | InterfaceExtends ; +// InterfacePermits: +// permits TypeName {, TypeName} +InterfacePermits: PERMITS TypeList + ; +InterfacePermits_opt : + | InterfacePermits + ; + // InterfaceBody: // { {InterfaceMemberDeclaration} } // InterfaceMemberDeclaration: @@ -933,24 +1013,30 @@ ; // ClassInstanceCreationExpression: -// new [TypeArguments] {Annotation} Identifier [TypeArgumentsOrDiamond] ( [ArgumentList] ) [ClassBody] -// ExpressionName . new [TypeArguments] {Annotation} Identifier [TypeArgumentsOrDiamond] ( [ArgumentList] ) [ClassBody] -// Primary . new [TypeArguments] {Annotation} Identifier [TypeArgumentsOrDiamond] ( [ArgumentList] ) [ClassBody] -//// TypeArguments_opt confuses parser -ClassInstanceCreationExpression: NEW TypeArguments IDENTIFIER TypeArgumentsOrDiamond_opt PARENOPEN ArgumentList_opt PARENCLOSE CODEBLOCK_opt - { - CreatorDef creator = new CreatorDef(); - creator.setCreatedName( $3 ); - $$ = creator; - } - | NEW IDENTIFIER TypeArgumentsOrDiamond_opt PARENOPEN ArgumentList_opt PARENCLOSE CODEBLOCK_opt - { - CreatorDef creator = new CreatorDef(); - creator.setCreatedName( $2 ); - $$ = creator; - } +// UnqualifiedClassInstanceCreationExpression +// ExpressionName . UnqualifiedClassInstanceCreationExpression +// Primary . UnqualifiedClassInstanceCreationExpression +ClassInstanceCreationExpression: UnqualifiedClassInstanceCreationExpression + | Primary DOT UnqualifiedClassInstanceCreationExpression ; +// UnqualifiedClassInstanceCreationExpression: +// new [TypeArguments] ClassOrInterfaceTypeToInstantiate ( [ArgumentList] ) [ClassBody] +//// TypeArguments_opt confuses parser +UnqualifiedClassInstanceCreationExpression: NEW TypeArguments IDENTIFIER TypeArgumentsOrDiamond_opt PARENOPEN ArgumentList_opt PARENCLOSE CODEBLOCK_opt + { + CreatorDef creator = new CreatorDef(); + creator.setCreatedName( $3 ); + $$ = creator; + } + | NEW IDENTIFIER TypeArgumentsOrDiamond_opt PARENOPEN ArgumentList_opt PARENCLOSE CODEBLOCK_opt + { + CreatorDef creator = new CreatorDef(); + creator.setCreatedName( $2 ); + $$ = creator; + } + ; + CODEBLOCK_opt: | CODEBLOCK ; @@ -1095,20 +1181,36 @@ // Expression: // LambdaExpression // AssignmentExpression -Expression: AssignmentExpression +Expression: LambdaExpression + | AssignmentExpression ; // LambdaExpression: // LambdaParameters -> LambdaBody +LambdaExpression: LambdaParameters ARROW LambdaBody { $$ = new LambdaDef(); } + ; + // LambdaParameters: // Identifier // ( [FormalParameterList] ) // ( InferredFormalParameterList ) +LambdaParameters: IDENTIFIER + | PARENOPEN FormalParameterList_opt PARENCLOSE + | PARENOPEN InferredFormalParameterList PARENCLOSE + ; + // InferredFormalParameterList: // Identifier {, Identifier} +InferredFormalParameterList: InferredFormalParameterList COMMA IDENTIFIER + | IDENTIFIER + ; + // LambdaBody: // Expression // Block +LambdaBody: Expression + | CODEBLOCK + ; // AssignmentExpression: // ConditionalExpression @@ -1708,19 +1810,44 @@ Modifiers_opt: | Modifiers_opt Modifier; -// Modifier: -// Annotation -// public -// protected -// private -// static -// abstract -// final -// native -// synchronized -// transient -// volatile -// strictfp +// AnnotationInterfaceElementModifier: +// (one of) +// Annotation public +// abstract +// ClassModifier: +// (one of) +// Annotation public protected private +// abstract static final sealed non-sealed strictfp +// ConstantModifier: +// (one of) +// Annotation public +// static final +// ConstructorModifier: +// (one of) +// Annotation public protected private +// EnumConstantModifier: +// Annotation +// FieldModifier: +// (one of) +// Annotation public protected private +// static final transient volatile +// InterfaceModifier: +// (one of) +// Annotation public protected private +// abstract static sealed non-sealed strictfp +// InterfaceMethodModifier: +// (one of) +// Annotation public private +// abstract default static strictfp +// MethodModifier: +// (one of) +// Annotation public protected private +// abstract static final synchronized native strictfp +// RecordComponentModifier: +// Annotation +// VariableModifier: +// Annotation +// final Modifier: Annotation | PUBLIC { @@ -1734,6 +1861,10 @@ { modifiers.add("private"); } + | ABSTRACT + { + modifiers.add("abstract"); + } | STATIC { modifiers.add("static"); @@ -1742,9 +1873,17 @@ { modifiers.add("final"); } - | ABSTRACT + | SEALED { - modifiers.add("abstract"); + modifiers.add("sealed"); + } + | NON_SEALED + { + modifiers.add("non-sealed"); + } + | STRICTFP + { + modifiers.add("strictfp"); } | NATIVE { @@ -1762,14 +1901,11 @@ { modifiers.add("transient"); } - | STRICTFP - { - modifiers.add("strictfp"); - } | DEFAULT { modifiers.add("default"); } + | ; Arguments_opt: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qdox-2.0.0/src/main/java/com/thoughtworks/qdox/builder/impl/DefaultJavaAnnotationAssembler.java new/qdox-2.0.1/src/main/java/com/thoughtworks/qdox/builder/impl/DefaultJavaAnnotationAssembler.java --- old/qdox-2.0.0/src/main/java/com/thoughtworks/qdox/builder/impl/DefaultJavaAnnotationAssembler.java 2019-12-06 20:34:41.000000000 +0100 +++ new/qdox-2.0.1/src/main/java/com/thoughtworks/qdox/builder/impl/DefaultJavaAnnotationAssembler.java 2021-11-13 15:25:20.000000000 +0100 @@ -80,6 +80,7 @@ import com.thoughtworks.qdox.parser.expression.FieldRefDef; import com.thoughtworks.qdox.parser.expression.GreaterEqualsDef; import com.thoughtworks.qdox.parser.expression.GreaterThanDef; +import com.thoughtworks.qdox.parser.expression.LambdaDef; import com.thoughtworks.qdox.parser.expression.LessEqualsDef; import com.thoughtworks.qdox.parser.expression.LessThanDef; import com.thoughtworks.qdox.parser.expression.LogicalAndDef; @@ -466,4 +467,9 @@ { return null; } + @Override + public AnnotationValue transform( LambdaDef lambdaDef ) + { + return null; + } } \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qdox-2.0.0/src/main/java/com/thoughtworks/qdox/builder/impl/EvaluatingVisitor.java new/qdox-2.0.1/src/main/java/com/thoughtworks/qdox/builder/impl/EvaluatingVisitor.java --- old/qdox-2.0.0/src/main/java/com/thoughtworks/qdox/builder/impl/EvaluatingVisitor.java 2019-12-06 20:34:41.000000000 +0100 +++ new/qdox-2.0.1/src/main/java/com/thoughtworks/qdox/builder/impl/EvaluatingVisitor.java 2021-11-13 15:25:20.000000000 +0100 @@ -41,6 +41,7 @@ import com.thoughtworks.qdox.model.expression.FieldRef; import com.thoughtworks.qdox.model.expression.GreaterEquals; import com.thoughtworks.qdox.model.expression.GreaterThan; +import com.thoughtworks.qdox.model.expression.Lambda; import com.thoughtworks.qdox.model.expression.LessEquals; import com.thoughtworks.qdox.model.expression.LessThan; import com.thoughtworks.qdox.model.expression.LogicalAnd; @@ -1025,4 +1026,10 @@ { throw new IllegalArgumentException( "Cannot evaluate '" + methodInvocation + "'." ); } + + @Override + public Object visit( Lambda lambda ) + { + throw new IllegalArgumentException( "Cannot evaluate '" + lambda + "'." ); + } } \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qdox-2.0.0/src/main/java/com/thoughtworks/qdox/model/expression/ExpressionVisitor.java new/qdox-2.0.1/src/main/java/com/thoughtworks/qdox/model/expression/ExpressionVisitor.java --- old/qdox-2.0.0/src/main/java/com/thoughtworks/qdox/model/expression/ExpressionVisitor.java 2019-12-06 20:34:41.000000000 +0100 +++ new/qdox-2.0.1/src/main/java/com/thoughtworks/qdox/model/expression/ExpressionVisitor.java 2021-11-13 15:25:20.000000000 +0100 @@ -103,4 +103,6 @@ Object visit( MethodInvocation methodInvocation ); + Object visit( Lambda lambda ); + } \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qdox-2.0.0/src/main/java/com/thoughtworks/qdox/model/expression/FieldRef.java new/qdox-2.0.1/src/main/java/com/thoughtworks/qdox/model/expression/FieldRef.java --- old/qdox-2.0.0/src/main/java/com/thoughtworks/qdox/model/expression/FieldRef.java 2019-12-06 20:34:41.000000000 +0100 +++ new/qdox-2.0.1/src/main/java/com/thoughtworks/qdox/model/expression/FieldRef.java 2021-11-13 15:25:20.000000000 +0100 @@ -1,5 +1,7 @@ package com.thoughtworks.qdox.model.expression; +import java.util.List; + /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -94,7 +96,15 @@ @Override public String toString() { - return getName(); + JavaField field = getField(); + if ( field != null && !getDeclaringClass().equals( field.getDeclaringClass() ) ) + { + return field.getDeclaringClass().getCanonicalName() + "." + field.getName(); + } + else + { + return name; + } } public void setDeclaringClass( JavaClass declaringClass ) @@ -139,7 +149,7 @@ { field = javaClass.getFieldByName( getNamePart( i ) ); - if ( field == null ) + if ( field != null ) { break; } @@ -177,6 +187,33 @@ } } } + } + + if ( field == null ) + { + ClassLibrary classLibrary = getClassLibrary(); + if ( classLibrary != null ) + { + List<String> imports = getDeclaringClass().getSource().getImports(); + for ( String i : imports ) + { + if ( i.startsWith( "static" ) ) + { + String member = i.substring( i.lastIndexOf( '.' ) + 1 ); + if ( "*".equals( member ) || getNamePrefix( 0 ).equals( member ) ) + { + String className = i.substring( 7, i.lastIndexOf( '.' ) ).trim(); + JavaClass javaClass = classLibrary.getJavaClass( className ); + JavaField tmpField = javaClass.getFieldByName( member ); + if ( tmpField != null && ( javaClass.isInterface() || tmpField.isStatic() ) ) + { + field = tmpField; + break; + } + } + } + } + } } } return field; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qdox-2.0.0/src/main/java/com/thoughtworks/qdox/model/expression/Lambda.java new/qdox-2.0.1/src/main/java/com/thoughtworks/qdox/model/expression/Lambda.java --- old/qdox-2.0.0/src/main/java/com/thoughtworks/qdox/model/expression/Lambda.java 1970-01-01 01:00:00.000000000 +0100 +++ new/qdox-2.0.1/src/main/java/com/thoughtworks/qdox/model/expression/Lambda.java 2021-11-13 15:25:20.000000000 +0100 @@ -0,0 +1,17 @@ +package com.thoughtworks.qdox.model.expression; + +public class Lambda implements AnnotationValue +{ + @Override + public Object getParameterValue() + { + return ""; + } + + @Override + public Object accept( ExpressionVisitor visitor ) + { + return visitor.visit( this ); + } + +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qdox-2.0.0/src/main/java/com/thoughtworks/qdox/parser/expression/ElemValueTransformer.java new/qdox-2.0.1/src/main/java/com/thoughtworks/qdox/parser/expression/ElemValueTransformer.java --- old/qdox-2.0.0/src/main/java/com/thoughtworks/qdox/parser/expression/ElemValueTransformer.java 2019-12-06 20:34:41.000000000 +0100 +++ new/qdox-2.0.1/src/main/java/com/thoughtworks/qdox/parser/expression/ElemValueTransformer.java 2021-11-13 15:25:20.000000000 +0100 @@ -101,4 +101,6 @@ U transform( CreatorDef newCreator ); + U transform( LambdaDef lambdaDef ); + } \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qdox-2.0.0/src/main/java/com/thoughtworks/qdox/parser/expression/LambdaDef.java new/qdox-2.0.1/src/main/java/com/thoughtworks/qdox/parser/expression/LambdaDef.java --- old/qdox-2.0.0/src/main/java/com/thoughtworks/qdox/parser/expression/LambdaDef.java 1970-01-01 01:00:00.000000000 +0100 +++ new/qdox-2.0.1/src/main/java/com/thoughtworks/qdox/parser/expression/LambdaDef.java 2021-11-13 15:25:20.000000000 +0100 @@ -0,0 +1,29 @@ +package com.thoughtworks.qdox.parser.expression; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +public class LambdaDef extends ExpressionDef +{ + @Override + public <U> U transform( ElemValueTransformer<U> transformer ) + { + return transformer.transform( this ); + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qdox-2.0.0/src/test/java/com/thoughtworks/qdox/JavaProjectBuilderTest.java new/qdox-2.0.1/src/test/java/com/thoughtworks/qdox/JavaProjectBuilderTest.java --- old/qdox-2.0.0/src/test/java/com/thoughtworks/qdox/JavaProjectBuilderTest.java 2019-12-06 20:34:42.000000000 +0100 +++ new/qdox-2.0.1/src/test/java/com/thoughtworks/qdox/JavaProjectBuilderTest.java 2021-11-13 15:25:20.000000000 +0100 @@ -1,6 +1,5 @@ package com.thoughtworks.qdox; -import static org.junit.Assert.assertTrue; import static org.mockito.Matchers.any; import static org.mockito.Matchers.same; import static org.mockito.Mockito.mock; @@ -1658,6 +1657,67 @@ assertTrue( classA.getImplements().equals( Arrays.asList( builder.getClassByName( "Itf2" ) ) ) ); } + // Github #64 + public void testGetInterface() + { + JavaProjectBuilder javaProjectBuilder = new JavaProjectBuilder(); + javaProjectBuilder.addSourceTree( new File( "src/main/java" ) ); + JavaClass intrfc = javaProjectBuilder.getClassByName( "org.thoughtworks.qdox.Searcher" ); + assertNotNull(intrfc); + + JavaClass clss = javaProjectBuilder.getClassByName( "org.thoughtworks.qdox.JavaProjectBuilder" ); + assertNotNull(clss); + } + + // github #73 + public void testLambdaExpression() { + String source = "public enum GenerateType {" + + "ENTITY(\"entity\", (mojo, biConsumer) -> {} )" + + "}"; + + builder.addSource( new StringReader( source ) ); + } + + // github #75 + public void testAnnotationWithConstant() { + String constantSource = "package com.xenoamess;\n" + + "public interface Constants {\n" + + " public String STATIC_STRING_A=\"SOME_VALUE\";" + "}"; + builder.addSource( new StringReader( constantSource ) ); + + String source = "import static com.xenoamess.Constants.STATIC_STRING_A;\n" + + "\n" + "public class ClassA{\n" + + " @AnnotationA(annotationFieldA = STATIC_STRING_A)\n" + + " public void functionA(){\n" + " }\n" + + "}"; + JavaMethod method = + builder.addSource( new StringReader( source ) ).getClassByName( "ClassA" ).getMethods().get( 0 ); + assertEquals( "@AnnotationA(annotationFieldA=com.xenoamess.Constants.STATIC_STRING_A)\n", + method.getAnnotations().get( 0 ).getCodeBlock() ); + } + + // Github #76 + public void testAtInComment() throws Exception + { + String source = "// Generated by the protocol buffer compiler. DO NOT EDIT!\n" + + "// source: model.proto\n" + + "\n" + + "public interface ModelOrBuilder {\n" + + " // @@protoc_insertion_point(interface_extends:Model)\n" + + "\n" + + " /**\n" + + " * <code>string name = 1;</code>\n" + + " */\n" + + " java.lang.String getName();\n" + + " /**\n" + + " * <code>string name = 1;</code>\n" + + " */\n" + + " String getNameBytes();\n" + + "}"; + JavaClass clazz = builder.addSource( new StringReader( source ) ).getClassByName( "ModelOrBuilder" ); + assertEquals( 0, clazz.getMethods().get( 0 ).getAnnotations().size() ); + } + public void testGenericEnumMethod() throws Exception { String source = "package java.time.temporal;\r\n" + "public final class IsoFields {\r\n" + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qdox-2.0.0/src/test/java/com/thoughtworks/qdox/RecordsTest.java new/qdox-2.0.1/src/test/java/com/thoughtworks/qdox/RecordsTest.java --- old/qdox-2.0.0/src/test/java/com/thoughtworks/qdox/RecordsTest.java 1970-01-01 01:00:00.000000000 +0100 +++ new/qdox-2.0.1/src/test/java/com/thoughtworks/qdox/RecordsTest.java 2021-11-13 15:25:20.000000000 +0100 @@ -0,0 +1,141 @@ +package com.thoughtworks.qdox; + +import java.io.StringReader; + +import org.junit.Test; + +/** + * Examples from <a href="https://docs.oracle.com/en/java/javase/16/language/records.html">https://docs.oracle.com/en/java/javase/16/language/records.html</a> + * + * @author Robert Scholte + */ +public class RecordsTest +{ + private JavaProjectBuilder builder = new JavaProjectBuilder(); + + @Test + public void withTwoFields() { + String source = "record Rectangle(double length, double width) { }"; + builder.addSource( new StringReader(source) ); + } + + @Test + public void withCanonicalConstructor() { + String source = "record Rectangle(double length, double width) {\n" + + " public Rectangle(double length, double width) {\n" + + " if (length <= 0 || width <= 0) {\n" + + " throw new java.lang.IllegalArgumentException(\n" + + " String.format(\"Invalid dimensions: %f, %f\", length, width));\n" + + " }\n" + + " this.length = length;\n" + + " this.width = width;\n" + + " }\n" + + "}"; + builder.addSource( new StringReader(source) ); + } + + @Test + public void withCompactConstructor() { + String source = "record Rectangle(double length, double width) {\n" + + " public Rectangle {\n" + + " if (length <= 0 || width <= 0) {\n" + + " throw new java.lang.IllegalArgumentException(\n" + + " String.format(\"Invalid dimensions: %f, %f\", length, width));\n" + + " }\n" + + " }\n" + + "}"; + builder.addSource( new StringReader(source) ); + } + + @Test + public void withPublicAccessorMethod() { + String source = "record Rectangle(double length, double width) {\n" + + " \n" + + " // Public accessor method\n" + + " public double length() {\n" + + " System.out.println(\"Length is \" + length);\n" + + " return length;\n" + + " }\n" + + "}"; + builder.addSource( new StringReader(source) ); + } + + @Test + public void withStaticMembers() { + String source = "record Rectangle(double length, double width) {\n" + + " \n" + + " // Static field\n" + + " static double goldenRatio;\n" + + "\n" + + " // Static initializer\n" + + " static {\n" + + " goldenRatio = (1 + Math.sqrt(5)) / 2;\n" + + " }\n" + + "\n" + + " // Static method\n" + + " public static Rectangle createGoldenRectangle(double width) {\n" + + " return new Rectangle(width, width * goldenRatio);\n" + + " }\n" + + "}"; + builder.addSource( new StringReader(source) ); + } + + @Test + public void withNonStaticMembers() { + String source = "record Rectangle(double length, double width) {\n" + + "\n" + + " // Field declarations must be static:\n" + + " BiFunction<Double, Double, Double> diagonal;\n" + + "\n" + + " // Instance initializers are not allowed in records:\n" + + " {\n" + + " diagonal = (x, y) -> Math.sqrt(x*x + y*y);\n" + + " }\n" + + "}"; + builder.addSource( new StringReader(source) ); + } + + @Test + public void withNestedRecord() { + String source = "record Rectangle(double length, double width) {\n" + + "\n" + + " // Nested record class\n" + + " record RotationAngle(double angle) {\n" + + " public RotationAngle {\n" + + " angle = Math.toRadians(angle);\n" + + " }\n" + + " }\n" + + " \n" + + " // Public instance method\n" + + " public Rectangle getRotatedRectangleBoundingBox(double angle) {\n" + + " RotationAngle ra = new RotationAngle(angle);\n" + + " double x = Math.abs(length * Math.cos(ra.angle())) +\n" + + " Math.abs(width * Math.sin(ra.angle()));\n" + + " double y = Math.abs(length * Math.sin(ra.angle())) +\n" + + " Math.abs(width * Math.cos(ra.angle()));\n" + + " return new Rectangle(x, y);\n" + + " }\n" + + "}"; + builder.addSource( new StringReader(source) ); + } + + @Test + public void withGenerics() { + String source = "record Triangle<C extends Coordinate> (C top, C left, C right) { }"; + builder.addSource( new StringReader(source) ); + } + + @Test + public void withInterface() { + String source = "record Customer(String... data) implements Billable { }"; + builder.addSource( new StringReader(source) ); + } + + @Test + public void withAnnotatedParameters() { + String source = "record Rectangle(\n" + + " @GreaterThanZero double length,\n" + + " @GreaterThanZero double width) { }"; + builder.addSource( new StringReader(source) ); + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qdox-2.0.0/src/test/java/com/thoughtworks/qdox/SealedClassesTest.java new/qdox-2.0.1/src/test/java/com/thoughtworks/qdox/SealedClassesTest.java --- old/qdox-2.0.0/src/test/java/com/thoughtworks/qdox/SealedClassesTest.java 1970-01-01 01:00:00.000000000 +0100 +++ new/qdox-2.0.1/src/test/java/com/thoughtworks/qdox/SealedClassesTest.java 2021-11-13 15:25:20.000000000 +0100 @@ -0,0 +1,42 @@ +package com.thoughtworks.qdox; + +import java.io.StringReader; + +import org.junit.Test; + +/** + * Examples from <a href="https://docs.oracle.com/en/java/javase/16/language/sealed-classes-and-interfaces.html">https://docs.oracle.com/en/java/javase/16/language/sealed-classes-and-interfaces.html</a> + * @author Robert Scholte + */ +public class SealedClassesTest +{ + private JavaProjectBuilder builder = new JavaProjectBuilder(); + + @Test + public void sealedClass() { + String source = "public sealed class Shape\r\n" + + " permits Circle, Square, Rectangle {\r\n" + + "}"; + builder.addSource( new StringReader(source) ); + } + + @Test + public void nonSealedClass() { + String source = "public non-sealed class Square extends Shape {\r\n" + + " public double side;\r\n" + + "}"; + builder.addSource( new StringReader(source) ); + } + + @Test + public void sealedInterface() { + String source = "public sealed interface Shape permits Polygon {}"; + builder.addSource( new StringReader(source) ); + } + + @Test + public void nonSealedInterface() { + String source = "public non-sealed interface Polygon extends Shape { }"; + builder.addSource( new StringReader(source) ); + } +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qdox-2.0.0/src/test/java/com/thoughtworks/qdox/TextBlocksTest.java new/qdox-2.0.1/src/test/java/com/thoughtworks/qdox/TextBlocksTest.java --- old/qdox-2.0.0/src/test/java/com/thoughtworks/qdox/TextBlocksTest.java 1970-01-01 01:00:00.000000000 +0100 +++ new/qdox-2.0.1/src/test/java/com/thoughtworks/qdox/TextBlocksTest.java 2021-11-13 15:25:20.000000000 +0100 @@ -0,0 +1,34 @@ +package com.thoughtworks.qdox; + +import static org.junit.Assert.assertEquals; + +import java.io.StringReader; + +import org.junit.Test; + +import com.thoughtworks.qdox.model.JavaField; +import com.thoughtworks.qdox.model.JavaSource; + +/** + * Examples from <a href="https://docs.oracle.com/en/java/javase/16/text-blocks/index.html">https://docs.oracle.com/en/java/javase/16/text-blocks/index.html</a> + * @author Robert Scholte + * + */ +public class TextBlocksTest +{ + private JavaProjectBuilder builder = new JavaProjectBuilder(); + + @Test + public void test() + { + String source = "interface Something { " + + "// Using a text block\r\n" + + "String tbName = \"\"\"\r\n" + + " Pat Q. Smith\"\"\"; }"; + JavaSource javaSource = builder.addSource( new StringReader( source ) ); + JavaField javaField = javaSource.getClasses().get( 0 ).getFieldByName( "tbName" ); + assertEquals( "\"\"\"\r\n" + + " Pat Q. Smith\"\"\"", javaField.getInitializationExpression() ); + } + +} diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/qdox-2.0.0/src/test/java/com/thoughtworks/qdox/builder/impl/EvaluatingVisitorTest.java new/qdox-2.0.1/src/test/java/com/thoughtworks/qdox/builder/impl/EvaluatingVisitorTest.java --- old/qdox-2.0.0/src/test/java/com/thoughtworks/qdox/builder/impl/EvaluatingVisitorTest.java 2019-12-06 20:34:42.000000000 +0100 +++ new/qdox-2.0.1/src/test/java/com/thoughtworks/qdox/builder/impl/EvaluatingVisitorTest.java 2021-11-13 15:25:20.000000000 +0100 @@ -493,11 +493,10 @@ } JavaField nonStaticNonFinalfield = mock( JavaField.class ); - JavaClass declaringClass = mock( JavaClass.class ); when( declaringClass.getFieldByName( "fieldname" ) ).thenReturn( nonStaticNonFinalfield ); + when( nonStaticNonFinalfield.getDeclaringClass() ).thenReturn( declaringClass ); - JavaClass annotatedClass = mock( JavaClass.class ); ref.setDeclaringClass( declaringClass ); try { ++++++ qdox-build.xml ++++++ <?xml version="1.0" encoding="UTF-8"?> <project name="qdox" default="package" basedir="."> <!-- ====================================================================== --> <!-- Build environment properties --> <!-- ====================================================================== --> <property file="build.properties"/> <property name="project.artifactId" value="qdox"/> <property name="project.version" value="2.0.1"/> <property name="build.finalName" value="${project.artifactId}-${project.version}"/> <property name="build.dir" value="target"/> <property name="build.outputDir" value="${build.dir}/classes"/> <property name="build.srcDir" value="src/main/java"/> <property name="build.resourceDir" value="src/main/resources"/> <property name="reporting.outputDirectory" value="${build.dir}/site"/> <property name="compiler.source" value="1.7"/> <property name="compiler.target" value="${compiler.source}"/> <!-- ====================================================================== --> <!-- Cleaning up target --> <!-- ====================================================================== --> <target name="clean" description="Clean the output directory"> <delete dir="${build.dir}"/> </target> <!-- ====================================================================== --> <!-- Compilation target --> <!-- ====================================================================== --> <target name="compile" description="Compile the code"> <mkdir dir="${build.outputDir}"/> <javac destdir="${build.outputDir}" nowarn="false" debug="true" optimize="false" deprecation="true" target="${compiler.target}" verbose="false" fork="false" source="${compiler.source}"> <src> <pathelement location="${build.srcDir}"/> </src> </javac> </target> <!-- ====================================================================== --> <!-- Javadoc target --> <!-- ====================================================================== --> <target name="javadoc" description="Generates the Javadoc of the application"> <javadoc sourcepath="${build.srcDir}" packagenames="*" destdir="${reporting.outputDirectory}/apidocs" access="protected" source="${compiler.source}" verbose="false" version="true" use="true" author="true" splitindex="false" nodeprecated="false" nodeprecatedlist="false" notree="false" noindex="false" nohelp="false" nonavbar="false" serialwarn="false" charset="ISO-8859-1" linksource="false" breakiterator="false"/> </target> <!-- ====================================================================== --> <!-- Package target --> <!-- ====================================================================== --> <target name="package" depends="compile" description="Package the application"> <jar jarfile="${build.dir}/${build.finalName}.jar" compress="true" index="false" basedir="${build.outputDir}" excludes="**/package.html"> <manifest> <attribute name="Bundle-Localization" value="plugin"/> <attribute name="Bundle-ManifestVersion" value="2"/> <attribute name="Bundle-Name" value="%pluginName"/> <attribute name="Bundle-RequiredExecutionEnvironment" value="J2SE-${compiler.target}"/> <attribute name="Bundle-SymbolicName" value="com.thoughtworks.qdox"/> <attribute name="Bundle-Vendor" value="%providerName"/> <attribute name="Bundle-Version" value="${project.version}"/> <attribute name="Export-Package" value="com.thoughtworks.qdox.ant;version="${project.version}",com.thoughtworks.qdox.directorywalker;version="${project.version}",com.thoughtworks.qdox.junit;version="${project.version}",com.thoughtworks.qdox.model.util;version="${project.version}",com.thoughtworks.qdox.model;version="${project.version}",com.thoughtworks.qdox.parser.impl;version="${project.version}",com.thoughtworks.qdox.parser.structs;version="${project.version}",com.thoughtworks.qdox.parser;version="${project.version}",com.thoughtworks.qdox.tools;version="${project.version}",com.thoughtworks.qdox;version="${project.version}""/> <attribute name="Import-Package" value="junit.framework;version="[3.8.2,4.0.0)";resolution:=optional,org.apache.tools.ant.types;version="[1.7.0,2.0.0)";resolution:=optional,org.apache.tools.ant;version="[1.7.0,2.0.0)";resolution:=optional"/> </manifest> </jar> </target> <!-- ====================================================================== --> <!-- A dummy target for the package named after the type it creates --> <!-- ====================================================================== --> <target name="jar" depends="package" description="Builds the jar for the application"/> </project>
