-
Notifications
You must be signed in to change notification settings - Fork 419
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
[SwiftParser] Support function body and type member skipping #2316
base: main
Are you sure you want to change the base?
Conversation
@@ -2791,6 +2791,12 @@ public func childName(_ keyPath: AnyKeyPath) -> String? { | |||
return "closingQuote" | |||
case \SimpleStringLiteralExprSyntax.unexpectedAfterClosingQuote: | |||
return "unexpectedAfterClosingQuote" | |||
case \SkippedDeclSyntax.unexpectedBeforeText: | |||
return "unexpectedBeforeText" |
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.
Can we remove these unexpected
items?
if let peekedScalar = start.peekScalar(), peekedScalar.isValidIdentifierStartCodePoint { | ||
break | ||
} | ||
if let peekedScalar = start.peekScalar(), peekedScalar.isOperatorStartCodePoint { | ||
if let peekedScalar = start.peekScalar(), | ||
peekedScalar.isValidIdentifierStartCodePoint || peekedScalar.isOperatorStartCodePoint { |
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.
unrelated?
mutating func skippedBraceBody(unless: Lookahead.SkipBodyResult) -> RawSkippedDeclSyntax? { | ||
return self.withLookahead { lookahead in | ||
let result = lookahead.advanceUntilMatchingRightBrace() | ||
guard result.isDisjoint(with: unless) else { |
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.
Instead of checking the result on the skipped area, the skipping function should bail out and return nil
as soon as it finds any unless
condition.
// Nested class. Because? | ||
if tokenKind == .keyword && tokenText == "class" { | ||
return false | ||
} |
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.
It's because of AnyObject lookup :shakesfist:
ParsingOptions
option-set type withbodySkipping
member, and addoptions: ParsingOptions
to allParser.parse(...)
functionsSkippedDeclSyntax
SkippedDeclSyntax
contains only one.unknown
token that covers the whole skipped characters including trivia.#if
directives