public static void main(String[] args) {
try {
App app = new App();
Leitor leitor = new Leitor("App", "C:\\programa-java\\MetodoLiu\\src\\main\\java\\weiEtal\\App.java");
List<com.github.javaparser.ast.stmt.Statement> linhas = leitor.linhasMetodo("metodo1");
for (com.github.javaparser.ast.stmt.Statement statement : linhas) {
if(statement instanceof IfStmt) {
System.out.println(statement);
IfStmt ifStmt = (IfStmt) statement;
if(ifStmt.hasElseBlock()) {
System.out.println("Bloco else: " + ifStmt.getElseStmt().get());
System.out.println(ifStmt.getElseStmt().get().isThrowStmt());
System.out.println(ifStmt.getElseStmt().get() instanceof ThrowStmt);
List<?> nosElse = ifStmt.getElseStmt().get().getChildNodes();
//pegando lin por lin dentro do else.
for (Object object : nosElse) {
System.out.println(object instanceof ThrowStmt);
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
Comentários
Postar um comentário