@DataProvider public static Object[][] tooComplexProvider() { return testForEach( new TestCase().withTypeMock(mock(PsiClassType.class)) .withQualifiedNameOf(String.class).thenExpectTheResult().toBeTooGeneric(), new TestCase().withTypeMock(mock(PsiClassType.class)) .withQualifiedNameOf(Integer.class).thenExpectTheResult().toBeTooGeneric(), new TestCase().withTypeMock(mock(PsiClassType.class)) .withQualifiedNameOf(List.class).thenExpectTheResult().toBeTooGeneric(), new TestCase().withTypeMock(mock(PsiClassType.class)) .withQualifiedNameOf(Stream.class).thenExpectTheResult().toBeTooGeneric(), new TestCase().withTypeMock(mock(PsiClassType.class)) .withQualifiedNameOf(BufferedReader.class).thenExpectTheResult().toBeTooGeneric(), new TestCase().withTypeMock(mock(PsiType.class)) .withQualifiedName("some_qualified_name").thenExpectTheResult().toBeTooGeneric(), new TestCase().withTypeMock(mock(PsiClassType.class)) .withQualifiedName(null).thenExpectTheResult().toBeTooGeneric(), new TestCase().withTypeMock(mock(PsiClassType.class)) .withQualifiedName("myClass").thenExpectTheResult().toBeNotTooGeneric() ); }
@Override public Stream<LookupElementBuilder> resolveCompletions(String propertyName, PsiType psiType) { PsiType[] parameters = ((PsiClassReferenceType) psiType).getParameters(); Stream<PsiClass> psiClassStream = null; if (parameters.length == 1 && parameters[0] instanceof PsiWildcardType) { PsiWildcardType psiWildcardType = ((PsiWildcardType) parameters[0]); if (psiWildcardType.isBounded()) { if (psiWildcardType.isExtends()) { psiClassStream = subClasses((PsiClassType) psiWildcardType.getExtendsBound()).stream(); } else if (psiWildcardType.isSuper()) { psiClassStream = superClasses((PsiClassType) psiWildcardType.getSuperBound()).stream(); } } } if (psiClassStream != null) { return psiClassStream.map(this::buildClassLookup).filter(Optional::isPresent).map(Optional::get); } else { return Stream.empty(); } }
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(); } }
private SrcType makeSrcType( PsiType type ) { SrcType srcType; if( type instanceof PsiClassType ) { srcType = new SrcType( ((PsiClassType)type).rawType().getCanonicalText() ); for( PsiType typeParam : ((PsiClassType)type).getParameters() ) { srcType.addTypeParam( makeSrcType( typeParam ) ); } } else { srcType = new SrcType( type.getCanonicalText() ); } return srcType; }
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 makeDefaultParameterizedType( PsiType type ) { if( type != null && !isStructuralInterface( type ) && !isParameterizedType( type ) && isGenericType( type ) ) { PsiTypeParameter[] typeVars = type( type ).getTypeParameters(); PsiType[] boundingTypes = new PsiType[typeVars.length]; for( int i = 0; i < boundingTypes.length; i++ ) { PsiTypeParameter typeVar = typeVars[i]; boundingTypes[i] = type( getBoundingType( typeVar ) ); if( isRecursiveType( (PsiClassType)type( typeVar ), boundingTypes[i] ) ) { return type; } } if( boundingTypes.length == 0 ) { return type; } type = parameterizeType( (PsiClassType)type, boundingTypes ); } return type; }
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 ); }
private static PsiType maybeGetLowerBound( PsiWildcardType type, TypeVarToTypeMap actualParamByVarName, boolean bKeepTypeVars, LinkedHashSet<PsiType> recursiveTypes ) { PsiType lower = type.getSuperBound(); if( lower != PsiType.NULL && recursiveTypes.size() > 0 ) { // This is a "super" (contravariant) wildcard LinkedList<PsiType> list = new LinkedList<>( recursiveTypes ); PsiType enclType = list.getLast(); if( isParameterizedType( enclType ) ) { PsiType genType = getActualType( ((PsiClassType)enclType).rawType(), actualParamByVarName, bKeepTypeVars, recursiveTypes ); if( LambdaUtil.isFunctionalType( genType ) ) { // For functional interfaces we keep the lower bound as an upper bound so that blocks maintain contravariance wrt the single method's parameters return lower; } } } return null; }
private static TypeVarToTypeMap mapActualTypeByVarName( PsiType ownersType ) { TypeVarToTypeMap actualParamByVarName = new TypeVarToTypeMap(); PsiTypeParameter[] vars = type( ownersType ).getTypeParameters(); if( vars != null ) { PsiType[] paramArgs = ((PsiClassType)ownersType).getParameters(); for( int i = 0; i < vars.length; i++ ) { PsiClassType typeVar = (PsiClassType)type( vars[i] ); if( paramArgs.length > i ) { actualParamByVarName.put( typeVar, paramArgs[i] ); } } } return actualParamByVarName; }
public JavaCallHierarchyData(PsiClass originalClass, PsiMethod methodToFind, PsiClassType originalType, PsiMethod method, Set<PsiMethod> methodsToFind, NodeDescriptor nodeDescriptor, Map<PsiMember, NodeDescriptor> resultMap, Project project) { myOriginalClass = originalClass; myMethodToFind = methodToFind; myOriginalType = originalType; myMethod = method; myMethodsToFind = methodsToFind; myNodeDescriptor = nodeDescriptor; myResultMap = resultMap; myProject = project; }
@Nullable public static TargetType create(final PsiClassType classType) { final PsiClassType.ClassResolveResult resolvedGenerics = classType.resolveGenerics(); final PsiClass resolvedClass = resolvedGenerics.getElement(); if (resolvedClass == null) { return null; } final String classQName = resolvedClass.getQualifiedName(); if (classQName == null) { return null; } if (resolvedClass.hasTypeParameters()) { return null; } return new TargetType(classQName, false, classType); }
@Override public void visitVariable(@NotNull PsiVariable variable) { super.visitVariable(variable); final PsiType type = variable.getType(); final PsiType componentType = type.getDeepComponentType(); if (!(componentType instanceof PsiClassType)) { return; } final String className = ((PsiClassType)componentType).getClassName(); @NonNls final String javaLangReflect = "java.lang.reflect."; if (!className.startsWith(javaLangReflect)) { return; } final PsiTypeElement typeElement = variable.getTypeElement(); if (typeElement == null) { return; } registerError(typeElement); }
public String getName() { PsiType type = psiType; if (type instanceof PsiWildcardType) { type = ((PsiWildcardType)type).getBound(); } if (type instanceof PsiClassType) { final PsiClass resolve = ((PsiClassType)type).resolve(); if (resolve != null) { return resolve.getName(); } final String canonicalText = type.getCanonicalText(); final int i = canonicalText.indexOf('<'); if (i < 0) return canonicalText; return canonicalText.substring(0, i); } if (type == null) { return ""; } return type.getCanonicalText(); }
@Override public void getNamedArguments(@NotNull GrCall call, @Nullable PsiElement resolve, @Nullable String argumentName, boolean forCompletion, Map<String, NamedArgumentDescriptor> result) { if (!forCompletion || !(resolve instanceof PsiMethod)) return; PsiType returnType = ((PsiMethod)resolve).getReturnType(); if (!(returnType instanceof PsiClassType)) return; Map<String, NamedArgumentDescriptor> map = new HashMap<String, NamedArgumentDescriptor>(); GroovyConstructorNamedArgumentProvider.processClass(call, (PsiClassType)returnType, argumentName, map); for (String name : map.keySet()) { result.put(name, NamedArgumentDescriptor.SIMPLE_UNLIKELY); } }
@Override @NotNull public PsiJavaCodeReferenceElement[] getReferenceElements() { PsiClassType[] types = getReferencedTypes(); if (types.length == 0) return PsiJavaCodeReferenceElement.EMPTY_ARRAY; PsiManagerEx manager = getManager(); List<PsiJavaCodeReferenceElement> result = ContainerUtil.newArrayList(); for (PsiClassType type : types) { PsiClassType.ClassResolveResult resolveResult = type.resolveGenerics(); PsiClass resolved = resolveResult.getElement(); if (resolved != null) { result.add(new LightClassReference(manager, type.getCanonicalText(), resolved, resolveResult.getSubstitutor())); } } return result.toArray(new PsiJavaCodeReferenceElement[result.size()]); }
@Override public PsiType getSelectedType() { if (myForceDef) return null; if (myType == null) { final GrClosableBlock closure = ExtractClosureProcessorBase.generateClosure(this); PsiType type = closure.getType(); if (type instanceof PsiClassType) { final PsiType[] parameters = ((PsiClassType)type).getParameters(); if (parameters.length == 1 && parameters[0] != null) { if (parameters[0].equalsToText(PsiType.VOID.getBoxedTypeName())) { type = ((PsiClassType)type).rawType(); } } } myType = type; } return myType; }
/** * If the return type of {@code method} is a parameterized collection, this function * constructs the resource name from the parameterized parameters of the return type else it * returns {@code null}. * * @param method the method in which the resource name will be generated from * @return the guessed resource name */ @Override @Nullable public String guessResourceName(PsiMethod method) { Project project = getProject(method); if (project == null) { return null; } PsiType returnType = method.getReturnType(); if (isValidCollectionType(project, returnType)) { assert (returnType instanceof PsiClassType); PsiClassType classType = (PsiClassType) returnType; PsiType[] typeParams = classType.getParameters(); // TODO: Add inspection to verify that the the type parameter is specified // for paramerterized types, since trying to generate client libs without one generates // a : "Object type T not supported" return typeParams.length > 0 ? getSimpleName(project, typeParams[0]).toLowerCase() : null; } return null; }
/** * 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; }
private boolean isCollectionType(PsiType type, Project project) { PsiClassType collectionType = JavaPsiFacade.getElementFactory(project).createTypeByFQClassName("java.util.Collection"); if (collectionType.isAssignableFrom(type)) { return true; } // hack because isAssignableFrom is broken // todo(elharo): cover other collection types and non-generic collections // todo(elharo): better regex on Java class names String name = type.getCanonicalText(); if (name.matches("List<.+>")) { return true; } return false; }
/** * Returns {@code true} if {@code type} is a parameterized type and {@code false} otherwise. * * @param type the type to be evaluated * @return {@code true} if {@code type} is a parameterized type and {@code false} otherwise */ public static boolean isParameterizedType(PsiType type) { if (!(type instanceof PsiClassType)) { return false; } Boolean accepted = type.accept( new PsiTypeVisitor<Boolean>() { @Nullable @Override public Boolean visitClassType(PsiClassType classType) { return classType.getParameterCount() > 0; } }); return Boolean.TRUE.equals(accepted); }
@Nullable @Override public TypeBuilder visitClassType(PsiClassType classType) { String name = (classType instanceof PsiClassReferenceType) ? ((PsiClassReferenceType) classType).getReference().getQualifiedName() : classType.getClassName(); String mappedName = typeParameterMap.containsKey(name) ? typeParameterMap.get(name) : name; typeBuilder.withName(mappedName); for (PsiType param : classType.getParameters()) { PsiTypeParameterConverter converter = new PsiTypeParameterConverter(typeParameterMap); param.accept(converter); typeBuilder.withTypeBinding(converter.getTypeParameterBuilder()); } return super.visitClassType(classType); }
private void checkSuperClassInheritance(PsiClass superClass, String baseClassName, List<String> warnings) { final Project project = generatorProperties.getProject(); PsiClass baseClass = findPsiClass(project, baseClassName); if (baseClass == null) { warnings.add("Could not find base type '" + baseClassName + "' in the project."); } else if (!baseClass.equals(superClass)) { final PsiClassType[] superTypes = superClass.getSuperTypes(); boolean foundBaseClass = false; for (PsiClassType superType : superTypes) { final PsiClass resolve = superType.resolve(); if (baseClass.equals(resolve)) { foundBaseClass = true; break; } } if (!foundBaseClass) { warnings.add("Supertype '" + superClass.getQualifiedName() + "' does not extend '" + baseClass.getQualifiedName() + "'."); } } }
@Override public void visitReferenceExpression(GrReferenceExpression refExpr) { super.visitReferenceExpression(refExpr); GroovyResolveResult resolveResult = refExpr.advancedResolve(); PsiElement resolved = resolveResult.getElement(); if (resolved != null) { if (isDeclarationAssignment(refExpr) || resolved instanceof PsiPackage) return; } else { GrExpression qualifier = refExpr.getQualifierExpression(); if (qualifier == null && isDeclarationAssignment(refExpr)) return; } final PsiType refExprType = refExpr.getType(); if (refExprType == null) { if (resolved != null) { registerError(refExpr); } } else if (refExprType instanceof PsiClassType && ((PsiClassType)refExprType).resolve() == null) { registerError(refExpr); } }
/** * Make the class implementing Parcelable */ private void makeClassImplementParcelable(PsiElementFactory elementFactory, JavaCodeStyleManager styleManager) { final PsiClassType[] implementsListTypes = psiClass.getImplementsListTypes(); final String implementsType = "android.os.Parcelable"; for (PsiClassType implementsListType : implementsListTypes) { PsiClass resolved = implementsListType.resolve(); // Already implements Parcelable, no need to add it if (resolved != null && implementsType.equals(resolved.getQualifiedName())) { return; } } PsiJavaCodeReferenceElement implementsReference = elementFactory.createReferenceFromText(implementsType, psiClass); PsiReferenceList implementsList = psiClass.getImplementsList(); if (implementsList != null) { styleManager.shortenClassReferences(implementsList.add(implementsReference)); } }
@Override protected PsiFile createExpressionCodeFragment(@NotNull Project project, @NotNull XExpression expression, @Nullable PsiElement context, boolean isPhysical) { TextWithImports text = TextWithImportsImpl.fromXExpression(expression); if(text != null && context != null) { CodeFragmentFactory factory = DebuggerUtilsEx.findAppropriateCodeFragmentFactory(text, context); JavaCodeFragment codeFragment = factory.createPresentationCodeFragment(text, context, project); codeFragment.forceResolveScope(GlobalSearchScope.allScope(project)); final PsiClass contextClass = PsiTreeUtil.getNonStrictParentOfType(context, PsiClass.class); if(contextClass != null) { final PsiClassType contextType = JavaPsiFacade.getInstance(codeFragment.getProject()).getElementFactory().createType(contextClass); codeFragment.setThisType(contextType); } return codeFragment; } else { return super.createExpressionCodeFragment(project, expression, context, isPhysical); } }
private void validateCleanUpMethodExists(@NotNull PsiLocalVariable psiVariable, @NotNull String cleanupName, @NotNull ProblemNewBuilder problemNewBuilder) { final PsiType psiType = psiVariable.getType(); if (psiType instanceof PsiClassType) { final PsiClassType psiClassType = (PsiClassType) psiType; final PsiClass psiClassOfField = psiClassType.resolve(); final PsiMethod[] methods; if (psiClassOfField != null) { methods = psiClassOfField.findMethodsByName(cleanupName, true); boolean hasCleanupMethod = false; for (PsiMethod method : methods) { if (0 == method.getParameterList().getParametersCount()) { hasCleanupMethod = true; } } if (!hasCleanupMethod) { problemNewBuilder.addError("'@Cleanup': method '%s()' not found on target class", cleanupName); } } } else { problemNewBuilder.addError("'@Cleanup': is legal only on a local variable declaration inside a block"); } }
@NotNull public static PsiType extractAllElementType(@NotNull PsiType psiType, @NotNull PsiManager psiManager, final String superClass, final int paramIndex) { PsiType oneElementType = PsiUtil.substituteTypeParameter(psiType, superClass, paramIndex, true); if (oneElementType instanceof PsiWildcardType) { oneElementType = ((PsiWildcardType) oneElementType).getBound(); } PsiType result; final PsiClassType javaLangObject = PsiType.getJavaLangObject(psiManager, GlobalSearchScope.allScope(psiManager.getProject())); if (null == oneElementType || Comparing.equal(javaLangObject, oneElementType)) { result = PsiWildcardType.createUnbounded(psiManager); } else { result = PsiWildcardType.createExtends(psiManager, oneElementType); } return result; }
@NotNull public static PsiType[] extractTypeParameters(@NotNull PsiType psiType, @NotNull PsiManager psiManager) { if (!(psiType instanceof PsiClassType)) { return PsiType.EMPTY_ARRAY; } final PsiClassType classType = (PsiClassType) psiType; final PsiClassType.ClassResolveResult classResolveResult = classType.resolveGenerics(); final PsiClass psiClass = classResolveResult.getElement(); if (psiClass == null) { return PsiType.EMPTY_ARRAY; } final PsiSubstitutor psiSubstitutor = classResolveResult.getSubstitutor(); final PsiTypeParameter[] typeParameters = psiClass.getTypeParameters(); final PsiType[] psiTypes = PsiType.createArray(typeParameters.length); for (int i = 0; i < typeParameters.length; i++) { PsiType psiSubstituteKeyType = psiSubstitutor.substitute(typeParameters[i]); if (null == psiSubstituteKeyType) { psiSubstituteKeyType = PsiType.getJavaLangObject(psiManager, GlobalSearchScope.allScope(psiManager.getProject())); } psiTypes[i] = psiSubstituteKeyType; } return psiTypes; }
private void compareThrows(PsiReferenceList beforeThrows, PsiReferenceList afterThrows, PsiMethod psiMethod) { PsiClassType[] beforeTypes = beforeThrows.getReferencedTypes(); PsiClassType[] afterTypes = afterThrows.getReferencedTypes(); assertEquals("Throws counts are different for Method :" + psiMethod.getName(), beforeTypes.length, afterTypes.length); for (PsiClassType beforeType : beforeTypes) { boolean found = false; for (PsiClassType afterType : afterTypes) { if (beforeType.equals(afterType)) { found = true; break; } } assertTrue("Expected throw: " + beforeType.getClassName() + " not found on " + psiMethod.getName(), found); } }
@Override public boolean isApplicable(@NotNull PsiElement element, @NotNull Document copyDocument, int newOffset) { if (!PsiUtil.isLanguageLevel7OrHigher(element)) return false; PsiExpression initializer = JavaPostfixTemplatesUtils.getTopmostExpression(element); if (initializer == null) return false; final PsiType type = initializer.getType(); if (!(type instanceof PsiClassType)) return false; final PsiClass aClass = ((PsiClassType)type).resolve(); Project project = element.getProject(); final JavaPsiFacade facade = JavaPsiFacade.getInstance(project); final PsiClass autoCloseable = facade.findClass(CommonClassNames.JAVA_LANG_AUTO_CLOSEABLE, ProjectScope.getLibrariesScope(project)); if (!InheritanceUtil.isInheritorOrSelf(aClass, autoCloseable, true)) return false; return true; }
public ChangeFormComponentTypeFix(PsiPlainTextFile formFile, String fieldName, PsiType componentTypeToSet) { myFormFile = formFile; myFieldName = fieldName; if (componentTypeToSet instanceof PsiClassType) { PsiClass psiClass = ((PsiClassType)componentTypeToSet).resolve(); if (psiClass != null) { myComponentTypeToSet = ClassUtil.getJVMClassName(psiClass); } else { myComponentTypeToSet = ((PsiClassType) componentTypeToSet).rawType().getCanonicalText(); } } else { myComponentTypeToSet = componentTypeToSet.getCanonicalText(); } }
@SuppressWarnings("HardCodedStringLiteral") public static boolean isGetByStringOrByObjectMethod(@NotNull PsiMethod method) { String methodName = method.getName(); if(!"get".equals(methodName)) { return false; } PsiParameterList parameterList = method.getParameterList(); if(parameterList.getParametersCount() != 1) { return false; } PsiParameter parameter = parameterList.getParameters()[0]; final PsiElementFactory factory = JavaPsiFacade.getInstance(method.getProject()).getElementFactory(); PsiClassType javaLangString = factory.createTypeByFQClassName(JavaClassNames.JAVA_LANG_STRING, method.getResolveScope()); if(parameter.getType().isAssignableFrom(javaLangString)) { return true; } PsiClassType javaLangObject = factory.createTypeByFQClassName(JavaClassNames.JAVA_LANG_OBJECT, method.getResolveScope()); return parameter.getType().isAssignableFrom(javaLangObject); }
@NotNull @Override public PsiClassType[] getReferencedTypes() { if (myCachedTypes == null) { if (myRefs.isEmpty()) { myCachedTypes = PsiClassType.EMPTY_ARRAY; } else { final int size = myRefs.size(); myCachedTypes = new PsiClassType[size]; for (int i = 0; i < size; i++) { myCachedTypes[i] = myFactory.createType(myRefs.get(i)); } } } return myCachedTypes; }
public void testReplacingType() throws Exception { doTest(new Runnable() { @Override public void run() { final PsiElement elementAt = myFile.findElementAt(myEditor.getCaretModel().getOffset()); final PsiTypeElement typeElement = PsiTreeUtil.getParentOfType(elementAt, PsiTypeElement.class); final PsiClass aClassA = JavaPsiFacade.getInstance(myProject).findClass("p2.A", GlobalSearchScope.moduleScope(myModule)); assertNotNull(aClassA); final PsiElementFactory factory = myJavaFacade.getElementFactory(); final PsiClassType type = factory.createType(aClassA); try { typeElement.replace(factory.createTypeElement(type)); } catch(IncorrectOperationException e) { LOGGER.error(e); } } }); }
public static void addBound(PsiType inferenceVariableType, PsiType boundType, InferenceBound inferenceBound, InferenceSession session) { final InferenceVariable variable = session.getInferenceVariable(inferenceVariableType); if(variable != null) { for(TypeAnnotationModifier modifier : TypeAnnotationModifier.EP_NAME.getExtensions()) { if(boundType instanceof PsiClassType) { final TypeAnnotationProvider annotationProvider = modifier.modifyAnnotations(inferenceVariableType, (PsiClassType) boundType); if(annotationProvider != null) { boundType = boundType.annotate(annotationProvider); } } } variable.addBound(boundType, inferenceBound, session.myIncorporationPhase); } }
@Override @NotNull public PsiClassType[] getReferencedTypes() { PsiClassReferenceListStub stub = getGreenStub(); if(stub != null) { return stub.getReferencedTypes(); } PsiJavaCodeReferenceElement[] refs = getReferenceElements(); PsiElementFactory factory = JavaPsiFacade.getInstance(getProject()).getElementFactory(); PsiClassType[] types = new PsiClassType[refs.length]; for(int i = 0; i < types.length; i++) { types[i] = factory.createType(refs[i]); } return types; }