本文整理汇总了Java中org.sonar.plugins.java.api.tree.Tree.is方法的典型用法代码示例。如果您正苦于以下问题:Java Tree.is方法的具体用法?Java Tree.is怎么用?Java Tree.is使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.sonar.plugins.java.api.tree.Tree
的用法示例。
在下文中一共展示了Tree.is方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildGraph
import org.sonar.plugins.java.api.tree.Tree; //导入方法依赖的package包/类
private void buildGraph(Tree tree) {
String label = tree.kind() + (tree.firstToken() != null ? (" L#" + tree.firstToken().line()) : "");
addNode(new ASTDotNode(index, label, tree.kind()));
if (tree.is(Tree.Kind.TOKEN)) {
// add an extra node for tokens
addNode(new ASTDotNode(index, escapeSpecialChars(((SyntaxToken) tree).text())));
}
int currentNodeIndex = index;
if (!((JavaTree) tree).isLeaf()) {
for (Tree child : ((JavaTree) tree).getChildren()) {
index++;
int childIndex = index;
buildGraph(child);
addEdge(new ASTDotEdge(currentNodeIndex, childIndex));
}
}
}
示例2: addChildren
import org.sonar.plugins.java.api.tree.Tree; //导入方法依赖的package包/类
private static void addChildren(Stream.Builder<String> sb, Tree tree) {
if (tree.is(Tree.Kind.INFERED_TYPE)) {
// do nothing, infered types does not have children
return;
}
addTrees(sb, ((JavaTree) tree).getChildren());
}
示例3: getMethodBehavior
import org.sonar.plugins.java.api.tree.Tree; //导入方法依赖的package包/类
@CheckForNull
private static MethodBehavior getMethodBehavior(BehaviorCache bc, @Nullable Tree syntaxTree) {
if (syntaxTree == null || !syntaxTree.is(Tree.Kind.METHOD_INVOCATION)) {
return null;
}
Symbol symbol = ((MethodInvocationTree) syntaxTree).symbol();
if (!symbol.isMethodSymbol()) {
return null;
}
return bc.get((Symbol.MethodSymbol) symbol);
}
示例4: checkMember
import org.sonar.plugins.java.api.tree.Tree; //导入方法依赖的package包/类
private void checkMember(Tree member) {
boolean isVariableField = member.is(Kind.VARIABLE);
if (isVariableField) {
VariableTree variableField = (VariableTree) member;
String name = variableField.type().symbolType().fullyQualifiedName();
if (nonThreadSafeTypes.contains(name)) {
context.reportIssue(this, member, String.format(RULE_MESSAGE, name));
}
}
}
示例5: checkIfMapVariableIsModified
import org.sonar.plugins.java.api.tree.Tree; //导入方法依赖的package包/类
private void checkIfMapVariableIsModified(List<IdentifierTree> usagesOfMVM) {
for (IdentifierTree modifiableValueMapUsageIdentifier : usagesOfMVM) {
Tree usageOfMVM = modifiableValueMapUsageIdentifier.parent();
if (usageOfMVM != null) {
if (usageOfMVM.is(Tree.Kind.ARGUMENTS)) {
visitMethodWithMVM(modifiableValueMapUsageIdentifier, usageOfMVM);
} else if (usageOfMVM.is(Tree.Kind.MEMBER_SELECT) && isSomeoneCallingMutableMethodsOnMap((MemberSelectExpressionTree) usageOfMVM)) {
isModified = true;
break;
}
}
}
}