Skip to content

Apply .singleQuoted on representing Node.Scalar from String if Resolver.default resolves that to other than .str.#198

Merged
norio-nomura merged 5 commits into
masterfrom
nn-smart-quoted-string
Jul 7, 2019
Merged

Apply .singleQuoted on representing Node.Scalar from String if Resolver.default resolves that to other than .str.#198
norio-nomura merged 5 commits into
masterfrom
nn-smart-quoted-string

Conversation

@norio-nomura

Copy link
Copy Markdown
Collaborator

Fixes #197

Apply `.singleQuoted` on representing `Node.Scalar` from `String` if `Resolver.default` resolves that to other than `.str`.
Fixes #197
public func represented() -> Node.Scalar {
return .init(self)
let scalar = Node.Scalar(self)
return scalar.resolvedTag.name == .str ? scalar : .init(self, Tag(.str), .singleQuoted)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The performance impact can be almost ignored since resolvedTag was previously called in serializeScalar(_:) on serializing.
https://github.com/jpsim/Yams/blob/41c33b6f96/Sources/Yams/Emitter.swift#L413

@jpsim jpsim left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Nice fix! Should we backport this to a 2.0.x release without the breaking changes?

@norio-nomura norio-nomura merged commit 0e210c0 into master Jul 7, 2019
@norio-nomura norio-nomura deleted the nn-smart-quoted-string branch July 7, 2019 06:54
@norio-nomura

Copy link
Copy Markdown
Collaborator Author

Should we backport this to a 2.0.x release without the breaking changes?

I'll branch yams-2.0-branch from 6694617 and open cherry-picking PR against that

norio-nomura added a commit that referenced this pull request Jul 7, 2019
Apply `.singleQuoted` on representing `Node.Scalar` from `String` if `Resolver.default` resolves that to other than `.str`.
norio-nomura added a commit that referenced this pull request Jul 7, 2019
…` from `String` if `Resolver.default` resolves that to other than `.str`.
ryohey added a commit to yonaskolb/XcodeGen that referenced this pull request Jul 15, 2021
Some values are now added quotes due to Yams 3.0.0 changes in jpsim/Yams#198
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.

Yams.dump dumps numerical String values as Number

2 participants