use of com.sun.tools.javac.code.Type.ArrayType in project error-prone by google.
the class ArraysAsListPrimitiveArray method matchMethodInvocation.
@Override
public Description matchMethodInvocation(MethodInvocationTree tree, VisitorState state) {
if (!ARRAYS_AS_LIST_SINGLE_ARRAY.matches(tree, state)) {
return NO_MATCH;
}
ExpressionTree array = Iterables.getOnlyElement(tree.getArguments());
Type componentType = ((ArrayType) ASTHelpers.getType(array)).getComponentType();
if (!componentType.isPrimitive()) {
return NO_MATCH;
}
String guavaUtils = GUAVA_UTILS.get(componentType.getKind());
if (guavaUtils == null) {
return NO_MATCH;
}
Fix fix = SuggestedFix.builder().addImport("com.google.common.primitives." + guavaUtils).replace(tree.getMethodSelect(), guavaUtils + ".asList").build();
return describeMatch(tree, fix);
}
use of com.sun.tools.javac.code.Type.ArrayType in project ceylon-compiler by ceylon.
the class JavacType method getComponentType.
@Override
public TypeMirror getComponentType() {
if (!componentTypeSet && type instanceof ArrayType) {
Type compType = ((ArrayType) type).getComponentType();
if (compType != null) {
componentType = new JavacType(compType);
}
componentTypeSet = true;
}
return componentType;
}
Aggregations