本文整理汇总了Java中net.sourceforge.pmd.lang.java.ast.ASTPrimaryPrefix类的典型用法代码示例。如果您正苦于以下问题:Java ASTPrimaryPrefix类的具体用法?Java ASTPrimaryPrefix怎么用?Java ASTPrimaryPrefix使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ASTPrimaryPrefix类属于net.sourceforge.pmd.lang.java.ast包,在下文中一共展示了ASTPrimaryPrefix类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isPlainJunitAssert
import net.sourceforge.pmd.lang.java.ast.ASTPrimaryPrefix; //导入依赖的package包/类
/**
* Tells if the statement is an assert statement or not.
* @param statement Root node to search assert statements
* @return True is statement is assert, false otherwise
*/
private static boolean isPlainJunitAssert(final Node statement) {
final ASTPrimaryExpression expression =
ProhibitPlainJunitAssertionsRule.getChildNodeWithType(
statement, ASTPrimaryExpression.class
);
final ASTPrimaryPrefix prefix =
ProhibitPlainJunitAssertionsRule.getChildNodeWithType(
expression, ASTPrimaryPrefix.class
);
final ASTName name = ProhibitPlainJunitAssertionsRule
.getChildNodeWithType(prefix, ASTName.class);
boolean assrt = false;
if (name != null) {
final String img = name.getImage();
assrt = img != null && (img.startsWith("assert")
|| img.startsWith("Assert.assert"));
}
return assrt;
}
示例2: visit
import net.sourceforge.pmd.lang.java.ast.ASTPrimaryPrefix; //导入依赖的package包/类
@Override
public Object visit(ASTName node, Object data) {
if (node.jjtGetParent() instanceof ASTPrimaryPrefix) {
String image = node.getImage();
if (image != null && image.endsWith(".getComponentFactory")) {
addViolationWithMessage(data, node, "Only UIMap related classes are allowed to access a GUI Component Factory");
}
}
return super.visit(node, data);
}