Skip to content

Commit 62f67c9

Browse files
committed
Add function with placeholders test
1 parent 6508d78 commit 62f67c9

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

Tests/SwiftParserTest/DeclarationTests.swift

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2550,4 +2550,47 @@ final class DeclarationTests: ParserTestCase {
25502550
"""
25512551
)
25522552
}
2553+
2554+
func testFunctionDeclarationWithPlaceholder() {
2555+
assertParse(
2556+
"""
2557+
func 1️⃣<#name#>(2️⃣<#parameters#>) -> 3️⃣<#return type#> {
2558+
4️⃣<#function body#>
2559+
}
2560+
""",
2561+
substructure: FunctionDeclSyntax(
2562+
funcKeyword: .keyword(.func),
2563+
name: .identifier("name"),
2564+
signature: FunctionSignatureSyntax(
2565+
parameterClause: FunctionParameterClauseSyntax(
2566+
parameters: FunctionParameterListSyntax([])
2567+
),
2568+
returnClause: ReturnClauseSyntax(
2569+
type: IdentifierTypeSyntax(
2570+
name: .identifier("return type")
2571+
)
2572+
)
2573+
),
2574+
body: CodeBlockSyntax(
2575+
statements: CodeBlockItemListSyntax([
2576+
CodeBlockItemSyntax(
2577+
item: .expr(
2578+
ExprSyntax(
2579+
EditorPlaceholderExprSyntax(
2580+
placeholder: .identifier("function body")
2581+
)
2582+
)
2583+
)
2584+
)
2585+
])
2586+
)
2587+
),
2588+
diagnostics: [
2589+
DiagnosticSpec(locationMarker: "1️⃣", message: "editor placeholder in source file"),
2590+
DiagnosticSpec(locationMarker: "2️⃣", message: "editor placeholder in source file"),
2591+
DiagnosticSpec(locationMarker: "3️⃣", message: "editor placeholder in source file"),
2592+
DiagnosticSpec(locationMarker: "4️⃣", message: "editor placeholder in source file"),
2593+
]
2594+
)
2595+
}
25532596
}

0 commit comments

Comments
 (0)