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

implement new line for brace #92

Merged
merged 9 commits into from
Mar 22, 2020
Merged

Conversation

po-miyasaka
Copy link
Collaborator

@po-miyasaka po-miyasaka commented Mar 21, 2020

resolved #49

As is

At first glance, it is difficult to understand the hierarchy

If the following is implimented,

struct A {
  let b: B
  let string: String
}

struct B {
  let string: String
  let int: Int
}

let target = A(b: B(string: "hoge", int: 0), string: "foo")
Debug.pp >>> target

the result will be the following.

A(b: B(string: "hoge",
       int: 0),
  string: "foo")

To be

Using indent and new-line make the hierarchy easier to understand.

the result will be the following.

A(
 b: B(
     string: "hoge",
     int: 0
    ),
 string: "foo"
)

@po-miyasaka po-miyasaka marked this pull request as ready for review March 21, 2020 16:59
Copy link
Owner

@YusukeHosonuma YusukeHosonuma left a comment

Choose a reason for hiding this comment

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

Congrats for fist commit 🎉

Comment on lines 99 to 105
Dog(
id: "pochi",
name: "ポチ",
nickname: nil,
age: 3,
homepage: https://www.google.com/
)
Copy link
Owner

Choose a reason for hiding this comment

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

I think about indent-size are should decided by Debug.Option.indent instead of class (or struct) name.

// indent = 2
Dog(
  id: "pochi",
  name: "ポチ",
...

// indent = 4
Dog(
    id: "pochi",
    name: "ポチ",
...

What do you think?

Copy link
Collaborator Author

@po-miyasaka po-miyasaka Mar 22, 2020

Choose a reason for hiding this comment

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

Fixed like that the indent depends on Debug.Option.

@@ -66,18 +66,19 @@ class MultilineFormatter: PrettyFormatter {
func objectString(
Copy link
Owner

Choose a reason for hiding this comment

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

I though about this format are decided by new option item Option.debug. objectFormat in detail design of #49 😅
But it's not bad idea that support only this style...

Which is better for the user...?

What do you think?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think option.objectFormat is not needed.

Sources/Core/Formatter/MultilineFormatter.swift Outdated Show resolved Hide resolved
Comment on lines 175 to 181
"dog-1": Dog(
id: "pochi",
name: "ポチ",
nickname: nil,
age: 3,
homepage: https://www.google.com/
),
Copy link
Owner

Choose a reason for hiding this comment

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

Hmmm, should we change dictionary format too for consistency of format? (I didn't think about this)

"dog-1": Dog(
    id: "pochi",
    name: "ポチ",
    nickname: nil,
    age: 3,
    homepage: https://www.google.com/,

    // dictionary in dictionary
    dict: [
        "apple": Apple(
            price: 100,
            sale: true
        ) ,
        "orange": Orange(
            price: 100,
            sale: true
        ) 
    ]
),

What do you think?

Copy link
Collaborator Author

@po-miyasaka po-miyasaka Mar 22, 2020

Choose a reason for hiding this comment

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

It's depends on MultilineFormatter.objectString.
I think this consistency is not bad.

Copy link
Owner

Choose a reason for hiding this comment

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

Are you say in other words that this problem should fixed but not in this PR?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oh, it will be fixed this issue.
#95

@codecov-io
Copy link

codecov-io commented Mar 22, 2020

Codecov Report

Merging #92 into master will increase coverage by 0.14%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #92      +/-   ##
==========================================
+ Coverage   77.25%   77.39%   +0.14%     
==========================================
  Files           9        9              
  Lines         321      323       +2     
==========================================
+ Hits          248      250       +2     
  Misses         73       73              
Impacted Files Coverage Δ
Sources/Core/Formatter/MultilineFormatter.swift 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1995ab4...62489dc. Read the comment docs.

po-miyasaka and others added 3 commits March 22, 2020 15:04
Co-Authored-By: Yusuke Hosonuma <tobi462@gmail.com>
…eHosonuma/SwiftPrettyPrint into feature/new-line-break-style
Copy link
Owner

@YusukeHosonuma YusukeHosonuma left a comment

Choose a reason for hiding this comment

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

Good work!
Please confirm last one comment from me.

)
)
"""

formatter = MultilineFormatter(option: option(indent: 2))
Copy link
Owner

Choose a reason for hiding this comment

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

Please add test when indent size are 4 too :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added test!

Copy link
Owner

@YusukeHosonuma YusukeHosonuma left a comment

Choose a reason for hiding this comment

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

Great!!

@po-miyasaka
Copy link
Collaborator Author

po-miyasaka commented Mar 22, 2020

Thanks for reviewing!!!!

@po-miyasaka po-miyasaka merged commit 167281d into master Mar 22, 2020
@po-miyasaka po-miyasaka deleted the feature/new-line-break-style branch March 22, 2020 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support line-break style format for struct and class
3 participants