当前位置: 首页>>代码示例>>Java>>正文


Java IfStmt.getElseStmt方法代码示例

本文整理汇总了Java中com.github.javaparser.ast.stmt.IfStmt.getElseStmt方法的典型用法代码示例。如果您正苦于以下问题:Java IfStmt.getElseStmt方法的具体用法?Java IfStmt.getElseStmt怎么用?Java IfStmt.getElseStmt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.github.javaparser.ast.stmt.IfStmt的用法示例。


在下文中一共展示了IfStmt.getElseStmt方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visit

import com.github.javaparser.ast.stmt.IfStmt; //导入方法依赖的package包/类
@Override public Node visit(final IfStmt n, final A arg) {
	visitComment(n, arg);
	final Expression condition = (Expression)
		n.getCondition().accept(this, arg);
	if (condition == null) {
		return null;
	}
	n.setCondition(condition);
	final Statement thenStmt = (Statement) n.getThenStmt().accept(this, arg);
	if (thenStmt == null) {
		// Remove the entire statement if the then-clause was removed.
		// DumpVisitor, used for toString, has no null check for the
		// then-clause.
		return null;
	}
	n.setThenStmt(thenStmt);
	if (n.getElseStmt() != null) {
		n.setElseStmt((Statement) n.getElseStmt().accept(this, arg));
	}
	return n;
}
 
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:22,代码来源:ModifierVisitorAdapter.java

示例2: parseIfStatement

import com.github.javaparser.ast.stmt.IfStmt; //导入方法依赖的package包/类
/**
 *
 * @param is
 *      a github javaparser IfStatement
 * @param attributes
 *      the list of attributes of the class,
 *      to potentially get a type from the name
 * @param bd
 *      a body declaration
 * @return
 *      an IfStatement structure
 */
private IfStatement parseIfStatement(IfStmt is, List<Attribute> attributes, BodyDeclaration bd) {
    IfStatement ifSt = new IfStatement();
    List<Stmt> body = new ArrayList<>();
    ifSt.setCondition(parseExpression(is.getCondition(), attributes, bd.getBeginLine()));
    body.addAll(parseStatement(is.getThenStmt(), attributes, bd));
    if (is.getElseStmt() != null) {
        List<Stmt> elsStmts = new ArrayList<>();
        elsStmts.addAll(parseStatement(is.getElseStmt(), attributes, bd));
        ifSt.setElseStmt(elsStmts);
    }
    ifSt.setBody(body);
    ifSt.setLine(is.getBeginLine() - bd.getBeginLine());

    return ifSt;
}
 
开发者ID:DevMine,项目名称:parsers,代码行数:28,代码来源:Parser.java

示例3: visit

import com.github.javaparser.ast.stmt.IfStmt; //导入方法依赖的package包/类
@Override
public void visit(final IfStmt n, final Object arg) {
    printer.printLn("IfStmt");
    printJavaComment(n.getComment(), arg);
    printer.print("if (");
    n.getCondition().accept(this, arg);
    final boolean thenBlock = n.getThenStmt() instanceof BlockStmt;
    if (thenBlock) // block statement should start on the same line
    {
        printer.print(") ");
    } else {
        printer.printLn(")");
        printer.indent();
    }
    n.getThenStmt().accept(this, arg);
    if (!thenBlock) {
        printer.unindent();
    }
    if (n.getElseStmt() != null) {
        if (thenBlock) {
            printer.print(" ");
        } else {
            printer.printLn();
        }
        final boolean elseIf = n.getElseStmt() instanceof IfStmt;
        final boolean elseBlock = n.getElseStmt() instanceof BlockStmt;
        if (elseIf || elseBlock) // put chained if and start of block statement on a same level
        {
            printer.print("else ");
        } else {
            printer.printLn("else");
            printer.indent();
        }
        n.getElseStmt().accept(this, arg);
        if (!(elseIf || elseBlock)) {
            printer.unindent();
        }
    }
}
 
开发者ID:pcgomes,项目名称:javaparser2jctree,代码行数:40,代码来源:ASTDumpVisitor.java

示例4: visit

