Skip to content

Commit 0bd5eef

Browse files
authored
Merge pull request #2183 from apple/revert-2150-kimdv/2147-sometimes-the-placeholder-is-identified-as-identifierpattern
Revert "Handle pattern as editor placeholder"
2 parents af32a12 + a6baf89 commit 0bd5eef

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
}

0 commit comments

Comments
 (0)