本文整理汇总了Java中com.sun.source.tree.LambdaExpressionTree.BodyKind.STATEMENT属性的典型用法代码示例。如果您正苦于以下问题:Java BodyKind.STATEMENT属性的具体用法?Java BodyKind.STATEMENT怎么用?Java BodyKind.STATEMENT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类com.sun.source.tree.LambdaExpressionTree.BodyKind
的用法示例。
在下文中一共展示了BodyKind.STATEMENT属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitLambda
@Override
public void visitLambda(JCLambda tree) {
print(cs.spaceWithinLambdaParens() && tree.params.nonEmpty() ? "( " : "(");
boolean oldPrintingMethodParams = printingMethodParams;
printingMethodParams = true;
suppressVariableType = tree.paramKind == JCLambda.ParameterKind.IMPLICIT;
wrapTrees(tree.params, cs.wrapLambdaParams(), cs.alignMultilineLambdaParams()
? out.col : out.leftMargin + cs.getContinuationIndentSize(),
true);
suppressVariableType = false;
printingMethodParams = oldPrintingMethodParams;
if (cs.spaceWithinLambdaParens() && tree.params.nonEmpty())
needSpace();
print(')');
print(cs.spaceAroundLambdaArrow() ? " ->" : "->");
if (tree.getBodyKind() == BodyKind.STATEMENT) {
printBlock(tree.body, cs.getOtherBracePlacement(), cs.spaceAroundLambdaArrow());
} else {
int rm = cs.getRightMargin();
switch(cs.wrapBinaryOps()) {
case WRAP_IF_LONG:
if (widthEstimator.estimateWidth(tree.body, rm - out.col) + out.col <= cs.getRightMargin()) {
if(cs.spaceAroundLambdaArrow())
print(' ');
break;
}
case WRAP_ALWAYS:
newline();
toColExactly(out.leftMargin + cs.getContinuationIndentSize());
break;
case WRAP_NEVER:
if(cs.spaceAroundLambdaArrow())
print(' ');
break;
}
printExpr(tree.body, TreeInfo.notExpression);
}
}
示例2: visitLambda
@Override
public void visitLambda(JCLambda tree) {
if (tree.getBodyKind() == BodyKind.STATEMENT) {
JCExpression ident = make.at(tree).QualIdent(symtab.assertionErrorType.tsym);
JCThrow throwTree = make.Throw(make.NewClass(null, List.nil(), ident, List.nil(), null));
tree.body = make.Block(0, List.of(throwTree));
}
}
示例3: getBodyKind
@Override
public BodyKind getBodyKind() {
return body.hasTag(BLOCK) ?
BodyKind.STATEMENT :
BodyKind.EXPRESSION;
}