@@ -23,17 +23,7 @@ internal PropertyPattern(Context cx, PropertyPatternClauseSyntax pp, IExpression
23
23
}
24
24
}
25
25
26
- private class AccessStep
27
- {
28
- public readonly string Identifier ;
29
- public readonly Microsoft . CodeAnalysis . Location Location ;
30
-
31
- public AccessStep ( string identifier , Microsoft . CodeAnalysis . Location location )
32
- {
33
- Identifier = identifier ;
34
- Location = location ;
35
- }
36
- }
26
+ private record AccessStep ( string Identifier , Microsoft . CodeAnalysis . Location Location ) ;
37
27
38
28
private class AccessStepPack
39
29
{
@@ -47,37 +37,25 @@ public AccessStepPack Add(string identifier, Microsoft.CodeAnalysis.Location loc
47
37
return this ;
48
38
}
49
39
50
- public AccessStepPack ( string identifier , Microsoft . CodeAnalysis . Location location )
51
- {
40
+ public AccessStepPack ( string identifier , Microsoft . CodeAnalysis . Location location ) =>
52
41
Last = new AccessStep ( identifier , location ) ;
53
- }
54
42
}
55
43
56
- private static AccessStepPack GetAccessStepPack ( ExpressionSyntax syntax )
57
- {
58
- switch ( syntax )
44
+ private static AccessStepPack GetAccessStepPack ( ExpressionSyntax syntax ) =>
45
+ syntax switch
59
46
{
60
- case MemberAccessExpressionSyntax memberAccess :
61
- return GetAccessStepPack ( memberAccess . Expression ) . Add ( memberAccess . Name . Identifier . ValueText , memberAccess . Name . Identifier . GetLocation ( ) ) ;
62
- case IdentifierNameSyntax identifier :
63
- return new AccessStepPack ( identifier . Identifier . Text , identifier . GetLocation ( ) ) ;
64
- default :
65
- throw new InternalError ( syntax , "Unexpected expression syntax in property patterns." ) ;
66
- }
67
- }
47
+ MemberAccessExpressionSyntax memberAccess => GetAccessStepPack ( memberAccess . Expression ) . Add ( memberAccess . Name . Identifier . ValueText , memberAccess . Name . Identifier . GetLocation ( ) ) ,
48
+ IdentifierNameSyntax identifier => new AccessStepPack ( identifier . Identifier . Text , identifier . GetLocation ( ) ) ,
49
+ _ => throw new InternalError ( syntax , "Unexpected expression syntax in property patterns." ) ,
50
+ } ;
68
51
69
- private static AccessStepPack GetAccessStepPack ( BaseExpressionColonSyntax syntax )
70
- {
71
- switch ( syntax )
52
+ private static AccessStepPack GetAccessStepPack ( BaseExpressionColonSyntax syntax ) =>
53
+ syntax switch
72
54
{
73
- case NameColonSyntax ncs :
74
- return new AccessStepPack ( ncs . Name . ToString ( ) , ncs . Name . GetLocation ( ) ) ;
75
- case ExpressionColonSyntax ecs :
76
- return GetAccessStepPack ( ecs . Expression ) ;
77
- default :
78
- throw new InternalError ( syntax , "Unsupported expression colon in property pattern." ) ;
55
+ NameColonSyntax ncs => new AccessStepPack ( ncs . Name . ToString ( ) , ncs . Name . GetLocation ( ) ) ,
56
+ ExpressionColonSyntax ecs => GetAccessStepPack ( ecs . Expression ) ,
57
+ _ => throw new InternalError ( syntax , "Unsupported expression colon in property pattern." ) ,
79
58
} ;
80
- }
81
59
82
60
private static Expression CreateSyntheticExp ( Context cx , Microsoft . CodeAnalysis . Location location , IExpressionParentEntity parent , int child ) =>
83
61
new Expression ( new ExpressionInfo ( cx , null , cx . CreateLocation ( location ) , ExprKind . PROPERTY_PATTERN , parent , child , false , null ) ) ;
0 commit comments