@@ -187,9 +187,37 @@ final class RecordExprCfgNode extends Nodes::RecordExprCfgNode {
187187
188188 RecordExprCfgNode ( ) { node = this .getRecordExpr ( ) }
189189
190- /** Gets the `i`th record expression. */
191- ExprCfgNode getExpr ( int i ) {
192- any ( ChildMapping mapping )
193- .hasCfgChild ( node , node .getRecordExprFieldList ( ) .getField ( i ) .getExpr ( ) , this , result )
190+ /** Gets the record expression for the field `field`. */
191+ pragma [ nomagic]
192+ ExprCfgNode getFieldExpr ( string field ) {
193+ exists ( RecordExprField ref |
194+ ref = node .getRecordExprFieldList ( ) .getAField ( ) and
195+ any ( ChildMapping mapping ) .hasCfgChild ( node , ref .getExpr ( ) , this , result ) and
196+ field = ref .getNameRef ( ) .getText ( )
197+ )
198+ }
199+ }
200+
201+ /**
202+ * A record pattern. For example:
203+ * ```rust
204+ * match x {
205+ * Foo { a: 1, b: 2 } => "ok",
206+ * Foo { .. } => "fail",
207+ * }
208+ * ```
209+ */
210+ final class RecordPatCfgNode extends Nodes:: RecordPatCfgNode {
211+ private RecordPatChildMapping node ;
212+
213+ RecordPatCfgNode ( ) { node = this .getRecordPat ( ) }
214+
215+ /** Gets the record pattern for the field `field`. */
216+ PatCfgNode getFieldPat ( string field ) {
217+ exists ( RecordPatField rpf |
218+ rpf = node .getRecordPatFieldList ( ) .getAField ( ) and
219+ any ( ChildMapping mapping ) .hasCfgChild ( node , rpf .getPat ( ) , this , result ) and
220+ field = rpf .getNameRef ( ) .getText ( )
221+ )
194222 }
195223}
0 commit comments