-
Notifications
You must be signed in to change notification settings - Fork 28
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
chore: bump spoon version #886
Conversation
Looks like there are problems with |
We're still stabilizing 7.6. Let's wait a little bit. |
conflict? |
acd5241
to
16904bf
Compare
ping @danglotb |
Hello, there are still issues with the CompilationUnit. It seems that it returns the original version of the class when I try to print it with : public static void printCtTypeToGivenDirectory(CtType<?> type, File directory, boolean autoImports) {
try {
Factory factory = type.getFactory();
Environment env = factory.getEnvironment();
env.setAutoImports(autoImports);
env.setNoClasspath(true);
env.setCommentEnabled(DSpotUtils.withComment);
JavaOutputProcessor processor = new JavaOutputProcessor(new DefaultJavaPrettyPrinter(env));
processor.setFactory(factory);
processor.getEnvironment().setSourceOutputDirectory(directory);
processor.createJavaFile(type);
env.setAutoImports(false);
} catch (Exception e) {
printCtTypUsingToStringToGivenDirectory(type, directory);
} In CompilationUnit cu = this.getFactory().CompilationUnit().getOrCreate(element); And this CompilationUnit still point on the original class and not the one that I want to print, i.e. the I tried to create a new Factory (kind of messy & ugly but uh), as follow: try {
//Factory factory = type.getFactory();
Environment env = type.getFactory().getEnvironment();
Factory factory = new FactoryImpl(new DefaultCoreFactory(), env);
CtPackage packageOfTestClass = factory.Package().getOrCreate(type.getPackage().getQualifiedName());
packageOfTestClass.addType(type);
env.setAutoImports(autoImports);
env.setNoClasspath(true);
env.setCommentEnabled(DSpotUtils.withComment);
JavaOutputProcessor processor = new JavaOutputProcessor(new DefaultJavaPrettyPrinter(env));
processor.setFactory(factory);
processor.getEnvironment().setSourceOutputDirectory(directory);
processor.createJavaFile(type);
env.setAutoImports(false);
} catch (Exception e) {
printCtTypUsingToStringToGivenDirectory(type, directory);
} But still the same behaviour. It looks like Spoon is using the original java file to print it, instead of the loaded CtType. |
Great progress. Could you write a pull-request with a failing test case in the Spoon repo?
|
Hello @monperrus Yes, I'll do that ASAP. Thank you :) |
updated to 8.1.0-SNAPSHOT |
…update-to-spoon-7.6
…update-to-spoon-7.6
It looks like we have still the same issue. Spoon is printing the old class (before modification) instead of the one given in parameter. BTW, DSpot looks into the public snapshot repository at maven.inria.fr for the snapshot of Spoon However, the last updated is :
Is the latest SNAPSHOT available somewhere else ? I'll look at providing a new test as pull request on the spoon repository to capture the problem. The cause in DSpot is the following method: public static void printCtTypeToGivenDirectory(CtType<?> type, File directory, boolean autoImports) {
Environment env = type.getFactory().getEnvironment();
Factory factory = new FactoryImpl(new DefaultCoreFactory(), env);
try {
//Factory factory = type.getFactory();
CtPackage packageOfTestClass = factory.Package().create(factory.Package().getRootPackage(), type.getPackage().getQualifiedName());
packageOfTestClass.addType(type.clone());
env.setAutoImports(autoImports);
env.setNoClasspath(true);
env.setCommentEnabled(DSpotUtils.withComment);
JavaOutputProcessor processor = new JavaOutputProcessor(new DefaultJavaPrettyPrinter(env));
processor.setFactory(factory);
processor.getEnvironment().setSourceOutputDirectory(directory);
processor.createJavaFile(type);
env.setAutoImports(false);
} catch (Exception e) {
printCtTypUsingToStringToGivenDirectory(type, directory);
}
} Thank you very much. |
Yes, and the last update is from Feb 26, if you look into the |
61e92e0
to
4d10fa3
Compare
4d10fa3
to
299f80b
Compare
Pull Request Test Coverage Report for Build 2502
💛 - Coveralls |
Thanks a lot @danglotb ! |
No description provided.