本文整理汇总了Java中com.sun.source.tree.EmptyStatementTree类的典型用法代码示例。如果您正苦于以下问题:Java EmptyStatementTree类的具体用法?Java EmptyStatementTree怎么用?Java EmptyStatementTree使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EmptyStatementTree类属于com.sun.source.tree包,在下文中一共展示了EmptyStatementTree类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitIf
import com.sun.source.tree.EmptyStatementTree; //导入依赖的package包/类
@Override
public Void visitIf(IfTree ifTree, List<ReformatOption> optionsToReformat) {
StatementTree thenStatement = ifTree.getThenStatement();
if (thenStatement instanceof BlockTree) {
addLeftBraceToList(optionsToReformat, ((BlockTree) thenStatement), PreferencesFormatOptions.BRACES_IN_OTHER_DECLARATION);
}
StatementTree elseStatement = ifTree.getElseStatement();
if (elseStatement instanceof EmptyStatementTree && thenStatement instanceof CompoundTree) {
addRightBraceToList(optionsToReformat, ((CompoundTree) thenStatement), PreferencesFormatOptions.AFTER_OTHER_DECLARATION);
} else if (elseStatement instanceof BlockTree) {
addLeftBraceToList(optionsToReformat, ((BlockTree) elseStatement), PreferencesFormatOptions.BRACES_IN_OTHER_DECLARATION);
}
return null;
}
示例2: visitEmptyStatement
import com.sun.source.tree.EmptyStatementTree; //导入依赖的package包/类
@Override
public Tree visitEmptyStatement(EmptyStatementTree tree, Void p) {
EmptyStatementTree n = make.EmptyStatement();
// model.setType(n, model.getType(tree));
comments.copyComments(tree, n);
model.setPos(n, model.getPos(tree));
return n;
}
示例3: visitEmptyStatement
import com.sun.source.tree.EmptyStatementTree; //导入依赖的package包/类
@Override
public Boolean visitEmptyStatement(EmptyStatementTree node, TreePath p) {
if (p == null) {
super.visitEmptyStatement(node, p);
return false;
}
return node.getKind() == p.getLeaf().getKind();
}
示例4: visitEmptyStatement
import com.sun.source.tree.EmptyStatementTree; //导入依赖的package包/类
@Override
public Void visitEmptyStatement(EmptyStatementTree tree, List<Node> d) {
List<Node> below = new ArrayList<Node>();
addCorrespondingType(below);
addCorrespondingComments(below);
super.visitEmptyStatement(tree, below);
d.add(new TreeNode(info, getCurrentPath(), below));
return null;
}
示例5: visitEmptyStatement
import com.sun.source.tree.EmptyStatementTree; //导入依赖的package包/类
@Override
public Void visitEmptyStatement(EmptyStatementTree tree, VisitorState visitorState) {
VisitorState state = visitorState.withPath(getCurrentPath());
for (EmptyStatementTreeMatcher matcher : emptyStatementMatchers) {
if (!isSuppressed(matcher, state)) {
try {
reportMatch(matcher.matchEmptyStatement(tree, state), tree, state);
} catch (Throwable t) {
handleError(matcher, t);
}
}
}
return super.visitEmptyStatement(tree, state);
}
示例6: matchEmptyStatement
import com.sun.source.tree.EmptyStatementTree; //导入依赖的package包/类
/**
* Match empty statement if: - Parent statement is an if - The then part of the parent if is an
* empty statement, and - The else part of the parent if does not exist
*/
@Override
public Description matchEmptyStatement(EmptyStatementTree tree, VisitorState state) {
boolean matches = false;
Tree parent = state.getPath().getParentPath().getLeaf();
if (parent.getKind() == IF) {
IfTree parentAsIf = (IfTree) parent;
matches =
(parentAsIf.getThenStatement() instanceof EmptyStatementTree)
&& (parentAsIf.getElseStatement() == null);
}
if (!matches) {
return Description.NO_MATCH;
}
/*
* We suggest different fixes depending on what follows the parent if statement.
* If there is no statement following the if, then suggest deleting the whole
* if statement. If the next statement is a block, then suggest deleting the
* empty then part of the if. If the next statement is not a block, then also
* suggest deleting the empty then part of the if.
*/
boolean nextStmtIsNull =
parentNode(nextStatement(Matchers.<StatementTree>isSame(null))).matches(tree, state);
assert (state.getPath().getParentPath().getLeaf().getKind() == IF);
IfTree ifParent = (IfTree) state.getPath().getParentPath().getLeaf();
if (nextStmtIsNull) {
// No following statements. Delete whole if.
return describeMatch(parent, SuggestedFix.delete(parent));
} else {
// There are more statements. Delete the empty then part of the if.
return describeMatch(
ifParent.getThenStatement(), SuggestedFix.delete(ifParent.getThenStatement()));
}
}
示例7: matchEmptyStatement
import com.sun.source.tree.EmptyStatementTree; //导入依赖的package包/类
/**
* Match empty statement if:
* - Parent statement is an if
* - The then part of the parent if is an empty statement, and
* - The else part of the parent if does not exist
*/
@Override
public Description matchEmptyStatement(EmptyStatementTree tree, VisitorState state) {
boolean matches = false;
Tree parent = state.getPath().getParentPath().getLeaf();
if (parent.getKind() == IF) {
IfTree parentAsIf = (IfTree)parent;
matches = (parentAsIf.getThenStatement() instanceof EmptyStatementTree) &&
(parentAsIf.getElseStatement() == null);
}
if (!matches) {
return Description.NO_MATCH;
}
/*
* We suggest different fixes depending on what follows the parent if statement.
* If there is no statement following the if, then suggest deleting the whole
* if statement. If the next statement is a block, then suggest deleting the
* empty then part of the if. If the next statement is not a block, then also
* suggest deleting the empty then part of the if.
*/
boolean nextStmtIsNull = parentNode(nextStatement(Matchers.<StatementTree>isSame(null)))
.matches(tree, state);
assert(state.getPath().getParentPath().getLeaf().getKind() == IF);
IfTree ifParent = (IfTree)state.getPath().getParentPath().getLeaf();
SuggestedFix fix = new SuggestedFix();
if (nextStmtIsNull) {
// No following statements. Delete whole if.
fix.delete(parent);
return describeMatch(parent, fix);
} else {
// There are more statements. Delete the empty then part of the if.
fix.delete(ifParent.getThenStatement());
return describeMatch(ifParent.getThenStatement(), fix);
}
}
示例8: visitEmptyStatement
import com.sun.source.tree.EmptyStatementTree; //导入依赖的package包/类
@Override
public Void visitEmptyStatement(EmptyStatementTree expected, Tree actual) {
if (!checkTypeAndCast(expected, actual).isPresent()) {
addTypeMismatch(expected, actual);
return null;
}
return null;
}
示例9: visitEmptyStatement
import com.sun.source.tree.EmptyStatementTree; //导入依赖的package包/类
public Boolean visitEmptyStatement(EmptyStatementTree node, ConstructorData p) {
super.visitEmptyStatement(node, p);
return null;
}
示例10: visitEmptyStatement
import com.sun.source.tree.EmptyStatementTree; //导入依赖的package包/类
@Override
public List<? extends TypeMirror> visitEmptyStatement(EmptyStatementTree node, Object p) {
return null;
}
示例11: visitEmptyStatement
import com.sun.source.tree.EmptyStatementTree; //导入依赖的package包/类
@Override
public Mirror visitEmptyStatement(EmptyStatementTree arg0, EvaluationContext evaluationContext) {
return null;
}
示例12: visitEmptyStatement
import com.sun.source.tree.EmptyStatementTree; //导入依赖的package包/类
@Override
public Void visitEmptyStatement(EmptyStatementTree node, Void unused) {
sync(node);
dropEmptyDeclarations();
return null;
}
示例13: visitEmptyStatement
import com.sun.source.tree.EmptyStatementTree; //导入依赖的package包/类
@Override
public R visitEmptyStatement(EmptyStatementTree est, P p) {
return null;
}
示例14: visitEmptyStatement
import com.sun.source.tree.EmptyStatementTree; //导入依赖的package包/类
@Override
public List<T> visitEmptyStatement(EmptyStatementTree node, T p) {
return checkForCriteria(node);
}
示例15: createEmptyStatement
import com.sun.source.tree.EmptyStatementTree; //导入依赖的package包/类
@Override
public EmptyStatementTree createEmptyStatement() {
return new EmptyStatementTreeImpl();
}