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

Enum with rawValue parses comment #1154

Closed
rocketnik opened this issue Mar 20, 2023 · 2 comments · Fixed by #1176
Closed

Enum with rawValue parses comment #1154

rocketnik opened this issue Mar 20, 2023 · 2 comments · Fixed by #1176
Assignees
Labels

Comments

@rocketnik
Copy link

rocketnik commented Mar 20, 2023

The rawValue of enum cases is parsed wrong in sourcey 2.0.1.
As you can see in the output, the comment "some comment" is part of the rawValue.
I would expect the comment not to be part of the rawValue.
Currently wrong: zero = 0 // some comment
Expected correct: zero = 0
Workaround until fixed: put the comment on an extra line

source.swift

public enum SomeEnum: Int {
    case zero = 0 // some comment
    case positive = 1
    case negative = -1
}

template.ejs

<%
function asdf() {
    const typesEnums = types.all.filter(type => type.kind === "enum")
    return typesEnums
        .map((theEnum) =>
            theEnum.cases.map((enumCase) =>
                `${enumCase.name} = ${enumCase.rawValue}`
            )
            .join("\n")
        )
}
%>
<%-
asdf()
%>

output

// Generated using Sourcery 2.0.1 — https://github.com/krzysztofzablocki/Sourcery
// DO NOT EDIT

zero = 0 // some comment
positive = 1
negative = -1
@art-divin art-divin self-assigned this Jul 3, 2023
@art-divin art-divin added the bug label Jul 3, 2023
@art-divin
Copy link
Collaborator

Hello @rocketnik 👋,

thank you very much for providing enough details to reproduce the bug.

I have reproduced it in minutes and I am investigating the root cause.

Will keep you posted ⏲️

@art-divin
Copy link
Collaborator

#1176 resolves this issue

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 a pull request may close this issue.

2 participants