-
-
Notifications
You must be signed in to change notification settings - Fork 352
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
review: refactor: manage sourceOutputDirectory in Environment #1770
Conversation
@@ -279,12 +278,12 @@ public void addTemplateSources(List<SpoonResource> resources) { | |||
|
|||
@Override | |||
public void setSourceOutputDirectory(File outputDirectory) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
put deprecated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wondered: it's still usable to put the right value in the environment...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method is used in some test and maybe some clients are still using it to put the value, so it can still work except now it puts the value in the Environment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR will already break the API.
I would break it more to reduce the number of API, to simplify the usage of the API.
At least I would say in the doc that this API is just a different way to access the Environment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would break it more to reduce the number of API, to simplify the usage of the API.
At least I would say in the doc that this API is just a different way to access the Environment
I agree with you. I'll deprecate it then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put the deprecated annotation in the interface.
❤️ |
OK for me. Merge? |
It's ready for me. |
@tdurieux @monperrus I made few changes to deprecate methods So maybe we should override the |
@@ -96,7 +122,7 @@ public void init() { | |||
} | |||
} | |||
try { | |||
directory = directory.getCanonicalFile(); | |||
this.getEnvironment().setSourceOutputDirectory(directory.getCanonicalFile()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this one: this should be done directly in the setter of Environment, no? WDYT?
|
||
List<File> printedFiles = new ArrayList<>(); | ||
|
||
public JavaOutputProcessor(PrettyPrinter printer) { | ||
this.printer = printer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that does not seem nice :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're talking about the line below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No the constructor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you elaborate ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you need to copy the env?
it is accessible via getFactory().getEnv().
OK for me. @tdurieux do you see a problem? |
I have a general issue with the printing process, there is too much state. |
I don't like the creation of getEnvironment method in several classes, I am pretty sure it is not required |
I agree, if we can avoid it, that's better |
@@ -44,19 +46,28 @@ | |||
*/ | |||
public class JavaOutputProcessor extends AbstractProcessor<CtNamedElement> implements FileGenerator<CtNamedElement> { | |||
PrettyPrinter printer; | |||
|
|||
File directory; | |||
private Environment environment; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need some state here, we alread have getFactory().getEnvironment()
|
||
List<File> printedFiles = new ArrayList<>(); | ||
|
||
public JavaOutputProcessor(PrettyPrinter printer) { | ||
this.printer = printer; | ||
this.environment = printer.getEnvironment(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can replace printer.getEnvironment()
by getFactory().getEnvironment()
. And then we don't need the new method in interface PrettyPrinter
thanks! |
Detected changes by Revapi: 3. Old API: fr.inria.gforge.spoon:spoon-core:jar:6.1.0-20171207.234709-36 New API: fr.inria.gforge.spoon:spoon-core:jar:6.1.0-SNAPSHOT
|
@tdurieux @monperrus so it's ready for me. |
thanks a lot! |
seems we have a regression due to this one: https://ci.inria.fr/sos/job/juliac/423/consoleFull |
I was using
|
thanks Lionel. --Martin
|
This PR intends to fix issues bring by the multiple usage of SourceOutputDirectory