All Downloads are FREE. Search and download functionalities are using the official Maven repository.

gw.lang.ir.statement.IRTryCatchFinallyStatement Maven / Gradle / Ivy

There is a newer version: 1.18.2
Show newest version
/*
 * Copyright 2014 Guidewire Software, Inc.
 */

package gw.lang.ir.statement;

import gw.lang.ir.IRStatement;
import gw.lang.UnstableAPI;

import java.util.List;

@UnstableAPI
public class IRTryCatchFinallyStatement extends IRStatement {
  private IRStatement _tryBody;
  private List _catchStatements;
  private IRStatement _finallyBody;

  public IRTryCatchFinallyStatement(IRStatement tryBody, List catchStatements, IRStatement finallyBody) {
    _tryBody = tryBody;
    _catchStatements = catchStatements;
    _finallyBody = finallyBody;

    tryBody.setParent( this );
    for (IRCatchClause catchClause : catchStatements) {
      catchClause.getBody().setParent( this );
    }
    if (finallyBody != null) {
      finallyBody.setParent( this );
    }
  }

  public IRStatement getTryBody() {
    return _tryBody;
  }

  public List getCatchStatements() {
    return _catchStatements;
  }

  public IRStatement getFinallyBody() {
    return _finallyBody;
  }

  @Override
  public IRTerminalStatement getLeastSignificantTerminalStatement()
  {

    IRTerminalStatement tryStmtTerminal = _tryBody.getLeastSignificantTerminalStatement();
    if( tryStmtTerminal != null )
    {
      if( _catchStatements.isEmpty())
      {
        return tryStmtTerminal;
      }
      IRTerminalStatement catchStmtTerminal = _catchStatements.get( _catchStatements.size() - 1 ).getBody().getLeastSignificantTerminalStatement();
      if( catchStmtTerminal != null )
      {
        return catchStmtTerminal;
      }
    }
    return null;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy