Backport patch for misparsed comments

This commit is contained in:
Michael Simacek 2017-01-20 18:08:44 +01:00
parent 12b9423b15
commit 10500d9365
2 changed files with 78 additions and 1 deletions

View File

@ -0,0 +1,69 @@
From ca5a50fc69b4b1bb0f640edb8dbaa13c5e90112e Mon Sep 17 00:00:00 2001
From: rfscholte <rfscholte@apache.org>
Date: Thu, 19 Jan 2017 18:44:38 +0100
Subject: [PATCH] #16 Single comment line not recognized
---
src/grammar/lexer.flex | 2 +-
.../thoughtworks/qdox/JavaProjectBuilderTest.java | 32 ++++++++++++++++++++++
2 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/src/grammar/lexer.flex b/src/grammar/lexer.flex
index 681f2b8..bd3462c 100644
--- a/src/grammar/lexer.flex
+++ b/src/grammar/lexer.flex
@@ -608,7 +608,7 @@ JavadocEnd = "*"+ "/"
\' { if (appendingToCodeBody) { codeBody.append('\''); } pushState(CHAR); }
}
-<ASSIGNMENT, YYINITIAL, CODEBLOCK, PARENBLOCK, ENUM, ANNOTATIONTYPE, ANNOTATION, ARGUMENTS, TYPE> {
+<ASSIGNMENT, YYINITIAL, CODEBLOCK, PARENBLOCK, ENUM, ANNOTATIONTYPE, ANNOTATION, ARGUMENTS, TYPE, NAME> {
"//" { if (appendingToCodeBody) { codeBody.append("//"); } pushState(SINGLELINECOMMENT); }
"/*" { if (appendingToCodeBody) { codeBody.append("/*"); } pushState(MULTILINECOMMENT); }
"/**/" { if (appendingToCodeBody) { codeBody.append("/**/"); } }
diff --git a/src/test/java/com/thoughtworks/qdox/JavaProjectBuilderTest.java b/src/test/java/com/thoughtworks/qdox/JavaProjectBuilderTest.java
index 204a23a..edc6352 100644
--- a/src/test/java/com/thoughtworks/qdox/JavaProjectBuilderTest.java
+++ b/src/test/java/com/thoughtworks/qdox/JavaProjectBuilderTest.java
@@ -1582,6 +1582,38 @@ public class JavaProjectBuilderTest extends TestCase
assertEquals( "com.fg.rtdoc.test.Iface", clz.getInterfaces().get(0).getFullyQualifiedName() );
}
+
+ // Github #16
+ public void testBeanProperties()
+ {
+ String zothParent = "public class ZothParent {\n" +
+ " private String name;\n" +
+ " public String getName() {\n" +
+ " return name;\n" +
+ " }\n" +
+ " public void setName(String name) {\n" +
+ " this.name = name;\n" +
+ " }\n" +
+ "}";
+
+ String zothChild = "public class ZothChild // extends ZothParent\n" +
+ "{\n" +
+ " private int age;\n" +
+ " public int getAge() {\n" +
+ " return age;\n" +
+ " }\n" +
+ " public void setAge(int age) {\n" +
+ " this.age = age;\n" +
+ " }\n" +
+ "}";
+
+ JavaProjectBuilder builder = new JavaProjectBuilder();
+ builder.addSource(new StringReader( zothParent ));
+ JavaClass zothClass = builder.addSource(new StringReader( zothChild )).getClassByName( "ZothChild" );
+ assertEquals( "java.lang.Object", zothClass.getSuperClass().getBinaryName());
+ assertEquals( 2, zothClass.getBeanProperties( true ).size() );
+
+ }
public void testDeclarationSignatureWithGenerics() {
String source = "import java.util.List;"
--
2.9.3

View File

@ -3,7 +3,7 @@
Summary: Extract class/interface/method definitions from sources Summary: Extract class/interface/method definitions from sources
Name: qdox Name: qdox
Version: 2.0 Version: 2.0
Release: 0.6.%{vertag}%{?dist} Release: 0.7.%{vertag}%{?dist}
Epoch: 0 Epoch: 0
License: ASL 2.0 License: ASL 2.0
URL: https://github.com/paul-hammant/qdox URL: https://github.com/paul-hammant/qdox
@ -12,6 +12,9 @@ BuildArch: noarch
Source0: http://repo2.maven.org/maven2/com/thoughtworks/qdox/qdox/%{version}-%{vertag}/%{name}-%{version}-%{vertag}-project.tar.gz Source0: http://repo2.maven.org/maven2/com/thoughtworks/qdox/qdox/%{version}-%{vertag}/%{name}-%{version}-%{vertag}-project.tar.gz
Source1: qdox-MANIFEST.MF Source1: qdox-MANIFEST.MF
# https://github.com/paul-hammant/qdox/issues/16
Patch1: 0001-16-Single-comment-line-not-recognized.patch
BuildRequires: byaccj BuildRequires: byaccj
BuildRequires: jflex BuildRequires: jflex
BuildRequires: maven-local BuildRequires: maven-local
@ -41,6 +44,8 @@ API docs for %{name}.
find -name *.jar -delete find -name *.jar -delete
rm -rf bootstrap rm -rf bootstrap
%patch1 -p1
# We don't need these plugins # We don't need these plugins
%pom_remove_plugin :animal-sniffer-maven-plugin %pom_remove_plugin :animal-sniffer-maven-plugin
%pom_remove_plugin :maven-failsafe-plugin %pom_remove_plugin :maven-failsafe-plugin
@ -75,6 +80,9 @@ zip -u target/%{name}-%{version}.jar META-INF/MANIFEST.MF
%doc LICENSE.txt %doc LICENSE.txt
%changelog %changelog
* Fri Jan 20 2017 Michael Simacek <msimacek@redhat.com> - 0:2.0-0.7.M5
- Backport patch for misparsed comments
* Tue Jan 17 2017 Michael Simacek <msimacek@redhat.com> - 0:2.0-0.6.M5 * Tue Jan 17 2017 Michael Simacek <msimacek@redhat.com> - 0:2.0-0.6.M5
- Update to upstream version 2.0-M5 - Update to upstream version 2.0-M5