Skip to content

Commit 764dce1

Browse files
authored
Merge pull request #2271 from kimdv/kimdv/revert-2147-sometimes-the-placeholder-is-identified-as-identifierpattern
[5.10] Revert "Handle pattern as editor placeholder"
2 parents dc426fa + d7ca4a9 commit 764dce1

25 files changed

+17
-672
lines changed

CodeGeneration/Sources/SyntaxSupport/PatternNodes.swift

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -182,22 +182,4 @@ public let PATTERN_NODES: [Node] = [
182182
]
183183
),
184184

185-
Node(
186-
kind: .editorPlaceholderPattern,
187-
base: .pattern,
188-
nameForDiagnostics: "editor placeholder",
189-
documentation: """
190-
An editor placeholder, e.g. `<#pattern#>` that is used in a position that expects a pattern.
191-
""",
192-
children: [
193-
Child(
194-
name: "placeholder",
195-
kind: .token(choices: [.token(.identifier)]),
196-
documentation: """
197-
The actual editor placeholder that starts with `<#` and ends with `#>`.
198-
"""
199-
)
200-
]
201-
),
202-
203185
]

CodeGeneration/Sources/SyntaxSupport/SyntaxNodeKind.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ public enum SyntaxNodeKind: String, CaseIterable {
111111
case dynamicReplacementAttributeArguments
112112
case editorPlaceholderDecl
113113
case editorPlaceholderExpr
114-
case editorPlaceholderPattern
115-
case editorPlaceholderType
116114
case effectsAttributeArgumentList
117115
case enumCaseDecl
118116
case enumCaseElement

CodeGeneration/Sources/SyntaxSupport/TypeNodes.swift

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -530,28 +530,4 @@ public let TYPE_NODES: [Node] = [
530530
]
531531
),
532532

533-
Node(
534-
kind: .editorPlaceholderType,
535-
base: .type,
536-
nameForDiagnostics: "editor placeholder",
537-
documentation: """
538-
An editor placeholder, e.g. `<#Type#>` that is used in a position that expects a type.
539-
""",
540-
children: [
541-
Child(
542-
name: "placeholder",
543-
kind: .token(choices: [.token(.identifier)]),
544-
documentation: """
545-
The actual editor placeholder that starts with `<#` and ends with `#>`.
546-
"""
547-
),
548-
Child(
549-
name: "genericArgumentClause",
550-
kind: .node(kind: .genericArgumentClause),
551-
documentation: "Generic arguments that is attatched to the type.",
552-
isOptional: true
553-
),
554-
]
555-
),
556-
557533
]

Release Notes/510.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,6 @@
2121
- Description: Remarks are used by the Swift compiler and other tools to describe some aspect of translation that doesn't reflect correctness, but may be useful for the user. Remarks have been added to the diagnostic severity enums to align with the Swift compiler.
2222
- Pull Request: https://github.com/apple/swift-syntax/pull/2143
2323

24-
- New pattern node `EditorPlaceholderPatternSyntax`
25-
- Description: This node type will be placeholder that is used in a position that expects a pattern.
26-
- Issue: https://github.com/apple/swift-syntax/issues/2147
27-
- Pull Request: https://github.com/apple/swift-syntax/pull/2150
28-
29-
- New type node `EditorPlaceholderTypeSyntax`
30-
- Description: This node type will be placeholder that is used in a position that expects a type.
31-
- Issue: https://github.com/apple/swift-syntax/issues/2156
32-
- Pull Request: https://github.com/apple/swift-syntax/pull/2150
33-
3424
## API Behavior Changes
3525

3626
## Deprecations

