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

refactor: handling of imports in pretty printer #2683

Merged
merged 25 commits into from
Sep 9, 2019

Conversation

pvojtechovsky
Copy link
Collaborator

@pvojtechovsky pvojtechovsky commented Oct 18, 2018

This PR implements #2624

@pvojtechovsky pvojtechovsky force-pushed the refImports branch 5 times, most recently from 2263ef0 to a567e54 Compare October 25, 2018 19:42
@pvojtechovsky pvojtechovsky force-pushed the refImports branch 6 times, most recently from 965ef15 to e9bf602 Compare November 1, 2018 22:13
@pvojtechovsky pvojtechovsky force-pushed the refImports branch 2 times, most recently from 009b837 to b2a2bdd Compare November 8, 2018 21:02
@pvojtechovsky pvojtechovsky force-pushed the refImports branch 2 times, most recently from 5804b2e to c593613 Compare November 26, 2018 18:42
@pvojtechovsky pvojtechovsky force-pushed the refImports branch 2 times, most recently from e7184bc to e4b62f7 Compare November 30, 2018 20:58
@pvojtechovsky
Copy link
Collaborator Author

Hallelujah! It passed all tests :-)

So, I started to split this PR to smaller parts. Please see, review and merge other PRs, which comes from this one.

@pvojtechovsky
Copy link
Collaborator Author

@monperrus, I see you gave it a lot of time. Thank you for having look!
I will have a look at your changes and add comments here, so we can discuss and reach common understanding.

C1) You removed CtElement#print(boolean), whose purpose was to print Spoon model in form in which it really actually is - without any further modifications of model. Are you sure Spoon should not offer that possibility?

C2) I like new prettyprint() method, which is kind of higher level API from my point of view and which is needed too.

@monperrus
Copy link
Collaborator

Hi Pavel,

Yes, we're almost ready to merge. You did a fantastic job.

C1) You removed CtElement#print(boolean), whose purpose was to print Spoon model in form in which it really actually is - without any further modifications of model. Are you sure Spoon should not offer that possibility?

This is the goal of toString, toString is a debug method. However, you're right, it still hides some implicit elements such as this.. We can change this easily so as to show all implicit elements but: 1) we would have to change tons of assertions 2) we would break backward compatibility and break many tests in client code. So, I prefer to stay as is.

C2) I like new prettyprint() method, which is kind of higher level API from my point of view and which is needed too.

thanks :-) it's still experimental though (we sometimes create a fake compilation unit on the fly)

@pvojtechovsky
Copy link
Collaborator Author

it still hides some implicit elements such as this.

I agree with you, we should keep it hidden. So no change is needed.

@pvojtechovsky
Copy link
Collaborator Author

The status of this PR after commit 2dd73cd
is OK for me. I have no more comments.

@monperrus
Copy link
Collaborator

Let's cool it down a little bit. @nharrand I guess you would be the final one to merge.

@nharrand nharrand merged commit 85a3ab1 into INRIA:master Sep 9, 2019
@monperrus
Copy link
Collaborator

Big kudos to Pavel @pvojtechovsky
Spoon loves you ❤️❤️!

}
} else {
//May be this can never happen
throw new SpoonException("Check this case. Is it relvant or not?");
Copy link
Contributor

Choose a reason for hiding this comment

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

Typo: relvant -> relevant

Copy link
Collaborator

Choose a reason for hiding this comment

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

thanks @seintur but it's already merged, would you edit the file directly on Github?

@monperrus
Copy link
Collaborator

It seems that the reason is writing fully-qualified java.lang.*.

To solve this, I propose to never write java.lang.* in toString().

WDYT?

@nharrand
Copy link
Collaborator

So, you would like to always write import for classes part of the standard library? (like everything prefixed with java.lang or java.util ?) Or just java.lang?

@monperrus
Copy link
Collaborator

monperrus commented Sep 10, 2019 via email

@nharrand
Copy link
Collaborator

nharrand commented Sep 10, 2019

My bad for imports. Still why just java.lang and not all classes of the standard library?

@monperrus
Copy link
Collaborator

to be backward-compatible and get the client builds passing again.

@nharrand
Copy link
Collaborator

Ok my bad, after some clarification, java.lang is the only package imported by default, so it makes sense to simplify its fully qualified name all the time.
SGTM.

@seintur
Copy link
Contributor

seintur commented Sep 10, 2019

And broke also https://ci.inria.fr/sos/job/juliac/1056/

Don't know for sure this is only about java.lang.* stuff. Still investigating the issue...

@monperrus
Copy link
Collaborator

Started to analyze. We have three kinds of regressions:

  • R1 before toString was dependent on autoimport mode
  • R2 some changes in autoimport mode
  • R3 some changes in full-qualified autoimport mode

I'm on it.

@monperrus monperrus mentioned this pull request Nov 6, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants