@@ -64,17 +64,27 @@ class Pattern extends Generated::Pattern {
64
64
}
65
65
66
66
/** Holds if this pattern is matched against an expression. */
67
- predicate hasMatchingExpr ( ) { exists ( this .getMatchingExpr ( ) ) }
67
+ final predicate hasMatchingExpr ( ) { exists ( this .getMatchingExpr ( ) ) }
68
68
69
69
/**
70
- * Holds if this occurs as a sub- pattern of the result .
70
+ * Gets the parent pattern of this pattern, if any .
71
71
*/
72
- Pattern getEnclosingPattern ( ) {
72
+ final Pattern getEnclosingPattern ( ) {
73
73
result = this .getFullyUnresolved ( ) .( Pattern ) .getImmediateEnclosingPattern ( )
74
74
}
75
75
76
76
/**
77
- * Holds if this occurs as an immediate sub-pattern of the result.
77
+ * Gets the parent pattern of this pattern, but only if
78
+ * both patterns match against the same object, which is not
79
+ * the case when destructuring a complex data structure,
80
+ * like a tuple or enum.
81
+ */
82
+ final Pattern getIdentityPreservingEnclosingPattern ( ) {
83
+ result = this .getFullyUnresolved ( ) .( Pattern ) .getImmediateIdentityPreservingEnclosingPattern ( )
84
+ }
85
+
86
+ /**
87
+ * Gets the parent pattern of this pattern, if any.
78
88
*/
79
89
Pattern getImmediateEnclosingPattern ( ) {
80
90
this = result .( EnumElementPattern ) .getImmediateSubPattern ( )
@@ -87,9 +97,10 @@ class Pattern extends Generated::Pattern {
87
97
}
88
98
89
99
/**
90
- * Holds if this occurs as an immediate sub-pattern of the result
91
- * without any intervening destructurings of
92
- * complex data structures.
100
+ * Gets the immediate parent pattern of this pattern, but only if
101
+ * both patterns match against the same object, which is not
102
+ * the case when destructuring a complex data structure,
103
+ * like a tuple or enum.
93
104
*/
94
105
Pattern getImmediateIdentityPreservingEnclosingPattern ( ) {
95
106
this = result .( BindingPattern ) .getImmediateSubPattern ( )
0 commit comments