Beispiel #1
0
  public final boolean canContinue() {
    Token token = getFirstToken();

    return (ElementUtils.isWhileWordToken(token)
        || ElementUtils.isUntilWordToken(token)
        || ElementUtils.isForeachWordToken(token));
  }
Beispiel #2
0
  /**
   * {@inheritDoc}
   *
   * <p>possible return types are:
   *
   * <ul>
   *   <li><code>CONTINUE</code>
   *   <li><code>IF</code>
   *   <li><code>FOR</code>
   *   <li><code>FOREACH</code>
   *   <li><code>LABEL</code>
   *   <li><code>UNKNOWN</code>
   *   <li><code>WHILE</code>
   * </ul>
   */
  @Override
  public final Type getType() {
    if (getSigChidrenCount() != 0) {
      int position = 0;
      Element element = getSigChild(position);

      // labeled statement
      if (element instanceof LabelToken) {

        if (getSigChidrenCount() == 1) {
          return Type.LABEL;
        }

        element = getSigChild(++position);
      }

      if (ElementUtils.isForWordToken(element) || ElementUtils.isForeachWordToken(element)) {
        return handleForOrForeach(position, element);
      }

      if (element instanceof WordToken) {
        return TYPES.get(element.getContent());
      }

      if (element instanceof BlockStructure) {
        return Type.CONTINUE;
      }
    }

    return Type.UNKNOWN;
  }