Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PARANAMER-26] Upgrade QDox to 2.x #16

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

import org.apache.tools.ant.types.FileSet;

import com.thoughtworks.qdox.JavaDocBuilder;
import com.thoughtworks.qdox.JavaProjectBuilder;

import com.thoughtworks.paranamer.generator.QdoxParanamerGenerator;

Expand Down Expand Up @@ -178,7 +178,7 @@ public void execute() throws BuildException {
+ ds.getBasedir());
for (Object o : Arrays.asList(includedFiles)) {
String file = (String) o;
JavaDocBuilder builder = new JavaDocBuilder();
JavaProjectBuilder builder = new JavaProjectBuilder();
try {
builder.addSource(new File(ds.getBasedir(), file));
// if the classdir is set then we source the classes
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
package com.thoughtworks.paranamer.ant;

import com.thoughtworks.paranamer.generator.Enhancer;
import com.thoughtworks.paranamer.generator.QdoxParanamerGenerator;
import com.thoughtworks.qdox.model.JavaClass;
import junit.framework.TestCase;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

import org.junit.Assert;
import org.junit.Test;

import package1.A;
import package1.B;
import package2.C;

import java.io.File;
import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import com.thoughtworks.paranamer.generator.Enhancer;
import com.thoughtworks.paranamer.generator.QdoxParanamerGenerator;
import com.thoughtworks.qdox.model.JavaClass;

public class ParanamerGeneratorTaskTest {
private static final File BASE = new File(ParanamerGeneratorTaskTest.class.getProtectionDomain().getCodeSource().getLocation().getFile()).getParentFile().getParentFile();
Expand All @@ -30,7 +32,8 @@ public void log(java.lang.String msg, int msgLevel) {

protected QdoxParanamerGenerator makeQdoxParanamerGenerator() {
return new QdoxParanamerGenerator() {
public void processClasses(JavaClass[] classes, String outputPath) throws IOException {
@Override
public void processClasses(Collection<JavaClass> classes, String outputPath) throws IOException {
for (JavaClass aClass : classes) {
result.add(aClass.getFullyQualifiedName());
}
Expand Down Expand Up @@ -62,13 +65,14 @@ protected QdoxParanamerGenerator makeQdoxParanamerGenerator() {
return new QdoxParanamerGenerator() {
public Enhancer makeEnhancer() {
return new Enhancer() {
public void enhance(File classFile, String parameterNameData) throws IOException {
@Override
public void enhance(File classFile, CharSequence parameterNameData) throws IOException {
didIt[0] = true;
super.enhance(classFile, parameterNameData);
Assert.assertTrue(classFile.getAbsolutePath().endsWith("C.class"));
Assert.assertEquals(
"method1OfC int,int arg1,arg2 \n" +
"method2OfC int arg \n", parameterNameData);
"method2OfC int arg \n", parameterNameData.toString());
}
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,25 @@
package com.thoughtworks.paranamer.ant;

import com.thoughtworks.paranamer.generator.Enhancer;
import com.thoughtworks.paranamer.generator.QdoxParanamerGenerator;

import com.thoughtworks.qdox.model.JavaClass;

import org.junit.Assert;
import org.junit.Test;
import package1.A;
import package1.B;
import package2.C;

import java.io.File;
import java.io.IOException;

import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

import org.apache.tools.ant.Project;
import org.apache.tools.ant.Target;

import org.apache.tools.ant.types.FileSet;
import org.junit.Assert;
import org.junit.Test;

import package1.A;
import package1.B;
import package2.C;

import com.thoughtworks.paranamer.generator.Enhancer;
import com.thoughtworks.paranamer.generator.QdoxParanamerGenerator;
import com.thoughtworks.qdox.model.JavaClass;

public class ParanamerTaskTest {
private static final File BASE = new File(ParanamerTaskTest.class
Expand Down Expand Up @@ -65,7 +63,8 @@ public void log(java.lang.String msg, int msgLevel) {

protected QdoxParanamerGenerator makeQdoxParanamerGenerator() {
return new QdoxParanamerGenerator() {
public void processClasses(JavaClass[] classes, String outputPath)
@Override
public void processClasses(Collection<JavaClass> classes, String outputPath)
throws IOException {
for (JavaClass aClass : classes) {
result.add(aClass.getFullyQualifiedName());
Expand Down Expand Up @@ -113,7 +112,8 @@ public void log(java.lang.String msg, int msgLevel) {

protected QdoxParanamerGenerator makeQdoxParanamerGenerator() {
return new QdoxParanamerGenerator() {
public void processClasses(JavaClass[] classes, String outputPath)
@Override
public void processClasses(Collection<JavaClass> classes, String outputPath)
throws IOException {
for (JavaClass aClass : classes) {
result.add(aClass.getFullyQualifiedName());
Expand Down Expand Up @@ -164,7 +164,8 @@ public void log(java.lang.String msg, int msgLevel) {

protected QdoxParanamerGenerator makeQdoxParanamerGenerator() {
return new QdoxParanamerGenerator() {
public void processClasses(JavaClass[] classes, String outputPath)
@Override
public void processClasses(Collection<JavaClass> classes, String outputPath)
throws IOException {
for (JavaClass aClass : classes) {
result.add(aClass.getFullyQualifiedName());
Expand Down Expand Up @@ -214,7 +215,8 @@ public void log(java.lang.String msg, int msgLevel) {

protected QdoxParanamerGenerator makeQdoxParanamerGenerator() {
return new QdoxParanamerGenerator() {
public void processClasses(JavaClass[] classes, String outputPath)
@Override
public void processClasses(Collection<JavaClass> classes, String outputPath)
throws IOException {
for (JavaClass aClass : classes) {
result.add(aClass.getFullyQualifiedName());
Expand Down Expand Up @@ -258,7 +260,8 @@ public void log(java.lang.String msg, int msgLevel) {

protected QdoxParanamerGenerator makeQdoxParanamerGenerator() {
return new QdoxParanamerGenerator() {
public void processClasses(JavaClass[] classes, String outputPath)
@Override
public void processClasses(Collection<JavaClass> classes, String outputPath)
throws IOException {
for (JavaClass aClass : classes) {
result.add(aClass.getFullyQualifiedName());
Expand Down Expand Up @@ -304,7 +307,8 @@ public void log(java.lang.String msg, int msgLevel) {

protected QdoxParanamerGenerator makeQdoxParanamerGenerator() {
return new QdoxParanamerGenerator() {
public void processClasses(JavaClass[] classes, String outputPath)
@Override
public void processClasses(Collection<JavaClass> classes, String outputPath)
throws IOException {
for (JavaClass aClass : classes) {
result.add(aClass.getFullyQualifiedName());
Expand Down Expand Up @@ -350,7 +354,8 @@ public void log(java.lang.String msg, int msgLevel) {

protected QdoxParanamerGenerator makeQdoxParanamerGenerator() {
return new QdoxParanamerGenerator() {
public void processClasses(JavaClass[] classes, String outputPath)
@Override
public void processClasses(Collection<JavaClass> classes, String outputPath)
throws IOException {
for (JavaClass aClass : classes) {
result.add(aClass.getFullyQualifiedName());
Expand Down Expand Up @@ -400,7 +405,8 @@ public void log(java.lang.String msg, int msgLevel) {

protected QdoxParanamerGenerator makeQdoxParanamerGenerator() {
return new QdoxParanamerGenerator() {
public void processClasses(JavaClass[] classes, String outputPath)
@Override
public void processClasses(Collection<JavaClass> classes, String outputPath)
throws IOException {
for (JavaClass aClass : classes) {
result.add(aClass.getFullyQualifiedName());
Expand Down Expand Up @@ -447,7 +453,8 @@ public void log(java.lang.String msg, int msgLevel) {

protected QdoxParanamerGenerator makeQdoxParanamerGenerator() {
return new QdoxParanamerGenerator() {
public void processClasses(JavaClass[] classes, String outputPath)
@Override
public void processClasses(Collection<JavaClass> classes, String outputPath)
throws IOException {
for (JavaClass aClass : classes) {
result.add(aClass.getFullyQualifiedName());
Expand Down Expand Up @@ -495,14 +502,15 @@ protected QdoxParanamerGenerator makeQdoxParanamerGenerator() {
return new QdoxParanamerGenerator() {
public Enhancer makeEnhancer() {
return new Enhancer() {
public void enhance(File classFile, String parameterNameData)
@Override
public void enhance(File classFile, CharSequence parameterNameData)
throws IOException {
enhanced[0] = true;
super.enhance(classFile, parameterNameData);
Assert.assertTrue(classFile.getAbsolutePath().endsWith("C.class"));
Assert.assertEquals(
"method1OfC int,int arg1,arg2 \n" +
"method2OfC int arg \n", parameterNameData);
"method2OfC int arg \n", parameterNameData.toString());
}
};
}
Expand Down
2 changes: 1 addition & 1 deletion paranamer-generator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<dependency>
<groupId>com.thoughtworks.qdox</groupId>
<artifactId>qdox</artifactId>
<version>1.12</version>
<version>2.0-M2</version>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
*/
public class Enhancer implements Opcodes {

public void enhance(File classFile, String parameterNameData)
public void enhance(File classFile, CharSequence parameterNameData)
throws IOException {

byte[] classBytecode = addExtraStaticField(classFile, parameterNameData);
Expand All @@ -56,7 +56,7 @@ public void enhance(File classFile, String parameterNameData)
}

private byte[] addExtraStaticField(File classFile,
final String parameterNameData) throws IOException {
final CharSequence parameterNameData) throws IOException {

InputStream inputStream = new FileInputStream(classFile);
ClassReader reader = new ClassReader(inputStream);
Expand All @@ -68,7 +68,7 @@ private byte[] addExtraStaticField(File classFile,

AddFieldAdapter adapter = new AddFieldAdapter(writer, ACC_PUBLIC
+ ACC_FINAL + ACC_STATIC, "__PARANAMER_DATA",
"Ljava/lang/String;", parameterNameData);
"Ljava/lang/String;", parameterNameData.toString());

reader.accept(adapter, 0);

Expand Down
Loading