-
Notifications
You must be signed in to change notification settings - Fork 448
Add diagnostic for label with string segment #1864
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
Add diagnostic for label with string segment #1864
Conversation
a74cceb
to
53fbbe3
Compare
e5cc28a
to
59e16b6
Compare
e830959
to
ea4b71f
Compare
ea4b71f
to
7c0220b
Compare
@swift-ci please test |
@ahoppen It fails formatting the same code, this is the result @available(*, unavailable, message: """
foobar message.
""") func multilineMessage() {
}
multilineMessage() A quick debug I think it's because we do some post processing of multiline string when parsing a We can use the same method, but that require we convert the Or we should try to extract the What do you think? |
I think we should try just re-using |
40ac1bf
to
fdcb47f
Compare
@ahoppen I was just debugging and trying to figure out why we get this error I've tried to debug, but I can't find the reason
|
As the failure message says: What we do is remove all the trivia of the tree, run But when you remove the leading spaces from the closing That’s why in SwiftParserTest/Assertions.swift:735 (inside And as I’m looking at the code, I’m realizing that we could actually simplify /// Removes trivia from all tokens that don’t occur inside multiline string
/// literals.
///
/// We keep trivia inside multiline string literals because the indentation of
/// the closing quote of a multi-line string literals has impact on how much
/// leading trivia is stripped from the literal’s content.
class TriviaRemover: SyntaxRewriter {
override func visit(_ node: StringLiteralExprSyntax) -> ExprSyntax {
if node.openingQuote == .multilineStringQuoteToken() {
return ExprSyntax(node)
} else {
return super.visit(node)
}
}
override func visit(_ node: SimpleStringLiteralExprSyntax) -> ExprSyntax {
if node.openingQuote == .multilineStringQuoteToken() {
return ExprSyntax(node)
} else {
return super.visit(node)
}
}
override func visit(_ token: TokenSyntax) -> TokenSyntax {
return token.with(\.leadingTrivia, []).with(\.trailingTrivia, [])
}
} |
cb87d07
to
f6dbe22
Compare
@swift-ci please test |
f6dbe22
to
cf8d598
Compare
@swift-ci please test |
cf8d598
to
a795ee7
Compare
@swift-ci please test |
@swift-ci Please test Windows |
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.
A couple comments to prevent round-trip failures, otherwise LGTM.
57e0dea
to
fd9c925
Compare
@swift-ci Please test |
fd9c925
to
4226e7a
Compare
@swift-ci Please test |
@swift-ci Please test windows |
Resolves #1831