File tree Expand file tree Collapse file tree 4 files changed +11
-3
lines changed
Tests/SwiftParserTest/translated Expand file tree Collapse file tree 4 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -2058,6 +2058,7 @@ extension Lexer.Cursor {
2058
2058
extension Lexer . Cursor {
2059
2059
mutating func tryLexEditorPlaceholder( sourceBufferStart: Lexer . Cursor ) -> Lexer . Result {
2060
2060
assert ( self . is ( at: " < " ) && self . is ( offset: 1 , at: " # " ) )
2061
+ let start = self
2061
2062
var ptr = self
2062
2063
let leftAngleConsumed = ptr. advance ( matching: " < " )
2063
2064
let poundConsumed = ptr. advance ( matching: " # " )
@@ -2072,7 +2073,10 @@ extension Lexer.Cursor {
2072
2073
let closingAngleConsumed = ptr. advance ( matching: " > " )
2073
2074
assert ( closingAngleConsumed)
2074
2075
self = ptr
2075
- return Lexer . Result ( . identifier)
2076
+ return Lexer . Result (
2077
+ . identifier,
2078
+ error: LexingDiagnostic ( . invalidIdentifierStartCharacter, position: start)
2079
+ )
2076
2080
default :
2077
2081
break
2078
2082
}
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ public extension TokenError {
38
38
39
39
/// Please order the cases in this enum alphabetically by case name.
40
40
public enum StaticTokenError : String , DiagnosticMessage {
41
+ case editorPlaceholder = " editor placeholder in source file "
41
42
case expectedBinaryExponentInHexFloatLiteral = " hexadecimal floating point literal must end with an exponent "
42
43
case expectedClosingBraceInUnicodeEscape = #"expected '}' in \u{...} escape sequence"#
43
44
case expectedDigitInFloatLiteral = " expected a digit in floating point exponent "
@@ -132,6 +133,7 @@ public extension SwiftSyntax.TokenDiagnostic {
132
133
}
133
134
134
135
switch self . kind {
136
+ case . editorPlaceholder: return StaticTokenError . editorPlaceholder
135
137
case . expectedBinaryExponentInHexFloatLiteral: return StaticTokenError . expectedBinaryExponentInHexFloatLiteral
136
138
case . expectedClosingBraceInUnicodeEscape: return StaticTokenError . expectedClosingBraceInUnicodeEscape
137
139
case . expectedDigitInFloatLiteral: return StaticTokenError . expectedDigitInFloatLiteral
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ public struct TokenDiagnostic: Hashable {
22
22
public enum Kind {
23
23
// Please order these alphabetically
24
24
25
+ case editorPlaceholder
25
26
case expectedBinaryExponentInHexFloatLiteral
26
27
case expectedClosingBraceInUnicodeEscape
27
28
case expectedDigitInFloatLiteral
@@ -94,6 +95,7 @@ public struct TokenDiagnostic: Hashable {
94
95
95
96
public var severity : Severity {
96
97
switch kind {
98
+ case . editorPlaceholder: return . error
97
99
case . expectedBinaryExponentInHexFloatLiteral: return . error
98
100
case . expectedClosingBraceInUnicodeEscape: return . error
99
101
case . expectedDigitInFloatLiteral: return . error
Original file line number Diff line number Diff line change @@ -83,10 +83,10 @@ final class IdentifiersTests: XCTestCase {
83
83
AssertParse (
84
84
"""
85
85
// Placeholders are recognized as identifiers but with error.
86
- func <#some name#>() {}
86
+ func 1️⃣ <#some name#>() {}
87
87
""" ,
88
88
diagnostics: [
89
- // TODO: (good first issue) Old parser expected error on line 2: editor placeholder in source file
89
+ DiagnosticSpec ( message : " editor placeholder in source file " )
90
90
]
91
91
)
92
92
}
You can’t perform that action at this time.
0 commit comments