@@ -1125,6 +1125,28 @@ class UsingStmt extends Stmt, @using_stmt {
11251125 /** Gets a local variable declaration of this `using` statement. */
11261126 LocalVariableDeclExpr getAVariableDeclExpr ( ) { result = this .getVariableDeclExpr ( _) }
11271127
1128+ /**
1129+ * Gets an expression that is used in this `using` statement. Either an
1130+ * expression assigned to a variable, for example `File.Open("settings.xml")`
1131+ * in
1132+ *
1133+ * ```
1134+ * using (FileStream f = File.Open("settings.xml")) {
1135+ * ...
1136+ * }
1137+ * ```
1138+ *
1139+ * or an expression directly used, for example `File.Open("settings.xml")`
1140+ * in
1141+ *
1142+ * ```
1143+ * using (File.Open("settings.xml")) {
1144+ * ...
1145+ * }
1146+ * ```
1147+ */
1148+ Expr getAnExpr ( ) { none ( ) }
1149+
11281150 /**
11291151 * DEPRECATED: Use UsingBlockStmt.getExpr() instead.
11301152 * Gets the expression directly used by this `using` statement, if any. For
@@ -1178,27 +1200,7 @@ class UsingBlockStmt extends UsingStmt, @using_block_stmt {
11781200 */
11791201 override Expr getExpr ( ) { result = this .getChild ( 0 ) }
11801202
1181- /**
1182- * Gets an expression that is used in this `using` statement. Either an
1183- * expression assigned to a variable, for example `File.Open("settings.xml")`
1184- * in
1185- *
1186- * ```
1187- * using (FileStream f = File.Open("settings.xml")) {
1188- * ...
1189- * }
1190- * ```
1191- *
1192- * or an expression directly used, for example `File.Open("settings.xml")`
1193- * in
1194- *
1195- * ```
1196- * using (File.Open("settings.xml")) {
1197- * ...
1198- * }
1199- * ```
1200- */
1201- Expr getAnExpr ( ) {
1203+ override Expr getAnExpr ( ) {
12021204 result = this .getAVariableDeclExpr ( ) .getInitializer ( )
12031205 or
12041206 result = this .getExpr ( )
@@ -1300,6 +1302,10 @@ class UsingDeclStmt extends LocalVariableDeclStmt, UsingStmt, @using_decl_stmt {
13001302 override LocalConstantDeclExpr getVariableDeclExpr ( int n ) {
13011303 result = LocalVariableDeclStmt .super .getVariableDeclExpr ( n )
13021304 }
1305+
1306+ override Expr getAnExpr ( ) {
1307+ result = this .getAVariableDeclExpr ( ) .getInitializer ( )
1308+ }
13031309}
13041310
13051311/**
0 commit comments