-
Notifications
You must be signed in to change notification settings - Fork 439
[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
Conversation
@swift-ci Please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks
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) | ||
} |
There was a problem hiding this comment.
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?
7b87b12
to
56f47e3
Compare
@swift-ci Please test |
@swift-ci Please test Windows |
56f47e3
to
3981815
Compare
Use a delegating function `SyntaxParseable.parse(from:parse:)` similar to the collection node version `SyntaxCollection.parse(from:parse:makeMissing`.
3981815
to
2d3ba35
Compare
@swift-ci Please test |
@swift-ci Please test Windwos |
@swift-ci Please test |
Introduce internal
SyntaxParseableImpl
protocol which provides the implementation of the reminder parsing, and theRawSyntax
->Syntax
bridging.