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

review fix: launcher#setArgs cannot be called twice #2141

Merged
merged 4 commits into from
Jun 29, 2018

Conversation

surli
Copy link
Collaborator

@surli surli commented Jun 29, 2018

This PR shows that the current behaviour is to never reset the model, even if the same launcher is called twice with different arguments.

My current test shows that model and model2 are the same and they contain 2 types at the end of the test.

I don't know if it's an expected behaviour or not, but it looks very dangerous to me. WDYT?

@surli
Copy link
Collaborator Author

surli commented Jun 29, 2018

By the way, the only way to make this case working is by using setArgs() because then we call processArguments which create a new JDTBasedSpoonCompiler. If we try doing that using the API (addInputResource and so one), it will never work because we don't create back the JDTBasedSpoonCompiler.

Personally what I would want as a user is:

  1. To obtain a new model each time I call buildModel()
  2. To be able to call buildModel() several times for the same launcher

@pvojtechovsky
Copy link
Collaborator

I would say they spoon model is not ready to coexist with another spoon model made by same launcher. Note that each model produced by launcher actually MUST share Factory and StandardEnvironment and it causes at least problems with change event handling ...

So it looks like that idea needs deeper refactoring

@surli
Copy link
Collaborator Author

surli commented Jun 29, 2018

I would say they spoon model is not ready to coexist with another spoon model made by same launcher.

Ok then we should prevent calling twice setArgs on the same launcher by throwing an exception for example. Do you agree?

@pvojtechovsky
Copy link
Collaborator

we should prevent calling twice setArgs on the same launcher by throwing an exception

I agree ... and later we might think about that refactoring. It is not nice when model specific things are in StandartEnvironment...

@surli surli changed the title fix: when a launcher is called twice wih different arguments a new model should be created fix: launcher#setArgs cannot be called twice Jun 29, 2018
@surli surli changed the title fix: launcher#setArgs cannot be called twice review fix: launcher#setArgs cannot be called twice Jun 29, 2018
@@ -99,6 +99,8 @@
private List<String> processorTypes = new ArrayList<>();
private List<Processor<? extends CtElement>> processors = new ArrayList<>();

private boolean processed;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

explicitly set it to false?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a comment about the meaning of the field?

@pvojtechovsky pvojtechovsky merged commit d7efd28 into INRIA:master Jun 29, 2018
@surli surli deleted the test-process-two-models branch July 3, 2018 07:42
@surli surli mentioned this pull request Jul 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants