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

io.codemodder.ast.TryResourceDeclaration Maven / Gradle / Ivy

There is a newer version: 0.97.9
Show newest version
package io.codemodder.ast;

import com.github.javaparser.ast.Node;
import com.github.javaparser.ast.body.VariableDeclarator;
import com.github.javaparser.ast.expr.VariableDeclarationExpr;
import com.github.javaparser.ast.stmt.TryStmt;
import java.util.Objects;

/**
 * Holds the nodes in the AST that represents a variable declaration as a try resource. See Java Language
 * Specification - Section 14.20.3 for more details.
 */
public final class TryResourceDeclaration extends LocalVariableDeclaration {

  private final TryStmt stmt;

  public TryResourceDeclaration(
      final TryStmt stmt, final VariableDeclarationExpr vde, final VariableDeclarator vd) {
    this.stmt = Objects.requireNonNull(stmt);
    this.vde = Objects.requireNonNull(vde);
    this.vd = Objects.requireNonNull(vd);
    this.scope = null;
  }

  /** Returns the {@link TryStmt} {@link Node} that holds the resource declaration. */
  @Override
  public TryStmt getStatement() {
    return stmt;
  }

  @Override
  protected LocalScope findScope() {
    return LocalScope.fromTryResource(stmt, vd);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy