Skip to content

Commit

Permalink
Done with getType -- create arbitrary Types for matchers
Browse files Browse the repository at this point in the history
  • Loading branch information
Eddie Aftandilian committed Sep 7, 2012
1 parent f56063d commit 82ee5e6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
9 changes: 5 additions & 4 deletions core/src/main/java/com/google/errorprone/VisitorState.java
Expand Up @@ -154,6 +154,11 @@ public Name getName(String nameStr) {
* Given the string representation of a simple (non-array, non-generic) type, return the
* matching Type.
*
* <p>If this method returns null, the compiler has not seen this type yet, which means that if
* you are comparing other types to this for equality or the subtype relation, your result would
* always be false even if it could create the type. Thus it might be best to bail out early in
* your matcher if this method returns null on your type of interest.
*
* @param typeStr The canonical string representation of a simple type (e.g., "java.lang.Object")
* @return The Type that corresponds to the string, or null if it cannot be found
*/
Expand Down Expand Up @@ -258,8 +263,4 @@ private static boolean isPrimitiveType(String typeStr) {
private interface NameLookupStrategy {
Name fromString(Context context, String nameStr);
}

public class TypeBuilder {

}
}
Expand Up @@ -33,8 +33,6 @@
import static com.google.errorprone.matchers.Matchers.*;

/**
* TODO(eaftan): tests -- more positive cases, start negative cases
*
* @author eaftan@google.com (Eddie Aftandilian)
*/
@BugPattern(name = "ArrayEquals",
Expand Down Expand Up @@ -75,11 +73,11 @@ public Description describe(MethodInvocationTree t, VisitorState state) {
}

public static class Scanner extends com.google.errorprone.Scanner {
public DescribingMatcher<MethodInvocationTree> matcher = new ArrayEquals();
public DescribingMatcher<MethodInvocationTree> scannerMatcher = new ArrayEquals();

@Override
public Void visitMethodInvocation(MethodInvocationTree node, VisitorState visitorState) {
evaluateMatch(node, visitorState, matcher);
evaluateMatch(node, visitorState, scannerMatcher);
return super.visitMethodInvocation(node, visitorState);
}
}
Expand Down

0 comments on commit 82ee5e6

Please sign in to comment.