File tree Expand file tree Collapse file tree 5 files changed +153
-296
lines changed
Expand file tree Collapse file tree 5 files changed +153
-296
lines changed Original file line number Diff line number Diff line change @@ -50,5 +50,10 @@ module Impl {
5050 or
5151 result = this .getVariant ( ) .getStructField ( name )
5252 }
53+
54+ /** Gets the `i`th struct field of the instantiated struct or variant. */
55+ StructField getNthStructField ( int i ) {
56+ result = [ this .getStruct ( ) .getNthStructField ( i ) , this .getVariant ( ) .getNthStructField ( i ) ]
57+ }
5358 }
5459}
Original file line number Diff line number Diff line change @@ -35,6 +35,12 @@ module Impl {
3535 /** Gets a record field, if any. */
3636 StructField getAStructField ( ) { result = this .getStructField ( _) }
3737
38+ /** Gets the `i`th struct field, if any. */
39+ pragma [ nomagic]
40+ StructField getNthStructField ( int i ) {
41+ result = this .getFieldList ( ) .( StructFieldList ) .getField ( i )
42+ }
43+
3844 /** Gets the `i`th tuple field, if any. */
3945 pragma [ nomagic]
4046 TupleField getTupleField ( int i ) { result = this .getFieldList ( ) .( TupleFieldList ) .getField ( i ) }
Original file line number Diff line number Diff line change @@ -42,6 +42,13 @@ module Impl {
4242 )
4343 }
4444
45+ /** Gets the `i`th struct field of the instantiated struct or variant. */
46+ StructField getNthStructField ( int i ) {
47+ exists ( PathResolution:: ItemNode item | item = this .getResolvedPath ( _) |
48+ result = [ item .( Struct ) .getNthStructField ( i ) , item .( Variant ) .getNthStructField ( i ) ]
49+ )
50+ }
51+
4552 /** Gets the struct pattern for the field `name`. */
4653 pragma [ nomagic]
4754 StructPatField getPatField ( string name ) {
Original file line number Diff line number Diff line change @@ -32,6 +32,12 @@ module Impl {
3232 result .getName ( ) .getText ( ) = name
3333 }
3434
35+ /** Gets the `i`th struct field, if any. */
36+ pragma [ nomagic]
37+ StructField getNthStructField ( int i ) {
38+ result = this .getFieldList ( ) .( StructFieldList ) .getField ( i )
39+ }
40+
3541 /** Gets the `i`th tuple field, if any. */
3642 pragma [ nomagic]
3743 TupleField getTupleField ( int i ) { result = this .getFieldList ( ) .( TupleFieldList ) .getField ( i ) }
You can’t perform that action at this time.
0 commit comments