This commit is contained in:
parent
1bafc78fcc
commit
c3e13147c4
@ -1,105 +1,94 @@
|
|||||||
From 6d7da5456a7458a249bed9c4c1e768cc7cc2fe40 Mon Sep 17 00:00:00 2001
|
diff -urEbwB hamcrest-1.3/hamcrest-generator/src/main/java/org/hamcrest/generator/QDoxFactoryReader.java hamcrest-1.3.new/hamcrest-generator/src/main/java/org/hamcrest/generator/QDoxFactoryReader.java
|
||||||
From: Michael Simacek <msimacek@redhat.com>
|
--- hamcrest-1.3/hamcrest-generator/src/main/java/org/hamcrest/generator/QDoxFactoryReader.java 2019-01-01 15:27:38.332599832 +0100
|
||||||
Date: Wed, 1 Feb 2017 12:57:14 +0100
|
+++ hamcrest-1.3.new/hamcrest-generator/src/main/java/org/hamcrest/generator/QDoxFactoryReader.java 2019-01-01 15:29:19.560043471 +0100
|
||||||
Subject: [PATCH] Port to qdox 2.0
|
@@ -4,8 +4,10 @@
|
||||||
|
import com.thoughtworks.qdox.model.JavaClass;
|
||||||
---
|
import com.thoughtworks.qdox.model.JavaMethod;
|
||||||
.../src/main/java/org/hamcrest/generator/QDox.java | 4 ++--
|
import com.thoughtworks.qdox.model.JavaParameter;
|
||||||
.../org/hamcrest/generator/QDoxFactoryReader.java | 26 ++++++++++++----------
|
-import com.thoughtworks.qdox.model.Type;
|
||||||
2 files changed, 16 insertions(+), 14 deletions(-)
|
+import com.thoughtworks.qdox.model.JavaType;
|
||||||
|
+import com.thoughtworks.qdox.model.impl.DefaultJavaClass;
|
||||||
diff --git a/hamcrest-generator/src/main/java/org/hamcrest/generator/QDox.java b/hamcrest-generator/src/main/java/org/hamcrest/generator/QDox.java
|
|
||||||
index efaf615..338178d 100644
|
+import java.util.ArrayList;
|
||||||
--- a/hamcrest-generator/src/main/java/org/hamcrest/generator/QDox.java
|
import java.util.Iterator;
|
||||||
+++ b/hamcrest-generator/src/main/java/org/hamcrest/generator/QDox.java
|
import java.util.List;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
@@ -56,15 +58,15 @@
|
||||||
|
JavaMethod methodSource = findMethodInSource(factoryMethod);
|
||||||
|
if (methodSource != null) {
|
||||||
|
factoryMethod.setJavaDoc(createJavaDocComment(methodSource));
|
||||||
|
- JavaParameter[] parametersFromSource
|
||||||
|
+ List<JavaParameter> parametersFromSource
|
||||||
|
= methodSource.getParameters();
|
||||||
|
List<FactoryMethod.Parameter> parametersFromReflection
|
||||||
|
= factoryMethod.getParameters();
|
||||||
|
|
||||||
|
- if (parametersFromReflection.size() == parametersFromSource.length) {
|
||||||
|
- for (int i = 0; i < parametersFromSource.length; i++) {
|
||||||
|
+ if (parametersFromReflection.size() == parametersFromSource.size()) {
|
||||||
|
+ for (int i = 0; i < parametersFromSource.size(); i++) {
|
||||||
|
parametersFromReflection.get(i).setName(
|
||||||
|
- parametersFromSource[i].getName());
|
||||||
|
+ parametersFromSource.get(i).getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -79,18 +81,18 @@
|
||||||
|
// Note, this doesn't always work - it struggles with some kinds of generics.
|
||||||
|
// This seems to cover most cases though.
|
||||||
|
List<FactoryMethod.Parameter> params = factoryMethod.getParameters();
|
||||||
|
- Type[] types = new Type[params.size()];
|
||||||
|
+ List<JavaType> types = new ArrayList<JavaType>(params.size());
|
||||||
|
boolean varArgs = false;
|
||||||
|
- for (int i = 0; i < types.length; i++) {
|
||||||
|
+ for (int i = 0; i < params.size(); i++) {
|
||||||
|
String type = params.get(i).getType();
|
||||||
|
varArgs = VARARGS_REGEX.matcher(type).find();
|
||||||
|
// QDox ignores varargs and generics, so we strip them out to help QDox.
|
||||||
|
type = GENERIC_REGEX.matcher(type).replaceAll("");
|
||||||
|
type = VARARGS_REGEX.matcher(type).replaceAll("");
|
||||||
|
- types[i] = new Type(type);
|
||||||
|
+ types.add(new DefaultJavaClass(type));
|
||||||
|
}
|
||||||
|
- JavaMethod[] methods = classSource.getMethodsBySignature(factoryMethod.getName(), types, false, varArgs);
|
||||||
|
- return methods.length == 1 ? methods[0] : null;
|
||||||
|
+ List<JavaMethod> methods = classSource.getMethodsBySignature(factoryMethod.getName(), types, false, varArgs);
|
||||||
|
+ return methods.size() == 1 ? methods.get(0) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
@@ -98,8 +100,8 @@
|
||||||
|
*/
|
||||||
|
private static String createJavaDocComment(JavaMethod methodSource) {
|
||||||
|
String comment = methodSource.getComment();
|
||||||
|
- DocletTag[] tags = methodSource.getTags();
|
||||||
|
- if ((comment == null || comment.trim().length() == 0) && tags.length == 0) {
|
||||||
|
+ List<DocletTag> tags = methodSource.getTags();
|
||||||
|
+ if ((comment == null || comment.trim().length() == 0) && tags.size() == 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
Only in hamcrest-1.3.new/hamcrest-generator/src/main/java/org/hamcrest/generator: QDoxFactoryReader.java.orig
|
||||||
|
Only in hamcrest-1.3.new/hamcrest-generator/src/main/java/org/hamcrest/generator: QDoxFactoryReader.java.rej
|
||||||
|
diff -urEbwB hamcrest-1.3/hamcrest-generator/src/main/java/org/hamcrest/generator/QDox.java hamcrest-1.3.new/hamcrest-generator/src/main/java/org/hamcrest/generator/QDox.java
|
||||||
|
--- hamcrest-1.3/hamcrest-generator/src/main/java/org/hamcrest/generator/QDox.java 2019-01-01 15:27:38.332599832 +0100
|
||||||
|
+++ hamcrest-1.3.new/hamcrest-generator/src/main/java/org/hamcrest/generator/QDox.java 2019-01-01 15:29:19.556043651 +0100
|
||||||
@@ -1,6 +1,6 @@
|
@@ -1,6 +1,6 @@
|
||||||
package org.hamcrest.generator;
|
package org.hamcrest.generator;
|
||||||
|
|
||||||
-import com.thoughtworks.qdox.JavaDocBuilder;
|
-import com.thoughtworks.qdox.JavaDocBuilder;
|
||||||
+import com.thoughtworks.qdox.JavaProjectBuilder;
|
+import com.thoughtworks.qdox.JavaProjectBuilder;
|
||||||
import com.thoughtworks.qdox.model.JavaClass;
|
import com.thoughtworks.qdox.model.JavaClass;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -16,7 +16,7 @@ import java.io.Reader;
|
@@ -16,7 +16,7 @@
|
||||||
*/
|
*/
|
||||||
public class QDox {
|
public class QDox {
|
||||||
|
|
||||||
- private final JavaDocBuilder javaDocBuilder = new JavaDocBuilder();
|
- private final JavaDocBuilder javaDocBuilder = new JavaDocBuilder();
|
||||||
+ private final JavaProjectBuilder javaDocBuilder = new JavaProjectBuilder();
|
+ private final JavaProjectBuilder javaDocBuilder = new JavaProjectBuilder();
|
||||||
|
|
||||||
public void addSourceTree(File sourceDir) {
|
public void addSourceTree(File sourceDir) {
|
||||||
javaDocBuilder.addSourceTree(sourceDir);
|
javaDocBuilder.addSourceTree(sourceDir);
|
||||||
diff --git a/hamcrest-generator/src/main/java/org/hamcrest/generator/QDoxFactoryReader.java b/hamcrest-generator/src/main/java/org/hamcrest/generator/QDoxFactoryReader.java
|
Only in hamcrest-1.3.new/hamcrest-generator/src/main/java/org/hamcrest/generator: QDox.java.orig
|
||||||
index 5108140..97fce01 100644
|
Only in hamcrest-1.3.new/hamcrest-generator/src/main/java/org/hamcrest/generator: QDox.java.rej
|
||||||
--- a/hamcrest-generator/src/main/java/org/hamcrest/generator/QDoxFactoryReader.java
|
|
||||||
+++ b/hamcrest-generator/src/main/java/org/hamcrest/generator/QDoxFactoryReader.java
|
|
||||||
@@ -4,8 +4,10 @@ import com.thoughtworks.qdox.model.DocletTag;
|
|
||||||
import com.thoughtworks.qdox.model.JavaClass;
|
|
||||||
import com.thoughtworks.qdox.model.JavaMethod;
|
|
||||||
import com.thoughtworks.qdox.model.JavaParameter;
|
|
||||||
-import com.thoughtworks.qdox.model.Type;
|
|
||||||
+import com.thoughtworks.qdox.model.JavaType;
|
|
||||||
+import com.thoughtworks.qdox.model.impl.DefaultJavaClass;
|
|
||||||
|
|
||||||
+import java.util.ArrayList;
|
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
@@ -56,15 +58,15 @@ public class QDoxFactoryReader implements Iterable<FactoryMethod> {
|
|
||||||
JavaMethod methodSource = findMethodInSource(factoryMethod);
|
|
||||||
if (methodSource != null) {
|
|
||||||
factoryMethod.setJavaDoc(createJavaDocComment(methodSource));
|
|
||||||
- JavaParameter[] parametersFromSource
|
|
||||||
+ List<JavaParameter> parametersFromSource
|
|
||||||
= methodSource.getParameters();
|
|
||||||
List<FactoryMethod.Parameter> parametersFromReflection
|
|
||||||
= factoryMethod.getParameters();
|
|
||||||
|
|
||||||
- if (parametersFromReflection.size() == parametersFromSource.length) {
|
|
||||||
- for (int i = 0; i < parametersFromSource.length; i++) {
|
|
||||||
+ if (parametersFromReflection.size() == parametersFromSource.size()) {
|
|
||||||
+ for (int i = 0; i < parametersFromSource.size(); i++) {
|
|
||||||
parametersFromReflection.get(i).setName(
|
|
||||||
- parametersFromSource[i].getName());
|
|
||||||
+ parametersFromSource.get(i).getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -79,18 +81,18 @@ public class QDoxFactoryReader implements Iterable<FactoryMethod> {
|
|
||||||
// Note, this doesn't always work - it struggles with some kinds of generics.
|
|
||||||
// This seems to cover most cases though.
|
|
||||||
List<FactoryMethod.Parameter> params = factoryMethod.getParameters();
|
|
||||||
- Type[] types = new Type[params.size()];
|
|
||||||
+ List<JavaType> types = new ArrayList<JavaType>(params.size());
|
|
||||||
boolean varArgs = false;
|
|
||||||
- for (int i = 0; i < types.length; i++) {
|
|
||||||
+ for (int i = 0; i < params.size(); i++) {
|
|
||||||
String type = params.get(i).getType();
|
|
||||||
varArgs = VARARGS_REGEX.matcher(type).find();
|
|
||||||
// QDox ignores varargs and generics, so we strip them out to help QDox.
|
|
||||||
type = GENERIC_REGEX.matcher(type).replaceAll("");
|
|
||||||
type = VARARGS_REGEX.matcher(type).replaceAll("");
|
|
||||||
- types[i] = new Type(type);
|
|
||||||
+ types.add(new DefaultJavaClass(type));
|
|
||||||
}
|
|
||||||
- JavaMethod[] methods = classSource.getMethodsBySignature(factoryMethod.getName(), types, false, varArgs);
|
|
||||||
- return methods.length == 1 ? methods[0] : null;
|
|
||||||
+ List<JavaMethod> methods = classSource.getMethodsBySignature(factoryMethod.getName(), types, false, varArgs);
|
|
||||||
+ return methods.size() == 1 ? methods.get(0) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
@@ -98,8 +100,8 @@ public class QDoxFactoryReader implements Iterable<FactoryMethod> {
|
|
||||||
*/
|
|
||||||
private static String createJavaDocComment(JavaMethod methodSource) {
|
|
||||||
String comment = methodSource.getComment();
|
|
||||||
- DocletTag[] tags = methodSource.getTags();
|
|
||||||
- if ((comment == null || comment.trim().length() == 0) && tags.length == 0) {
|
|
||||||
+ List<DocletTag> tags = methodSource.getTags();
|
|
||||||
+ if ((comment == null || comment.trim().length() == 0) && tags.size() == 0) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
StringBuilder result = new StringBuilder();
|
|
||||||
--
|
|
||||||
2.9.3
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user