private ImmutableMultimap<String, MethodInvocationTree> methodCallsForSymbol( Symbol sym, ClassTree classTree) { ImmutableMultimap.Builder<String, MethodInvocationTree> methodMap = ImmutableMultimap.builder(); classTree.accept( new TreeScanner<Void, Void>() { @Override public Void visitMethodInvocation(MethodInvocationTree callTree, Void unused) { final MethodSymbol methodSymbol = getSymbol(callTree); if (methodSymbol != null && sym.equals(methodSymbol)) { methodMap.put(methodSymbol.toString(), callTree); } return super.visitMethodInvocation(callTree, unused); } }, null); return methodMap.build(); }
/** * Finds all method invocations on the given symbol, and constructs a map of the called method's * name, to the {@link MethodInvocationTree} in which it was called. */ private ImmutableMultimap<String, MethodInvocationTree> methodCallsForSymbol( Symbol sym, ClassTree classTree) { Builder<String, MethodInvocationTree> methodMap = ImmutableMultimap.builder(); // Populate map builder with names of method called : the tree in which it is called. classTree.accept( new TreeScanner<Void, Void>() { @Override public Void visitMethodInvocation(MethodInvocationTree callTree, Void unused) { if (sym.equals(getSymbol(getReceiver(callTree)))) { MethodSymbol methodSymbol = getSymbol(callTree); if (methodSymbol != null) { methodMap.put(methodSymbol.getSimpleName().toString(), callTree); } } return super.visitMethodInvocation(callTree, unused); } }, null); return methodMap.build(); } }
private VariableTree findEnclosingIdentifier(IdentifierTree originalNode, VisitorState state) { Symbol identifierSymbol = getSymbol(originalNode); if (!(identifierSymbol instanceof VarSymbol)) { return null; } return state .findEnclosing(ClassTree.class) .accept( new TreeScanner<VariableTree, Void>() { @Override public VariableTree visitVariable(VariableTree node, Void p) { return getSymbol(node).equals(identifierSymbol) ? node : null; } @Override public VariableTree reduce(VariableTree r1, VariableTree r2) { return r1 != null ? r1 : r2; } }, null); } }
/** Whether the given method is called elsewhere in the enclosing class. */ private static boolean calledElsewhere(MethodTree methodTree, VisitorState state) { MethodSymbol methodSymbol = getSymbol(methodTree); if (methodSymbol == null) { return false; } return state .findEnclosing(ClassTree.class) .accept( new TreeScanner<Boolean, Void>() { @Override public Boolean visitMethodInvocation(MethodInvocationTree callTree, Void unused) { if (methodSymbol.equals(getSymbol(callTree.getMethodSelect()))) { return true; } return super.visitMethodInvocation(callTree, unused); } @Override public Boolean reduce(Boolean r1, Boolean r2) { r1 = (r1 == null) ? false : r1; r2 = (r2 == null) ? false : r2; return r1 || r2; } }, null); }
private boolean verify(ClassTree ct, Element topElement) { currentClass = ct; CompilationUnitTree cut = getCompilationUnit(); String className = ct.getSimpleName().toString(); ExpressionTree pkgName = cut.getPackageName(); if (pkgName != null) { className = pkgName + "." + className; } classNames.add(className); if (hasTrustedAnnotation(ct, topElement)) { return true; } Boolean value = ct.accept(new VerifierVisitor(this, topElement), null); return value == null? true : value; }
private SuggestedFix fixAsserts(ClassTree tree, VisitorState state) { SuggestedFix.Builder fix = SuggestedFix.builder(); tree.accept( new TreeScanner<Void, Void>() { @Override
private ImmutableMultimap<String, MethodInvocationTree> methodCallsForSymbol( Symbol sym, ClassTree classTree) { ImmutableMultimap.Builder<String, MethodInvocationTree> methodMap = ImmutableMultimap.builder(); classTree.accept( new TreeScanner<Void, Void>() { @Override public Void visitMethodInvocation(MethodInvocationTree callTree, Void unused) { final MethodSymbol methodSymbol = getSymbol(callTree); if (methodSymbol != null && sym.equals(methodSymbol)) { methodMap.put(methodSymbol.toString(), callTree); } return super.visitMethodInvocation(callTree, unused); } }, null); return methodMap.build(); }
/** * Finds all method invocations on the given symbol, and constructs a map of the called method's * name, to the {@link MethodInvocationTree} in which it was called. */ private ImmutableMultimap<String, MethodInvocationTree> methodCallsForSymbol( Symbol sym, ClassTree classTree) { Builder<String, MethodInvocationTree> methodMap = ImmutableMultimap.builder(); // Populate map builder with names of method called : the tree in which it is called. classTree.accept( new TreeScanner<Void, Void>() { @Override public Void visitMethodInvocation(MethodInvocationTree callTree, Void unused) { if (sym.equals(getSymbol(getReceiver(callTree)))) { MethodSymbol methodSymbol = getSymbol(callTree); if (methodSymbol != null) { methodMap.put(methodSymbol.getSimpleName().toString(), callTree); } } return super.visitMethodInvocation(callTree, unused); } }, null); return methodMap.build(); } }
private boolean verify(ClassTree ct, Element topElement) { currentClass = ct; CompilationUnitTree cut = getCompilationUnit(); String className = ct.getSimpleName().toString(); ExpressionTree pkgName = cut.getPackageName(); if (pkgName != null) { className = pkgName + "." + className; } classNames.add(className); Boolean value = unsafe? Boolean.TRUE : ct.accept(new VerifierVisitor(this, topElement), null); return value == null? true : value.booleanValue(); }
private boolean verify(ClassTree ct, Element topElement) { currentClass = ct; CompilationUnitTree cut = getCompilationUnit(); String className = ct.getSimpleName().toString(); ExpressionTree pkgName = cut.getPackageName(); if (pkgName != null) { className = pkgName + "." + className; } classNames.add(className); Boolean value = unsafe? Boolean.TRUE : ct.accept(new VerifierVisitor(this, topElement), null); return value == null? true : value.booleanValue(); }
private VariableTree findEnclosingIdentifier(IdentifierTree originalNode, VisitorState state) { Symbol identifierSymbol = getSymbol(originalNode); if (!(identifierSymbol instanceof VarSymbol)) { return null; } return state .findEnclosing(ClassTree.class) .accept( new TreeScanner<VariableTree, Void>() { @Override public VariableTree visitVariable(VariableTree node, Void p) { return getSymbol(node).equals(identifierSymbol) ? node : null; } @Override public VariableTree reduce(VariableTree r1, VariableTree r2) { return r1 != null ? r1 : r2; } }, null); } }
/** Whether the given method is called elsewhere in the enclosing class. */ private static boolean calledElsewhere(MethodTree methodTree, VisitorState state) { MethodSymbol methodSymbol = getSymbol(methodTree); if (methodSymbol == null) { return false; } return state .findEnclosing(ClassTree.class) .accept( new TreeScanner<Boolean, Void>() { @Override public Boolean visitMethodInvocation(MethodInvocationTree callTree, Void unused) { if (methodSymbol.equals(getSymbol(callTree.getMethodSelect()))) { return true; } return super.visitMethodInvocation(callTree, unused); } @Override public Boolean reduce(Boolean r1, Boolean r2) { r1 = (r1 == null) ? false : r1; r2 = (r2 == null) ? false : r2; return r1 || r2; } }, null); }
private SuggestedFix fixAsserts(ClassTree tree, VisitorState state) { SuggestedFix.Builder fix = SuggestedFix.builder(); tree.accept( new TreeScanner<Void, Void>() { @Override