@@ -459,28 +459,47 @@ public class ParseDiagnosticsGenerator: SyntaxAnyVisitor {
459459 }
460460 if node. hasError,
461461 let unexpectedBeforeAtSignTokens = node. unexpectedBeforeAtSignToken,
462- let unexpectedBeforeAtSign = unexpectedBeforeAtSignTokens. lastToken ( viewMode: . sourceAccurate) ,
463- unexpectedBeforeAtSign. tokenKind == . atSign,
464- !unexpectedBeforeAtSign. trailingTrivia. isEmpty {
462+ let unexpectedBeforeAtSign = unexpectedBeforeAtSignTokens. lastToken ( viewMode: . sourceAccurate) {
465463 let tokensToDiscard = unexpectedBeforeAtSignTokens. compactMap { $0. as ( TokenSyntax . self) }
466- addDiagnostic (
467- unexpectedBeforeAtSign,
468- StaticParserError . invalidWhitespaceBetweenAttributeAtSignAndIdentifier,
469- fixIts: [
470- FixIt (
471- message: StaticParserFixIt . removeExtraneousWhitespace,
472- changes: [
473- . makeMissing( tokensToDiscard, transferTrivia: false ) ,
474- . makePresent( node. atSignToken) ,
475- ]
476- )
477- ] ,
478- handledNodes: [
479- node. id,
480- unexpectedBeforeAtSignTokens. id,
481- node. atSignToken. id
482- ]
483- )
464+ if unexpectedBeforeAtSign. tokenKind == . atSign, !unexpectedBeforeAtSign. trailingTrivia. isEmpty {
465+ addDiagnostic (
466+ unexpectedBeforeAtSign,
467+ StaticParserError . invalidWhitespaceBetweenAttributeAtSignAndIdentifier,
468+ fixIts: [
469+ FixIt (
470+ message: StaticParserFixIt . removeExtraneousWhitespace,
471+ changes: [
472+ . makeMissing( tokensToDiscard, transferTrivia: false ) ,
473+ . makePresent( node. atSignToken) ,
474+ ]
475+ )
476+ ] ,
477+ handledNodes: [
478+ node. id,
479+ unexpectedBeforeAtSignTokens. id,
480+ node. atSignToken. id
481+ ]
482+ )
483+ } else if unexpectedBeforeAtSign. tokenKind == . identifier( unexpectedBeforeAtSign. text) {
484+ addDiagnostic (
485+ unexpectedBeforeAtSign,
486+ StaticParserError . invalidWhitespaceBetweenAttributeAtSignAndIdentifier,
487+ fixIts: [
488+ FixIt (
489+ message: StaticParserFixIt . removeExtraneousWhitespace,
490+ changes: [
491+ . makeMissing( tokensToDiscard, transferTrivia: false ) ,
492+ . makePresent( node. attributeName) , // TODO: Provide synthesized attributeName as a replacement.
493+ ]
494+ )
495+ ] ,
496+ handledNodes: [
497+ node. id,
498+ unexpectedBeforeAtSignTokens. id,
499+ node. attributeName. id
500+ ]
501+ )
502+ }
484503 }
485504 return . visitChildren
486505 }
0 commit comments