Skip to content

[CodeGeneration] Minimize per-type parse(from:) code #2974

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

Merged
merged 1 commit into from
Feb 27, 2025

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Feb 24, 2025

Introduce internal SyntaxParseableImpl protocol which provides the implementation of the reminder parsing, and the RawSyntax -> Syntax bridging.

@rintaro
Copy link
Member Author

rintaro commented Feb 24, 2025

@swift-ci Please test

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks

Comment on lines 39 to 44
public static func parse(from parser: inout Parser) -> Self {
// Keep the parser alive so that the arena in which `raw` is allocated
// doesn’t get deallocated before we have a chance to create a syntax node
// from it. We can’t use `parser.arena` as the parameter to
// `Syntax(raw:arena:)` because the node might have been re-used during an
// incremental parse and would then live in a different arena than
// `parser.arena`.
defer { withExtendedLifetime(parser) {} }
let node = Self.parseRaw(from: &parser)
let raw = RawSyntax(parser.parseRemainder(into: node))
return Syntax(raw: raw, rawNodeArena: raw.arena).cast(Self.self)
}
Copy link
Member

Choose a reason for hiding this comment

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

Could you use 2 space for indentation here?

@rintaro rintaro force-pushed the layout-parseable-impl branch 2 times, most recently from 7b87b12 to 56f47e3 Compare February 26, 2025 18:34
@rintaro
Copy link
Member Author

rintaro commented Feb 26, 2025

@swift-ci Please test

@rintaro
Copy link
Member Author

rintaro commented Feb 26, 2025

@swift-ci Please test Windows

@rintaro rintaro force-pushed the layout-parseable-impl branch from 56f47e3 to 3981815 Compare February 26, 2025 18:42
Use a delegating function `SyntaxParseable.parse(from:parse:)` similar
to the collection node version
`SyntaxCollection.parse(from:parse:makeMissing`.
@rintaro rintaro force-pushed the layout-parseable-impl branch from 3981815 to 2d3ba35 Compare February 26, 2025 18:43
@rintaro
Copy link
Member Author

rintaro commented Feb 26, 2025

@swift-ci Please test

@rintaro
Copy link
Member Author

rintaro commented Feb 26, 2025

@swift-ci Please test Windwos

@rintaro
Copy link
Member Author

rintaro commented Feb 26, 2025

@swift-ci Please test

@rintaro rintaro merged commit 219fa33 into swiftlang:main Feb 27, 2025
3 checks passed
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.

2 participants