File tree 2 files changed +31
-0
lines changed
2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,8 @@ public enum SyntaxClassification {
47
47
case stringLiteral
48
48
/// An identifier referring to a type.
49
49
case type
50
+ /// The label of a function parameter or a function call argument.
51
+ case parameterLabel
50
52
}
51
53
52
54
extension SyntaxClassification {
@@ -83,6 +85,10 @@ extension SyntaxClassification {
83
85
return ( . keyword, false )
84
86
case \SimpleTypeIdentifierSyntax . name:
85
87
return ( . type, false )
88
+ case \FunctionParameterSyntax . firstName:
89
+ return ( . parameterLabel, false )
90
+ case \LabeledExprSyntax . label:
91
+ return ( . parameterLabel, false )
86
92
default :
87
93
return nil
88
94
}
Original file line number Diff line number Diff line change @@ -577,4 +577,29 @@ public class ClassificationTests: XCTestCase {
577
577
]
578
578
)
579
579
}
580
+
581
+ public func testParameterLabel( ) {
582
+ assertClassification (
583
+ """
584
+ func foo(arg: Int) {}
585
+ """ ,
586
+ expected: [
587
+ ClassificationSpec ( source: " func " , kind: . keyword) ,
588
+ ClassificationSpec ( source: " foo " , kind: . identifier) ,
589
+ ClassificationSpec ( source: " arg " , kind: . parameterLabel) ,
590
+ ClassificationSpec ( source: " Int " , kind: . type) ,
591
+ ]
592
+ )
593
+
594
+ assertClassification (
595
+ """
596
+ foo(arg: 1)
597
+ """ ,
598
+ expected: [
599
+ ClassificationSpec ( source: " foo " , kind: . identifier) ,
600
+ ClassificationSpec ( source: " arg " , kind: . parameterLabel) ,
601
+ ClassificationSpec ( source: " 1 " , kind: . integerLiteral) ,
602
+ ]
603
+ )
604
+ }
580
605
}
You can’t perform that action at this time.
0 commit comments