Skip to content

Make class extends and implements prettier by fitting to line width #13

Closed

Description

@tvonhacht

https://github.com/thorbenvh8/prettier-java/blob/master/PREVIEW.md#extends_abstract_class_and_implements_interfaces

public class ExtendsAbstractClassAndImplementsInterfaces extends AbstractClass implements Interface1, Interface2 {
It's just a line right now, when doesn't fit line, it should look like this? (open for discussion @azz)

public class ExtendsAbstractClassAndImplementsInterfaces
indent extends AbstractClass
indent implements Interface1,
same pos as Inter1 Interface2
{`
(formatting code in an issue is hard?!)

Activity

  1. j-f1 commented on Jan 8, 2018

    @j-f1

    You could check out how it’s implemented in TypeScript for inspiration.

  2. tvonhacht commented on Jan 8, 2018

    @tvonhacht
    Author

    its just the same as i have, but is that really cool and readable?

  3. j-f1 commented on Jan 8, 2018

    @j-f1

    is that really cool and readable?

    It might not be, but since people probably shouldn’t be writing code that’s that long, they should be willing to accept the result.

  4. tvonhacht commented on Jan 8, 2018

    @tvonhacht
    Author

    From my experience its pretty common to have a class that extends and has at least 2 interfaces to implement. Actually that what you should love about java :)
    I will work on this one on the next weekend and show you the output. Maybe I can convince you :)
    Thanks for your feedback, I really appreciate this fast feedback!

  5. j-f1 commented on Jan 8, 2018

    @j-f1

    I was just going by my TS knowledge (I don’t know Java, I’m just attempting to help based on what I know of other languages).

  6. tvonhacht commented on Jan 8, 2018

    @tvonhacht
    Author

    I'm very grateful for your feedback, I hope I didn't come off wrong.

  7. self-assigned this
    on Jan 9, 2018
  8. tvonhacht commented on Jan 9, 2018

    @tvonhacht
    Author
  9. j-f1 commented on Jan 9, 2018

    @j-f1

    That looks really nice! If you have time, would you be willing to contribute that style to the JS printer? The current style is not as nice.

  10. tvonhacht commented on Jan 9, 2018

    @tvonhacht
    Author

    @j-f1 It would be an honor for me :)
    you mean prettier/prettier project?

  11. j-f1 commented on Jan 9, 2018

    @j-f1

    Yes, that’s the one.

  12. tvonhacht commented on Jan 9, 2018

    @tvonhacht
    Author

    @j-f1 I implemented it here in my own fork branch :)
    https://github.com/thorbenvh8/prettier/tree/extends_implements
    can you please check? I actually changed 148 snapshots...

  13. tvonhacht commented on Jan 9, 2018

    @tvonhacht
    Author

    I made it so it always adds a hardline before extends and implements no matter how long the line

  14. j-f1 commented on Jan 9, 2018

    @j-f1

    I made it so it always adds a hardline before extends and implements

    That doesn’t look as nice IMO — it should only break if needed, especially since implementing multiple interfaces isn’t as common in JS-land.

  15. azz commented on Jan 9, 2018

    @azz
    Contributor

    Yeah we definitely want to keep the "if it fits, print it" approach.

  16. tvonhacht commented on Jan 9, 2018

    @tvonhacht
    Author

    Ok fixed it :) sorry for the missunderstanding :) Will do this in java too, youre right it makes sense :)
    This is the output now :)
    Screen_Shot_2018_01_09_at_8_40_09_AM

    @j-f1 @azz Im gonna create a pull request from this?

  17. j-f1 commented on Jan 9, 2018

    @j-f1

    Looks awesome!

  18. azz commented on Jan 9, 2018

    @azz
    Contributor

    Great stuff! Absolutely open a PR :)

  19. tvonhacht commented on Jan 9, 2018

    @tvonhacht
    Author
  20. tvonhacht commented on Jan 9, 2018

    @tvonhacht
    Author

    Side question why does the ci pipeline in travis takes 52 mins?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions