/** Build an instance of a Type. */ public Type getType(Type baseType, boolean isArray, List<Type> typeParams) { boolean isGeneric = typeParams != null && !typeParams.isEmpty(); if (!isArray && !isGeneric) { // Simple type. return baseType; } else if (isArray && !isGeneric) { // Array type, not generic. ClassSymbol arraySymbol = getSymtab().arrayClass; return new ArrayType(baseType, arraySymbol); } else if (!isArray && isGeneric) { // Generic type, not array. com.sun.tools.javac.util.List<Type> typeParamsCopy = com.sun.tools.javac.util.List.from(typeParams); return new ClassType(Type.noType, typeParamsCopy, baseType.tsym); } else { throw new IllegalArgumentException("Unsupported arguments to getType"); } }
@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); } }
Type.ArrayType tomodify = new Type.ArrayType(null, arType.tsym); Type toreturn; if (type.isAnnotated()) { toreturn = tomodify.annotatedType(type.getAnnotationMirrors()); } else { toreturn = tomodify; arType = (Type.ArrayType) aelemtype.unannotatedType(); ArrayType prevToMod = tomodify; tomodify = new Type.ArrayType(null, arType.tsym); prevToMod.elemtype = tomodify.annotatedType(arType.elemtype.getAnnotationMirrors()); } else { arType = (Type.ArrayType) arType.elemtype; tomodify.elemtype = new Type.ArrayType(null, arType.tsym); tomodify = (Type.ArrayType) tomodify.elemtype;
Type.ArrayType tomodify = new Type.ArrayType(null, arType.tsym); Type toreturn; if (type.isAnnotated()) { toreturn = tomodify.annotatedType(type.getAnnotationMirrors()); } else { toreturn = tomodify; arType = (Type.ArrayType) aelemtype.unannotatedType(); ArrayType prevToMod = tomodify; tomodify = new Type.ArrayType(null, arType.tsym); prevToMod.elemtype = tomodify.annotatedType(arType.elemtype.getAnnotationMirrors()); } else { arType = (Type.ArrayType) arType.elemtype; tomodify.elemtype = new Type.ArrayType(null, arType.tsym); tomodify = (Type.ArrayType) tomodify.elemtype;
return new ArrayType(lub(elements), syms.arrayClass);
case '[': sigp++; return new ArrayType(sigToType(), syms.arrayClass); case '(': sigp++;
Type componentType = ((Type.ArrayType)type).getComponentType(); if( componentType instanceof Type.ClassType ) return new Type.ArrayType( receiverType, _syms.arrayClass ); return new Type.ArrayType( replaceSelfTypesWithQualifier( receiverType, componentType, selfPos ), _syms.arrayClass );
while (tree.sym.members().lookup(valuesName).scope != null) // avoid name clash valuesName = names.fromString(valuesName + "" + target.syntheticNameChar()); Type arrayType = new ArrayType(types.erasure(tree.type), syms.arrayClass); VarSymbol valuesVar = new VarSymbol(PRIVATE|FINAL|STATIC|SYNTHETIC, valuesName,
} else if (enclTr.hasTag(TYPEARRAY)) { JCArrayTypeTree art = (JCArrayTypeTree) enclTr; validateAnnotatedType(art.getType(), ((ArrayType)enclTy.unannotatedType()).getComponentType()); repeat = false; } else if (enclTr.hasTag(TYPEUNION)) {
return new ArrayType(lub(elements), syms.arrayClass);
case '[': sigp++; return new ArrayType(sigToType(), syms.arrayClass); case '(': sigp++;
} else if (enclTr.hasTag(TYPEARRAY)) { JCArrayTypeTree art = (JCArrayTypeTree) enclTr; validateAnnotatedType(art.getType(), ((ArrayType)enclTy.unannotatedType()).getComponentType()); repeat = false; } else if (enclTr.hasTag(TYPEUNION)) {
return new ArrayType(lub(elements), syms.arrayClass);
case '[': sigp++; return new ArrayType(sigToType(), syms.arrayClass); case '(': sigp++;
} else if (type instanceof Type.ArrayType) { Type.ArrayType arrayType = (Type.ArrayType) type; Type componentType = arrayType.getComponentType(); if (nonNull(componentType) && nonNull(componentType.tsym)) { String s = arrayType.toString(); return Optional.of(s);
return new ArrayType(lub(elements), syms.arrayClass);
JCExpression valuesType = make.Type(new ArrayType(tree.sym.type, syms.arrayClass));
tree.vartype.type = atype.makeVarargs();
Type componentType = ((ArrayType) getType(targetType)).getComponentType(); Types types = state.getTypes(); Type charSequenceType = typeFromString("java.lang.CharSequence").get(state);
JCExpression valuesType = make.Type(new ArrayType(tree.sym.type, syms.arrayClass));