Optional<PsiClass> resolveFieldConfigType(PsiField psiField) { PsiType fieldType = psiField.getType(); if (fieldType instanceof PsiClassType) { PsiClassType fieldClassType = ((PsiClassType) fieldType); if (collectionType != null && collectionType.isAssignableFrom(fieldType) && fieldClassType.getParameterCount() == 1) { return toPsiClass(fieldClassType.getParameters()[0]); } else if (mapType != null && mapType.isAssignableFrom(fieldType) && fieldClassType.getParameterCount() == 2) { return toPsiClass(fieldClassType.getParameters()[1]); } else { return toPsiClass(fieldType); } } else if (fieldType instanceof PsiArrayType) { return toPsiClass(((PsiArrayType) fieldType).getComponentType()); } else { return Optional.empty(); } }
public static PsiType maybeInferParamType( TypeVarToTypeMap inferenceMap, PsiType ownersType, PsiType fromParamType, PsiType toParamType ) { int iCount = inferenceMap.size(); PsiType toCompType = toParamType; while( toCompType instanceof PsiArrayType ) { toCompType = ((PsiArrayType)toCompType).getComponentType(); } if( isTypeVariable( toCompType ) || isParameterizedType( toCompType ) ) { inferTypeVariableTypesFromGenParamTypeAndConcreteType_Reverse( toParamType, fromParamType, inferenceMap ); if( inferenceMap.size() > iCount ) { PsiType actualType = getActualType( toParamType, inferenceMap, false ); toParamType = actualType == null ? toParamType : actualType; } } return replaceTypeVariableTypeParametersWithBoundingTypes( toParamType, ownersType ); }
public static PsiType maybeInferReturnType( TypeVarToTypeMap inferenceMap, PsiType ownersType, PsiType fromReturnType, PsiType toReturnType ) { int iCount = inferenceMap.size(); PsiType toCompType = toReturnType; while( toCompType instanceof PsiArrayType ) { toCompType = ((PsiArrayType)toCompType).getComponentType(); } boolean bTypeVar = isTypeVariable( toCompType ); if( bTypeVar || isParameterizedType( toCompType ) ) { inferTypeVariableTypesFromGenParamTypeAndConcreteType( toReturnType, fromReturnType, inferenceMap ); if( bTypeVar && inferenceMap.get( (PsiClassType)toCompType ) != null || inferenceMap.size() > iCount ) { PsiType actualType = getActualType( toReturnType, inferenceMap, false ); toReturnType = actualType == null ? toReturnType : actualType; } } return replaceTypeVariableTypeParametersWithBoundingTypes( toReturnType, ownersType ); }
public static PsiType getDefaultParameterizedType( PsiType type, PsiManager mgr ) { if( type.getArrayDimensions() > 0 ) { PsiType defType = getDefaultParameterizedType( ((PsiArrayType)type).getComponentType(), mgr ); if( !defType.equals( type ) ) { return new PsiArrayType( defType ); } return type; } if( type instanceof PsiIntersectionType ) { return makeDefaultParameterizedTypeForCompoundType( (PsiIntersectionType)type, mgr ); } if( type instanceof PsiDisjunctionType ) { return getDefaultParameterizedType( PsiTypesUtil.getLowestUpperBoundClassType( (PsiDisjunctionType)type ), mgr ); } if( !isGenericType( type ) && !isParameterizedType( type ) ) { return type; } type = ((PsiClassType)type).rawType(); return makeDefaultParameterizedType( type ); }
@Override public LookupElement[] calculateLookupItems(@NotNull Expression[] params, ExpressionContext context) { if (params.length != 1) return null; LookupElement[] lookupItems = params[0].calculateLookupItems(context); if (lookupItems == null) return null; List<LookupElement> result = ContainerUtil.newArrayList(); for (LookupElement element : lookupItems) { PsiTypeLookupItem lookupItem = element.as(PsiTypeLookupItem.CLASS_CONDITION_KEY); if (lookupItem != null) { PsiType psiType = lookupItem.getType(); if (psiType instanceof PsiArrayType) { result.add(PsiTypeLookupItem.createLookupItem(((PsiArrayType)psiType).getComponentType(), null)); } } } return lookupItems; }
@Override public void visitField(@NotNull PsiField field) { super.visitField(field); if (!field.hasModifierProperty(PsiModifier.PUBLIC)) { return; } if (!field.hasModifierProperty(PsiModifier.STATIC)) { return; } final PsiType type = field.getType(); if (!(type instanceof PsiArrayType)) { return; } if (CollectionUtils.isConstantEmptyArray(field)) { return; } registerFieldError(field); }
@NotNull @Override public List<PsiType[]> inferExpectedSignatures(@NotNull PsiMethod method, @NotNull PsiSubstitutor substitutor, @NotNull String[] options) { List<PsiType[]> signatures = new SecondParamHintProcessor().inferExpectedSignatures(method, substitutor, options); if (signatures.size() == 1) { PsiType[] signature = signatures.get(0); if (signature.length == 1) { PsiType type = signature[0]; if (type instanceof PsiArrayType) { return produceResult(((PsiArrayType)type).getComponentType()); } } } return Collections.emptyList(); }
@NotNull @Override public List<PsiType[]> inferExpectedSignatures(@NotNull PsiMethod method, @NotNull PsiSubstitutor substitutor, @NotNull String[] options) { List<PsiType[]> signatures = new ThirdParamHintProcessor().inferExpectedSignatures(method, substitutor, options); if (signatures.size() == 1) { PsiType[] signature = signatures.get(0); if (signature.length == 1) { PsiType type = signature[0]; if (type instanceof PsiArrayType) { return produceResult(((PsiArrayType)type).getComponentType()); } } } return Collections.emptyList(); }
@NotNull @Override public List<PsiType[]> inferExpectedSignatures(@NotNull PsiMethod method, @NotNull PsiSubstitutor substitutor, @NotNull String[] options) { List<PsiType[]> signatures = new FirstParamHintProcessor().inferExpectedSignatures(method, substitutor, options); if (signatures.size() == 1) { PsiType[] signature = signatures.get(0); if (signature.length == 1) { PsiType type = signature[0]; if (type instanceof PsiArrayType) { return produceResult(((PsiArrayType)type).getComponentType()); } } } return Collections.emptyList(); }
/** * Returns false if <code>type</code> is a multiple levels of collections or arrays. Returns true * otherwise. * * @param type The PsiType been validated. * @param project The project that has the PsiElement associated with <code>type</code>. */ public boolean isValidArrayOrPrimitiveType(PsiType type, Project project) { if (type instanceof PsiArrayType) { PsiArrayType arrayType = (PsiArrayType) type; if (arrayType.getComponentType() instanceof PsiPrimitiveType) { return true; } else { return isValidInnerArrayType(arrayType.getComponentType(), project); } } // Check if type is a Collection PsiClassType collectionType = JavaPsiFacade.getElementFactory(project).createTypeByFQClassName("java.util.Collection"); if (collectionType.isAssignableFrom(type)) { assert (type instanceof PsiClassType); PsiClassType classType = (PsiClassType) type; PsiType[] typeParams = classType.getParameters(); assert (typeParams.length > 0); return isValidInnerArrayType(typeParams[0], project); } return true; }
@Override public LookupElement[] calculateLookupItems(@NotNull Expression[] params, ExpressionContext context) { if (params.length != 1) return null; LookupElement[] lookupItems = params[0].calculateLookupItems(context); if (lookupItems == null) return null; List<LookupElement> result = ContainerUtil.newArrayList(); for (LookupElement element : lookupItems) { PsiTypeLookupItem lookupItem = element.as(PsiTypeLookupItem.CLASS_CONDITION_KEY); if (lookupItem != null) { PsiType psiType = lookupItem.getPsiType(); if (psiType instanceof PsiArrayType) { result.add(PsiTypeLookupItem.createLookupItem(((PsiArrayType)psiType).getComponentType(), null)); } } } return lookupItems; }
@NotNull @Override @SuppressWarnings("unchecked") public <Psi extends PsiElement> List<Psi> getAugments(@NotNull PsiElement element, @NotNull Class<Psi> type) { if(type == PsiMethod.class && element instanceof PsiClass && element.getUserData(FLAG) == Boolean.TRUE && ((PsiClass) element).isEnum()) { List<Psi> list = new ArrayList<Psi>(2); LightMethodBuilder valuesMethod = new LightMethodBuilder(element.getManager(), JavaLanguage.INSTANCE, VALUES_METHOD_NAME); valuesMethod.setContainingClass((PsiClass) element); valuesMethod.setMethodReturnType(new PsiArrayType(new PsiImmediateClassType((PsiClass)element, PsiSubstitutor.EMPTY))); valuesMethod.addModifiers(PsiModifier.PUBLIC, PsiModifier.STATIC); list.add((Psi) valuesMethod); LightMethodBuilder valueOfMethod = new LightMethodBuilder(element.getManager(), JavaLanguage.INSTANCE, VALUE_OF_METHOD_NAME); valueOfMethod.setContainingClass((PsiClass) element); valueOfMethod.setMethodReturnType(new PsiImmediateClassType((PsiClass) element, PsiSubstitutor.EMPTY)); valueOfMethod.addModifiers(PsiModifier.PUBLIC, PsiModifier.STATIC); valueOfMethod.addParameter("name", JavaClassNames.JAVA_LANG_STRING); valueOfMethod.addException(JavaClassNames.JAVA_LANG_ILLEGAL_ARGUMENT_EXCEPTION); list.add((Psi) valueOfMethod); return list; } return Collections.emptyList(); }
@Nullable private static String getTypeShortName(@NotNull final PsiType type) { if(type instanceof PsiPrimitiveType) { return ((PsiPrimitiveType) type).getBoxedTypeName(); } if(type instanceof PsiClassType) { return ((PsiClassType) type).getClassName(); } if(type instanceof PsiArrayType) { return getTypeShortName(((PsiArrayType) type).getComponentType()) + "[]"; } return null; }
@Override public String getTooltip(MemberInfo memberInfo) { if(isMemberEnabled(memberInfo)) { return null; } if(!(memberInfo.getMember() instanceof PsiField)) { return CodeInsightBundle.message("generate.equals.hashcode.internal.error"); } final PsiField field = (PsiField) memberInfo.getMember(); final PsiType type = field.getType(); if(!(type instanceof PsiArrayType) || JavaVersionService.getInstance().isAtLeast(field, JavaSdkVersion.JDK_1_5)) { return null; } return CodeInsightBundle.message("generate.equals.hashcode.warning.hashcode.for.arrays.is.not.supported"); }
public PsiTypePattern arrayOf(final ElementPattern pattern) { return with(new PatternCondition<PsiType>("arrayOf") { public boolean accepts(@NotNull final PsiType psiType, final ProcessingContext context) { return psiType instanceof PsiArrayType && pattern.accepts(((PsiArrayType)psiType).getComponentType(), context); } }); }
@NotNull public static TargetClassFilter createClassFilter(@Nullable PsiType psiType) { if(psiType == null || psiType instanceof PsiArrayType) { return TargetClassFilter.ALL; } PsiClass psiClass = PsiUtil.resolveClassInType(psiType); if (psiClass != null) { return createClassFilter(psiClass); } return new FQNameClassFilter(psiType.getCanonicalText()); }
@Nullable public static TargetType create(final PsiArrayType arrayType) { PsiType currentComponentType = arrayType.getComponentType(); while (currentComponentType instanceof PsiArrayType) { currentComponentType = ((PsiArrayType)currentComponentType).getComponentType(); } if (!(currentComponentType instanceof PsiClassType)) { return null; } final String targetQName = arrayType.getCanonicalText(); return new TargetType(targetQName, true, arrayType); }
@Nullable @Override public Boolean isConvertible(@NotNull PsiType lType, @NotNull PsiType rType, @NotNull GroovyPsiElement context) { if (lType instanceof PsiArrayType) { PsiType lComponentType = ((PsiArrayType)lType).getComponentType(); PsiType rComponentType = ClosureParameterEnhancer.findTypeForIteration(rType, context); if (rComponentType != null && TypesUtil.isAssignable(lComponentType, rComponentType, context)) { return Boolean.TRUE; } } return null; }
/** * Returns false is <code>type</code> is an array or a java.util.Collection or one of its * subtypes. Returns true otherwise. * * @param type The PsiType been validated. * @param project The project that has the PsiElement associated with <code>type</code>. */ public boolean isValidInnerArrayType(PsiType type, Project project) { if (type instanceof PsiArrayType) { return false; } // Check if type is a Collection PsiClassType collectionType = JavaPsiFacade.getElementFactory(project).createTypeByFQClassName("java.util.Collection"); if (collectionType.isAssignableFrom(type)) { return false; } return true; }
@Nullable @Override public TypeBuilder visitArrayType(PsiArrayType arrayType) { boxed = false; // don't need to (or want to) box array types arrayType.getComponentType().accept(this); typeBuilder.withArrayDimensions(arrayType.getArrayDimensions()); return super.visitArrayType(arrayType); }
public static TargetClassFilter createClassFilter(PsiType psiType) { if(psiType instanceof PsiArrayType) { return TargetClassFilter.ALL; } PsiClass psiClass = PsiUtil.resolveClassInType(psiType); if (psiClass != null) { return createClassFilter(psiClass); } return new FQNameClassFilter(psiType.getCanonicalText()); }
public PsiTypePattern arrayOf(final ElementPattern pattern) { return with(new PatternCondition<PsiType>("arrayOf") { public boolean accepts(@NotNull final PsiType psiType, final ProcessingContext context) { return psiType instanceof PsiArrayType && pattern.getCondition().accepts(((PsiArrayType)psiType).getComponentType(), context); } }); }
private List<FieldExpression> suggestVariantsForCollectionMembers(PsiType nextExtensionBaseType, int depth, String nexpr) { List<FieldExpression> result = new LinkedList<FieldExpression>(); PsiClass nextExtensionBase = PsiUtil.resolveClassInType(nextExtensionBaseType); if (nextExtensionBase != null) { result.addAll(suggestVariants(nextExtensionBase, nexpr, depth - 1)); final String nexprComp = nexpr + "[0]"; if (nextExtensionBaseType instanceof PsiArrayType) { result.add(new FieldExpression(fieldDefinition, nexprComp)); PsiType compType = ((PsiArrayType) nextExtensionBaseType).getComponentType(); PsiClass compClass = PsiUtil.resolveClassInType(compType); if (compClass != null) { result.addAll(suggestVariants(compClass, nexprComp, depth - 1)); } } else if (isOfTypeList(nextExtensionBase)) { PsiClassType listClassType = (PsiClassType) nextExtensionBaseType; if (listClassType.hasParameters()) { PsiClassType.ClassResolveResult resolveResult = listClassType.resolveGenerics(); PsiType paramType = resolveResult.getSubstitutor().substitute(listClassType.getParameters()[0]); if (paramType instanceof PsiClassType) { PsiClass paramClass = PsiUtil.resolveClassInType(paramType); result.addAll(suggestVariants(paramClass, nexprComp, depth - 1)); } } result.add(new FieldExpression(fieldDefinition, nexprComp)); } } return result; }
public static boolean isUncheckedConversion(final PsiType t, final PsiType s) { if(t instanceof PsiClassType && !((PsiClassType) t).isRaw() && s instanceof PsiClassType) { final PsiClassType.ClassResolveResult tResult = ((PsiClassType) t).resolveGenerics(); final PsiClassType.ClassResolveResult sResult = ((PsiClassType) s).resolveGenerics(); final PsiClass tClass = tResult.getElement(); final PsiClass sClass = sResult.getElement(); if(tClass != null && sClass != null && !(sClass instanceof InferenceVariable)) { final PsiSubstitutor sSubstitutor = TypeConversionUtil.getClassSubstitutor(tClass, sClass, sResult.getSubstitutor()); if(sSubstitutor != null) { if(PsiUtil.isRawSubstitutor(tClass, sSubstitutor)) { return true; } } else if(tClass instanceof InferenceVariable && ((PsiClassType) s).isRaw() && tClass.isInheritor(sClass, true)) { return true; } } } else if(t instanceof PsiArrayType && t.getArrayDimensions() == s.getArrayDimensions()) { return isUncheckedConversion(t.getDeepComponentType(), s.getDeepComponentType()); } return false; }
@Nullable @Override protected PsiExpression getModifiedArgument(final PsiExpression expression, final PsiType toType) throws IncorrectOperationException { final PsiType exprType = expression.getType(); if(!(exprType instanceof PsiArrayType && toType instanceof PsiClassType)) { return null; } final PsiClass resolvedToType = ((PsiClassType) toType).resolve(); if(resolvedToType == null) { return null; } final PsiClass javaUtilList = getJavaUtilList(expression); if(javaUtilList == null || !InheritanceUtil.isInheritorOrSelf(javaUtilList, resolvedToType, true)) { return null; } final PsiType[] parameters = ((PsiClassType) toType).getParameters(); final PsiType arrayComponentType = ((PsiArrayType) exprType).getComponentType(); if(!(parameters.length == 1 && parameters[0].equals(arrayComponentType))) { return null; } final String rawNewExpression = String.format("java.util.Arrays.asList(%s)", expression.getText()); final Project project = expression.getProject(); final PsiExpression newExpression = JavaPsiFacade.getInstance(project).getElementFactory() .createExpressionFromText(rawNewExpression, null); return (PsiExpression) JavaCodeStyleManager.getInstance(project).shortenClassReferences(newExpression); }
public ConvertCollectionToArrayFix(@NotNull PsiExpression collectionExpression, @NotNull PsiArrayType arrayType) { myCollectionExpression = collectionExpression; PsiType componentType = arrayType.getComponentType(); myNewArrayText = componentType.equalsToText(CommonClassNames.JAVA_LANG_OBJECT) ? "" : "new " + getArrayTypeText(componentType); }
@NotNull private static String getArrayTypeText(PsiType componentType) { if(componentType instanceof PsiArrayType) { return getArrayTypeText(((PsiArrayType) componentType).getComponentType()) + "[]"; } if(componentType instanceof PsiClassType) { return ((PsiClassType) componentType).rawType().getCanonicalText() + "[0]"; } return componentType.getCanonicalText() + "[0]"; }
@Override public LookupElement[] calculateLookupItems(@NotNull Expression[] params, ExpressionContext context) { if(params.length != 1) { return null; } LookupElement[] lookupItems = params[0].calculateLookupItems(context); if(lookupItems == null) { return null; } List<LookupElement> result = ContainerUtil.newArrayList(); for(LookupElement element : lookupItems) { PsiTypeLookupItem lookupItem = element.as(PsiTypeLookupItem.CLASS_CONDITION_KEY); if(lookupItem != null) { PsiType psiType = lookupItem.getType(); if(psiType instanceof PsiArrayType) { result.add(PsiTypeLookupItem.createLookupItem(((PsiArrayType) psiType).getComponentType(), null)); } } } return lookupItems; }
@Nullable public static String convertToString(final PsiType psiType) { if (psiType instanceof PsiArrayType) { return '[' + toStringArray(((PsiArrayType)psiType).getComponentType()); } else if (psiType instanceof PsiClassType) { return psiType.getCanonicalText(); } return null; }
@NonNls @Nullable private static String toStringArray(final PsiType psiType) { if (psiType instanceof PsiArrayType) { return '[' + toStringArray(((PsiArrayType)psiType).getComponentType()); } else if (psiType instanceof PsiPrimitiveType) { return String.valueOf(ourPrimitiveTypes.get(psiType)); } else if (psiType instanceof PsiClassType) { return "L" + psiType.getCanonicalText() + ";"; } return null; }
@NotNull public static TargetClassFilter createClassFilter(@Nullable PsiType psiType) { if(psiType == null || psiType instanceof PsiArrayType) { return TargetClassFilter.ALL; } PsiClass psiClass = PsiUtil.resolveClassInType(psiType); if(psiClass != null) { return createClassFilter(psiClass); } return new FQNameClassFilter(psiType.getCanonicalText()); }
public static PsiType replaceTypeVariableTypeParametersWithBoundingTypes( PsiType type, PsiType enclType ) { if( isTypeVariable( type ) ) { PsiClass boundingType = getBoundingType( (PsiTypeParameter)((PsiClassType)type).resolve() ); if( isRecursiveType( (PsiClassType)type, type( boundingType ) ) ) { // short-circuit recursive typevar return ((PsiClassType)type( boundingType )).rawType(); } if( enclType != null && isParameterizedType( enclType ) ) { TypeVarToTypeMap map = mapTypeByVarName( enclType, enclType ); return replaceTypeVariableTypeParametersWithBoundingTypes( getActualType( type( boundingType ), map, true ) ); } return replaceTypeVariableTypeParametersWithBoundingTypes( type( boundingType ), enclType ); } if( type.getArrayDimensions() > 0 ) { return new PsiArrayType( replaceTypeVariableTypeParametersWithBoundingTypes( ((PsiArrayType)type).getComponentType(), enclType ) ); } if( type instanceof PsiIntersectionType ) { PsiType[] types = ((PsiIntersectionType)type).getConjuncts(); Set<PsiType> newTypes = new HashSet<>(); for( PsiType t : types ) { newTypes.add( replaceTypeVariableTypeParametersWithBoundingTypes( t ) ); } if( newTypes.size() == 1 ) { return newTypes.iterator().next(); } return PsiIntersectionType.createIntersection( new ArrayList<>( newTypes ) ); } if( isParameterizedType( type ) ) { PsiType[] typeParams = ((PsiClassType)type).getParameters(); PsiType[] concreteParams = new PsiType[typeParams.length]; for( int i = 0; i < typeParams.length; i++ ) { concreteParams[i] = replaceTypeVariableTypeParametersWithBoundingTypes( typeParams[i], enclType ); } type = parameterizeType( (PsiClassType)type, concreteParams ); } else if( type instanceof PsiClassType ) { PsiClass psiClass = ((PsiClassType)type).resolve(); PsiTypeParameter[] typeVars = psiClass.getTypeParameters(); PsiType[] boundingTypes = new PsiType[typeVars.length]; for( int i = 0; i < boundingTypes.length; i++ ) { boundingTypes[i] = type( getBoundingType( typeVars[i] ) ); if( isRecursiveType( (PsiClassType)type( typeVars[i] ), boundingTypes[i] ) ) { return type; } } for( int i = 0; i < boundingTypes.length; i++ ) { boundingTypes[i] = replaceTypeVariableTypeParametersWithBoundingTypes( boundingTypes[i], enclType ); } type = parameterizeType( (PsiClassType)type, boundingTypes ); } else if( type instanceof PsiWildcardType ) { replaceTypeVariableTypeParametersWithBoundingTypes( ((PsiWildcardType)type).getExtendsBound() ); } return type; }
private static boolean _isRecursiveType( PsiType declaringClass, Set<PsiClassType> visited ) { if( isTypeVariable( declaringClass ) ) { if( visited.contains( declaringClass ) ) { return true; } visited.add( (PsiClassType)declaringClass ); try { return _isRecursiveType( getBoundingType( declaringClass ), visited ); } finally { visited.remove( declaringClass ); } } if( declaringClass.getArrayDimensions() > 0 ) { return _isRecursiveType( ((PsiArrayType)declaringClass).getComponentType(), visited ); } if( !isGenericType( declaringClass ) && !isParameterizedType( declaringClass ) ) { return false; } if( isGenericType( declaringClass ) && !isParameterizedType( declaringClass ) ) { PsiTypeParameter[] typeVars = ((PsiClassType)declaringClass).rawType().resolve().getTypeParameters(); for( PsiTypeParameter gtv : typeVars ) { if( _isRecursiveType( type( gtv ), visited ) ) { return true; } } } else if( isParameterizedType( declaringClass ) ) { for( PsiType typeParam : ((PsiClassType)declaringClass).getParameters() ) { if( _isRecursiveType( typeParam, visited ) ) { return true; } } } return false; }
private static boolean _isRecursiveType( PsiClassType subject, Set<PsiClassType> visited, PsiType... types ) { visited.add( subject ); for( PsiType csr : types ) { if( !(csr instanceof PsiClassType) ) { continue; } for( PsiClassType subj : visited ) { if( ((PsiClassType)csr).rawType().equals( subj.rawType() ) ) { // Short-circuit recursive type parameterization e.g., class Foo<T extends Foo<T>> return true; } } if( isParameterizedType( csr ) ) { if( _isRecursiveType( subject, visited, ((PsiClassType)csr).getParameters() ) ) { return true; } } else if( isGenericType( csr ) ) { PsiTypeParameter[] typeVars = ((PsiClassType)csr).rawType().resolve().getTypeParameters(); for( PsiTypeParameter gtv : typeVars ) { if( _isRecursiveType( subject, visited, type( gtv ) ) ) { return true; } } } else if( isTypeVariable( csr ) ) { if( !visited.contains( csr ) && _isRecursiveType( (PsiClassType)csr, visited, getBoundingType( csr ) ) ) { return true; } visited.remove( csr ); if( _isRecursiveType( subject, visited, getBoundingType( csr ) ) ) { return true; } } else if( csr.getArrayDimensions() > 0 ) { if( _isRecursiveType( subject, visited, ((PsiArrayType)csr).getComponentType() ) ) { return true; } } } return false; }
@Nullable private static PsiType extractComponentType(PsiType type) { if (type instanceof PsiArrayType) return ((PsiArrayType)type).getComponentType(); return PsiUtil.substituteTypeParameter(type, CommonClassNames.JAVA_UTIL_COLLECTION, 0, false); }
private static boolean isCollectionOrArray(PsiType type) { return type instanceof PsiArrayType || InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_UTIL_COLLECTION); }
@Override public boolean isVarargs() { GrParameter last = ArrayUtil.getLastElement(myBlock.getAllParameters()); return last != null && last.getType() instanceof PsiArrayType; }