-
Notifications
You must be signed in to change notification settings - Fork 440
Implement more lexer diagnostics #1245
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
8db5890
to
0fec4fc
Compare
@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.
Nice!
@@ -474,6 +474,9 @@ extension FixItMessage where Self == StaticParserFixIt { | |||
public static var replaceCurlyQuoteByNormalQuote: Self { | |||
.init(#"replace curly quotes by '"'"#) | |||
} | |||
public static var replaceNonBreakingSpaceBySpace: Self { | |||
.init("replace non-breaking space by ' '") |
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.
by
-> with
? Same above this one as well
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.
Interesting. I would have always said by
but Google agrees that with
is preferred. This also changes the ReplaceTokensFixIt
, so I’ll do it in a follow-up PR.
7474459
to
6c9b223
Compare
@swift-ci Please test |
let error = result.error.map { error in | ||
return LexerError(error.kind, byteOffset: cursor.distance(to: error.position)) | ||
} | ||
error = error ?? result.error.map { LexerError($0.kind, byteOffset: cursor.distance(to: $0.position)) } |
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 we add a conversion method on LexingError
that takes the cursor
?
struct LexingError {
...
func toLexerError(_ initialCursor: Cursor) {
return LexerError(kind, initialCursor.distance(to: position)
}
}
...
error = error ?? result.error?.toLexerError(cursor)
6c9b223
to
3f7b8a6
Compare
@swift-ci Please test |
…id identifier starts
Fixes swiftlang#1214 rdar://104082735
6a28005
to
139f9df
Compare
@swift-ci Please test |
As discussed in swiftlang#1245 (comment)
This implements a few more lexer diagnostics.
Each commit of this PR should be standalone and should be reviewable on its own. But since they all build on top of each other, I can’t really create separate PRs for them.