import com.github.javaparser.ast.stmt.IfStmt; //导入方法依赖的package包/类
@Override public void visit(final IfStmt n, final Object arg) {
printJavaComment(n.getComment(), arg);
printer.print("if (");
n.getCondition().accept(this, arg);
final boolean thenBlock = n.getThenStmt() instanceof BlockStmt;
if (thenBlock) // block statement should start on the same line
    printer.print(") ");
else {
    printer.printLn(")");
    printer.indent();
}
n.getThenStmt().accept(this, arg);
if (!thenBlock)
    printer.unindent();
if (n.getElseStmt() != null) {
    if (thenBlock)
	printer.print(" ");
    else
	printer.printLn();
    final boolean elseIf = n.getElseStmt() instanceof IfStmt;
    final boolean elseBlock = n.getElseStmt() instanceof BlockStmt;
    if (elseIf || elseBlock) // put chained if and start of block statement on a same level
	printer.print("else ");
    else {
	printer.printLn("else");
	printer.indent();
    }
    n.getElseStmt().accept(this, arg);
    if (!(elseIf || elseBlock))
	printer.unindent();
}
   }
 
开发者ID:plum-umd,项目名称:java-sketch,代码行数:33,代码来源:DumpVisitor.java

示例5: visit

import com.github.javaparser.ast.stmt.IfStmt; //导入方法依赖的package包/类
@Override public void visit(final IfStmt n, final A arg) {
	visitComment(n.getComment(), arg);
	n.getCondition().accept(this, arg);
	n.getThenStmt().accept(this, arg);
	if (n.getElseStmt() != null) {
		n.getElseStmt().accept(this, arg);
	}
}
 
开发者ID:plum-umd,项目名称:java-sketch,代码行数:9,代码来源:VoidVisitorAdapter.java

示例6: visit

import com.github.javaparser.ast.stmt.IfStmt; //导入方法依赖的package包/类
@Override public void visit(final IfStmt n, final A arg) {
    jw.write(n); 
    visitComment(n.getComment(), arg);
    n.getCondition().accept(this, arg);
    n.getThenStmt().accept(this, arg);
    if (n.getElseStmt() != null) {
        n.getElseStmt().accept(this, arg);
    }
}
 
开发者ID:plum-umd,项目名称:java-sketch,代码行数:10,代码来源:JsonVisitorAdapter.java

示例7: visit

import com.github.javaparser.ast.stmt.IfStmt; //导入方法依赖的package包/类
@Override public Node visit(final IfStmt n, final A arg) {
	n.setCondition((Expression) n.getCondition().accept(this, arg));
	n.setThenStmt((Statement) n.getThenStmt().accept(this, arg));
	if (n.getElseStmt() != null) {
		n.setElseStmt((Statement) n.getElseStmt().accept(this, arg));
	}
	return n;
}
 
开发者ID:plum-umd,项目名称:java-sketch,代码行数:9,代码来源:ModifierVisitorAdapter.java

示例8: visit

import com.github.javaparser.ast.stmt.IfStmt; //导入方法依赖的package包/类
@Override public void visit(final IfStmt n, final Object arg) {
	printJavaComment(n.getComment(), arg);
	printer.print("if (");
	n.getCondition().accept(this, arg);
	final boolean thenBlock = n.getThenStmt() instanceof BlockStmt;
	if (thenBlock) // block statement should start on the same line
		printer.print(") ");
	else {
		printer.printLn(")");
		printer.indent();
	}
	n.getThenStmt().accept(this, arg);
	if (!thenBlock)
		printer.unindent();
	if (n.getElseStmt() != null) {
		if (thenBlock)
			printer.print(" ");
		else
			printer.printLn();
		final boolean elseIf = n.getElseStmt() instanceof IfStmt;
		final boolean elseBlock = n.getElseStmt() instanceof BlockStmt;
		if (elseIf || elseBlock) // put chained if and start of block statement on a same level
			printer.print("else ");
		else {
			printer.printLn("else");
			printer.indent();
		}
		n.getElseStmt().accept(this, arg);
		if (!(elseIf || elseBlock))
			printer.unindent();
	}
}
 
开发者ID:javaparser,项目名称:javasymbolsolver,代码行数:33,代码来源:DumpVisitor.java


注:本文中的com.github.javaparser.ast.stmt.IfStmt.getElseStmt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。