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 feat: finish the changing behaviour for noclasspath mode #2074

Merged
merged 6 commits into from
Jun 25, 2018

Conversation

surli
Copy link
Collaborator

@surli surli commented Jun 15, 2018

We change the behaviour of Spoon regarding the noclasspath mode in #1936 however we don't make any change about that on the command-line interface as pointed out in #2073.

This PR is a first proposal to align the behaviours.

Edit: Actually it's worst than I was thinking at first: when creating a new Launcher we were processing the arguments, then the method was switching by default the env noclasspath to false. So our changes in StandardEnvironment in #1936 had no impact for users.

@surli surli changed the title feat: Align CLI behaviour with API behaviour feat: finish the changing behaviour for noclasspath mode Jun 15, 2018
@surli surli changed the title feat: finish the changing behaviour for noclasspath mode review feat: finish the changing behaviour for noclasspath mode Jun 15, 2018
@@ -544,6 +544,7 @@ public void testUsageOfTypeAnnotationBeforeExceptionInSignatureOfMethod() throws
@Test
public void testUsageOfTypeAnnotationInReturnTypeInMethod() throws Exception {
final Launcher launcher = new Launcher();
launcher.getEnvironment().setNoClasspath(false);
Copy link
Collaborator

Choose a reason for hiding this comment

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

why do we need those changes? if it works in full classpath, it should work in noclasspath, correct?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Actually it works but the printed result is not exactly the same, so instead of fixing the assert I decided to keep the old setup.

Here the obtained diff if we call the test with a noclasspath:

Return type with an type annotation must be well printed expected:
<[public [email protected]
]String m3() {
    re...> but was:<[@spoon.test.annotation.testclasses.TypeAnnotation
public java.lang.]String m3() {
    re...>

Copy link
Collaborator

Choose a reason for hiding this comment

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

does this mean that we don't have the fully-qualified names in noclasspath or not?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No it means that in noclasspath, the annotation seems not printed exactly at the same place: before or after the modifier of a field.

Launcher.LOGGER.warn("Spoon is now using the 'no classpath mode' by default. If you want to ensure using Spoon in full classpath mode, please use the new flag: --fullclasspath.");
}

if (jsapActualArgs.getBoolean("fullclasspath")) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't understand why we need a new option which is also boolean.

We can still write --noclasspath true or --noclasspath false? We only have to change the default value?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The argument is a switch, you cannot write --noclasspath true or false:

[urli@vivat ~]$ java -jar spoon-core-6.2.0-jar-with-dependencies.jar --noclasspath true
Error: Unexpected argument: true

So in fact you could only switch on the noclasspath, and never switch off it. The opposite option allows that.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I see. Then instead of introducing a closed swith, I would suggest to introduce an open "--mode", "--mode noclasspath", "--mode fullclasspath", that we could extend in the future with new options.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Would this mode be related only to classpath? If yes I would prefer to name it cpmode to avoid ambiguity.
And do we keep the old switch for backward compatibility or not?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

By the way, just for information you merge in #2065 a new switch in the usage to disable the comments: it was exactly the same case as this one.

@monperrus
Copy link
Collaborator

monperrus commented Jun 20, 2018 via email

@monperrus
Copy link
Collaborator

monperrus commented Jun 20, 2018 via email

@monperrus
Copy link
Collaborator

monperrus commented Jun 20, 2018 via email

@surli
Copy link
Collaborator Author

surli commented Jun 20, 2018

Regarding keeping the old switch, what's the behavior of JSAP with unknown arguments: crash? silence? warning?

It crashes.

@surli surli mentioned this pull request Jun 20, 2018
@surli surli changed the title review feat: finish the changing behaviour for noclasspath mode WiP feat: finish the changing behaviour for noclasspath mode Jun 21, 2018
@surli surli changed the title WiP feat: finish the changing behaviour for noclasspath mode review feat: finish the changing behaviour for noclasspath mode Jun 25, 2018
@monperrus monperrus merged commit 9f72470 into INRIA:master Jun 25, 2018
@surli surli deleted the align-behaviour-of-cli branch June 25, 2018 12:52
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.

2 participants