Sources/SwiftParser/Patterns.swift

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -70,21 +70,12 @@ extension Parser {
7070
)
7171
case (.lhs(.identifier), let handle)?:
7272
let identifier = self.eat(handle)
73-
if identifier.tokenText.isEditorPlaceholder {
74-
return RawPatternSyntax(
75-
RawEditorPlaceholderPatternSyntax(
76-
placeholder: identifier,
77-
arena: self.arena
78-
)
79-
)
80-
} else {
81-
return RawPatternSyntax(
82-
RawIdentifierPatternSyntax(
83-
identifier: identifier,
84-
arena: self.arena
85-
)
73+
return RawPatternSyntax(
74+
RawIdentifierPatternSyntax(
75+
identifier: identifier,
76+
arena: self.arena
8677
)
87-
}
78+
)
8879
case (.lhs(.dollarIdentifier), let handle)?:
8980
let dollarIdent = self.eat(handle)
9081
let unexpectedBeforeIdentifier = RawUnexpectedNodesSyntax(elements: [RawSyntax(dollarIdent)], arena: self.arena)

Sources/SwiftParser/Types.swift

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -349,25 +349,14 @@ extension Parser {
349349
generics = nil
350350
}
351351

352-
if name.tokenText.isEditorPlaceholder {
353-
return RawTypeSyntax(
354-
RawEditorPlaceholderTypeSyntax(
355-
placeholder: name,
356-
genericArgumentClause: generics,
357-
arena: self.arena
358-
)
359-
)
360-
} else {
361-
return RawTypeSyntax(
362-
RawIdentifierTypeSyntax(
363-
unexpectedBeforeName,
364-
name: name,
365-
genericArgumentClause: generics,
366-
arena: self.arena
367-
)
352+
return RawTypeSyntax(
353+
RawIdentifierTypeSyntax(
354+
unexpectedBeforeName,
355+
name: name,
356+
genericArgumentClause: generics,
357+
arena: self.arena
368358
)
369-
}
370-
359+
)
371360
}
372361

373362
/// Parse the existential `Any` type.
@@ -949,9 +938,7 @@ extension Parser {
949938

950939
extension Parser {
951940
mutating func parseResultType() -> RawTypeSyntax {
952-
if self.at(prefix: "<#") {
953-
return self.parseTypeIdentifier()
954-
} else if self.at(prefix: "<") {
941+
if self.at(prefix: "<") {
955942
let generics = self.parseGenericParameters()
956943
let baseType = self.parseType()
957944
return RawTypeSyntax(

Sources/SwiftParserDiagnostics/generated/SyntaxKindNameForDiagnostics.swift

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,6 @@ extension SyntaxKind {
143143
return "editor placeholder"
144144
case .editorPlaceholderExpr:
145145
return "editor placeholder"
146-
case .editorPlaceholderPattern:
147-
return "editor placeholder"
148-
case .editorPlaceholderType:
149-
return "editor placeholder"
150146
case .effectsAttributeArgumentList:
151147
return "@_effects arguments"
152148
case .enumCaseDecl:

Sources/SwiftSyntax/Documentation.docc/generated/SwiftSyntax.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ These articles are intended for developers wishing to contribute to SwiftSyntax
151151
- <doc:SwiftSyntax/PatternSyntax>
152152
- <doc:SwiftSyntax/PatternSyntaxProtocol>
153153
- <doc:SwiftSyntax/MissingPatternSyntax>
154-
- <doc:SwiftSyntax/EditorPlaceholderPatternSyntax>
155154
- <doc:SwiftSyntax/ExpressionPatternSyntax>
156155
- <doc:SwiftSyntax/IdentifierPatternSyntax>
157156
- <doc:SwiftSyntax/IsTypePatternSyntax>
@@ -191,7 +190,6 @@ These articles are intended for developers wishing to contribute to SwiftSyntax
191190
- <doc:SwiftSyntax/ClassRestrictionTypeSyntax>
192191
- <doc:SwiftSyntax/CompositionTypeSyntax>
193192
- <doc:SwiftSyntax/DictionaryTypeSyntax>
194-
- <doc:SwiftSyntax/EditorPlaceholderTypeSyntax>
195193
- <doc:SwiftSyntax/FunctionTypeSyntax>
196194
- <doc:SwiftSyntax/IdentifierTypeSyntax>
197195
- <doc:SwiftSyntax/ImplicitlyUnwrappedOptionalTypeSyntax>

Sources/SwiftSyntax/generated/ChildNameForKeyPath.swift

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1077,22 +1077,6 @@ public func childName(_ keyPath: AnyKeyPath) -> String? {
10771077
return "placeholder"
10781078
case \EditorPlaceholderExprSyntax.unexpectedAfterPlaceholder:
10791079
return "unexpectedAfterPlaceholder"
1080-
case \EditorPlaceholderPatternSyntax.unexpectedBeforePlaceholder:
1081-
return "unexpectedBeforePlaceholder"
1082-
case \EditorPlaceholderPatternSyntax.placeholder:
1083-
return "placeholder"
1084-
case \EditorPlaceholderPatternSyntax.unexpectedAfterPlaceholder:
1085-
return "unexpectedAfterPlaceholder"
1086-
case \EditorPlaceholderTypeSyntax.unexpectedBeforePlaceholder:
1087-
return "unexpectedBeforePlaceholder"
1088-
case \EditorPlaceholderTypeSyntax.placeholder:
1089-
return "placeholder"
1090-
case \EditorPlaceholderTypeSyntax.unexpectedBetweenPlaceholderAndGenericArgumentClause:
1091-
return "unexpectedBetweenPlaceholderAndGenericArgumentClause"
1092-
case \EditorPlaceholderTypeSyntax.genericArgumentClause:
1093-
return "genericArgumentClause"
1094-
case \EditorPlaceholderTypeSyntax.unexpectedAfterGenericArgumentClause:
1095-
return "unexpectedAfterGenericArgumentClause"
10961080
case \EnumCaseDeclSyntax.unexpectedBeforeAttributes:
10971081
return "unexpectedBeforeAttributes"
10981082
case \EnumCaseDeclSyntax.attributes:

Sources/SwiftSyntax/generated/SyntaxAnyVisitor.swift

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -776,22 +776,6 @@ open class SyntaxAnyVisitor: SyntaxVisitor {
776776
visitAnyPost(node._syntaxNode)
777777
}
778778

779-
override open func visit(_ node: EditorPlaceholderPatternSyntax) -> SyntaxVisitorContinueKind {
780-
return visitAny(node._syntaxNode)
781-
}
782-
783-
override open func visitPost(_ node: EditorPlaceholderPatternSyntax) {
784-
visitAnyPost(node._syntaxNode)
785-
}
786-
787-
override open func visit(_ node: EditorPlaceholderTypeSyntax) -> SyntaxVisitorContinueKind {
788-
return visitAny(node._syntaxNode)
789-
}
790-
791-
override open func visitPost(_ node: EditorPlaceholderTypeSyntax) {
792-
visitAnyPost(node._syntaxNode)
793-
}
794-
795779
override open func visit(_ node: EffectsAttributeArgumentListSyntax) -> SyntaxVisitorContinueKind {
796780
return visitAny(node._syntaxNode)
797781
}

Sources/SwiftSyntax/generated/SyntaxBaseNodes.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ public struct PatternSyntax: PatternSyntaxProtocol, SyntaxHashable {
770770

771771
public init?(_ node: some SyntaxProtocol) {
772772
switch node.raw.kind {
773-
case .editorPlaceholderPattern, .expressionPattern, .identifierPattern, .isTypePattern, .missingPattern, .tuplePattern, .valueBindingPattern, .wildcardPattern:
773+
case .expressionPattern, .identifierPattern, .isTypePattern, .missingPattern, .tuplePattern, .valueBindingPattern, .wildcardPattern:
774774
self._syntaxNode = node._syntaxNode
775775
default:
776776
return nil
@@ -795,7 +795,6 @@ public struct PatternSyntax: PatternSyntaxProtocol, SyntaxHashable {
795795

796796
public static var structure: SyntaxNodeStructure {
797797
return .choices([
798-
.node(EditorPlaceholderPatternSyntax.self),
799798
.node(ExpressionPatternSyntax.self),
800799
.node(IdentifierPatternSyntax.self),
801800
.node(IsTypePatternSyntax.self),
@@ -1299,7 +1298,7 @@ public struct TypeSyntax: TypeSyntaxProtocol, SyntaxHashable {
12991298

13001299
public init?(_ node: some SyntaxProtocol) {
13011300
switch node.raw.kind {
1302-
case .arrayType, .attributedType, .classRestrictionType, .compositionType, .dictionaryType, .editorPlaceholderType, .functionType, .identifierType, .implicitlyUnwrappedOptionalType, .memberType, .metatypeType, .missingType, .namedOpaqueReturnType, .optionalType, .packElementType, .packExpansionType, .someOrAnyType, .suppressedType, .tupleType:
1301+
case .arrayType, .attributedType, .classRestrictionType, .compositionType, .dictionaryType, .functionType, .identifierType, .implicitlyUnwrappedOptionalType, .memberType, .metatypeType, .missingType, .namedOpaqueReturnType, .optionalType, .packElementType, .packExpansionType, .someOrAnyType, .suppressedType, .tupleType:
13031302
self._syntaxNode = node._syntaxNode
13041303
default:
13051304
return nil
@@ -1329,7 +1328,6 @@ public struct TypeSyntax: TypeSyntaxProtocol, SyntaxHashable {
13291328
.node(ClassRestrictionTypeSyntax.self),
13301329
.node(CompositionTypeSyntax.self),
13311330
.node(DictionaryTypeSyntax.self),
1332-
.node(EditorPlaceholderTypeSyntax.self),
13331331
.node(FunctionTypeSyntax.self),
13341332
.node(IdentifierTypeSyntax.self),
13351333
.node(ImplicitlyUnwrappedOptionalTypeSyntax.self),
@@ -1488,8 +1486,6 @@ extension Syntax {
14881486
.node(DynamicReplacementAttributeArgumentsSyntax.self),
14891487
.node(EditorPlaceholderDeclSyntax.self),
14901488
.node(EditorPlaceholderExprSyntax.self),
1491-
.node(EditorPlaceholderPatternSyntax.self),
1492-
.node(EditorPlaceholderTypeSyntax.self),
14931489
.node(EffectsAttributeArgumentListSyntax.self),
14941490
.node(EnumCaseDeclSyntax.self),
14951491
.node(EnumCaseElementListSyntax.self),

Sources/SwiftSyntax/generated/SyntaxEnum.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ public enum SyntaxEnum {
105105
case dynamicReplacementAttributeArguments(DynamicReplacementAttributeArgumentsSyntax)
106106
case editorPlaceholderDecl(EditorPlaceholderDeclSyntax)
107107
case editorPlaceholderExpr(EditorPlaceholderExprSyntax)
108-
case editorPlaceholderPattern(EditorPlaceholderPatternSyntax)
109-
case editorPlaceholderType(EditorPlaceholderTypeSyntax)
110108
case effectsAttributeArgumentList(EffectsAttributeArgumentListSyntax)
111109
case enumCaseDecl(EnumCaseDeclSyntax)
112110
case enumCaseElementList(EnumCaseElementListSyntax)
@@ -481,10 +479,6 @@ public extension Syntax {
481479
return .editorPlaceholderDecl(EditorPlaceholderDeclSyntax(self)!)
482480
case .editorPlaceholderExpr:
483481
return .editorPlaceholderExpr(EditorPlaceholderExprSyntax(self)!)
484-
case .editorPlaceholderPattern:
485-
return .editorPlaceholderPattern(EditorPlaceholderPatternSyntax(self)!)
486-
case .editorPlaceholderType:
487-
return .editorPlaceholderType(EditorPlaceholderTypeSyntax(self)!)
488482
case .effectsAttributeArgumentList:
489483
return .effectsAttributeArgumentList(EffectsAttributeArgumentListSyntax(self)!)
490484
case .enumCaseDecl:

Sources/SwiftSyntax/generated/SyntaxKind.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ public enum SyntaxKind: CaseIterable {
105105
case dynamicReplacementAttributeArguments
106106
case editorPlaceholderDecl
107107
case editorPlaceholderExpr
108-
case editorPlaceholderPattern
109-
case editorPlaceholderType
110108
case effectsAttributeArgumentList
111109
case enumCaseDecl
112110
case enumCaseElementList
@@ -602,10 +600,6 @@ public enum SyntaxKind: CaseIterable {
602600
return EditorPlaceholderDeclSyntax.self
603601
case .editorPlaceholderExpr:
604602
return EditorPlaceholderExprSyntax.self
605-
case .editorPlaceholderPattern:
606-
return EditorPlaceholderPatternSyntax.self
607-
case .editorPlaceholderType:
608-
return EditorPlaceholderTypeSyntax.self
609603
case .effectsAttributeArgumentList:
610604
return EffectsAttributeArgumentListSyntax.self
611605
case .enumCaseDecl:

Sources/SwiftSyntax/generated/SyntaxRewriter.swift

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -710,20 +710,6 @@ open class SyntaxRewriter {
710710
return ExprSyntax(visitChildren(node))
711711
}
712712

713-
/// Visit a ``EditorPlaceholderPatternSyntax``.
714-
/// - Parameter node: the node that is being visited
715-
/// - Returns: the rewritten node
716-
open func visit(_ node: EditorPlaceholderPatternSyntax) -> PatternSyntax {
717-
return PatternSyntax(visitChildren(node))
718-
}
719-
720-
/// Visit a ``EditorPlaceholderTypeSyntax``.
721-
/// - Parameter node: the node that is being visited
722-
/// - Returns: the rewritten node
723-
open func visit(_ node: EditorPlaceholderTypeSyntax) -> TypeSyntax {
724-
return TypeSyntax(visitChildren(node))
725-
}
726-
727713
/// Visit a ``EffectsAttributeArgumentListSyntax``.
728714
/// - Parameter node: the node that is being visited
729715
/// - Returns: the rewritten node
@@ -2470,14 +2456,6 @@ open class SyntaxRewriter {
24702456
return {
24712457
self.visitImpl($0, EditorPlaceholderExprSyntax.self, self.visit)
24722458
}
2473-
case .editorPlaceholderPattern:
2474-
return {
2475-
self.visitImpl($0, EditorPlaceholderPatternSyntax.self, self.visit)
2476-
}
2477-
case .editorPlaceholderType:
2478-
return {
2479-
self.visitImpl($0, EditorPlaceholderTypeSyntax.self, self.visit)
2480-
}
24812459
case .effectsAttributeArgumentList:
24822460
return {
24832461
self.visitImpl($0, EffectsAttributeArgumentListSyntax.self, self.visit)
@@ -3412,10 +3390,6 @@ open class SyntaxRewriter {
34123390
return visitImpl(node, EditorPlaceholderDeclSyntax.self, visit)
34133391
case .editorPlaceholderExpr:
34143392
return visitImpl(node, EditorPlaceholderExprSyntax.self, visit)
3415-
case .editorPlaceholderPattern:
3416-
return visitImpl(node, EditorPlaceholderPatternSyntax.self, visit)
3417-
case .editorPlaceholderType:
3418-
return visitImpl(node, EditorPlaceholderTypeSyntax.self, visit)
34193393
case .effectsAttributeArgumentList:
34203394
return visitImpl(node, EffectsAttributeArgumentListSyntax.self, visit)
34213395
case .enumCaseDecl:

0 commit comments

Comments
 (0)