@@ -185,8 +185,12 @@ signature module AstSig<LocationSig Location> {
185185
186186 /** A `try` statement with `catch` and/or `finally` clauses. */
187187 class TryStmt extends Stmt {
188- /** Gets the body of this `try` statement. */
189- Stmt getBody ( ) ;
188+ /**
189+ * Gets the body of this `try` statement at the specified (zero-based)
190+ * position `index`. In some languages, there is only ever a single body
191+ * (with `index` 0).
192+ */
193+ Stmt getBody ( int index ) ;
190194
191195 /**
192196 * Gets the `catch` clause at the specified (zero-based) position `index`
@@ -198,15 +202,6 @@ signature module AstSig<LocationSig Location> {
198202 Stmt getFinally ( ) ;
199203 }
200204
201- /**
202- * Gets the initializer of this `try` statement at the specified (zero-based)
203- * position `index`, if any.
204- *
205- * An example of this are resource declarations in Java's try-with-resources
206- * statement.
207- */
208- default AstNode getTryInit ( TryStmt try , int index ) { none ( ) }
209-
210205 /**
211206 * Gets the `else` block of this `try` statement, if any.
212207 *
@@ -699,7 +694,7 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
699694 or
700695 exists ( TryStmt trystmt |
701696 trystmt = n and
702- cannotTerminateNormally ( trystmt .getBody ( ) ) and
697+ cannotTerminateNormally ( trystmt .getBody ( _ ) ) and
703698 forall ( CatchClause catch | trystmt .getCatch ( _) = catch |
704699 cannotTerminateNormally ( catch .getBody ( ) )
705700 )
@@ -1256,11 +1251,7 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
12561251 )
12571252 )
12581253 or
1259- exists ( TryStmt trystmt |
1260- ast = getTryInit ( trystmt , _)
1261- or
1262- ast = trystmt .getBody ( )
1263- |
1254+ exists ( TryStmt trystmt | ast = trystmt .getBody ( _) |
12641255 c .getSuccessorType ( ) instanceof ExceptionSuccessor and
12651256 (
12661257 n .isBefore ( trystmt .getCatch ( 0 ) )
@@ -1635,16 +1626,11 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
16351626 or
16361627 exists ( TryStmt trystmt |
16371628 n1 .isBefore ( trystmt ) and
1638- (
1639- n2 .isBefore ( getTryInit ( trystmt , 0 ) )
1640- or
1641- not exists ( getTryInit ( trystmt , _) ) and n2 .isBefore ( trystmt .getBody ( ) )
1642- )
1629+ n2 .isBefore ( trystmt .getBody ( 0 ) )
16431630 or
1644- exists ( int i | n1 .isAfter ( getTryInit ( trystmt , i ) ) |
1645- n2 .isBefore ( getTryInit ( trystmt , i + 1 ) )
1646- or
1647- not exists ( getTryInit ( trystmt , i + 1 ) ) and n2 .isBefore ( trystmt .getBody ( ) )
1631+ exists ( int i |
1632+ n1 .isAfter ( trystmt .getBody ( i ) ) and
1633+ n2 .isBefore ( trystmt .getBody ( i + 1 ) )
16481634 )
16491635 or
16501636 exists ( PreControlFlowNode beforeElse , PreControlFlowNode beforeFinally |
@@ -1659,8 +1645,11 @@ module Make0<LocationSig Location, AstSig<Location> Ast> {
16591645 not exists ( trystmt .getFinally ( ) ) and beforeFinally .isAfter ( trystmt )
16601646 )
16611647 |
1662- n1 .isAfter ( trystmt .getBody ( ) ) and
1663- n2 = beforeElse
1648+ exists ( int i |
1649+ n1 .isAfter ( trystmt .getBody ( i ) ) and
1650+ not exists ( trystmt .getBody ( i + 1 ) ) and
1651+ n2 = beforeElse
1652+ )
16641653 or
16651654 n1 .isAfter ( getTryElse ( trystmt ) ) and
16661655 n2 = beforeFinally
0 commit comments