PsiClassType (@NotNull PsiElement element, @NotNull PsiType fromType) { final Project project = element.getProject(); JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project); PsiElementFactory factory = psiFacade.getElementFactory(); GlobalSearchScope scope = element.getResolveScope(); String atomicQualifiedName = myFromToMap.get(fromType); if (atomicQualifiedName != null) { PsiClass atomicClass = psiFacade.findClass(atomicQualifiedName, scope); if (atomicClass == null) {//show warning return null; } return factory.createType(atomicClass); } else if (fromType instanceof PsiArrayType) { PsiClass atomicReferenceArrayClass = psiFacade.findClass(AtomicReferenceArray.class.getName(), scope); if (atomicReferenceArrayClass == null) {//show warning return null; } Map<PsiTypeParameter, PsiType> substitutor = new HashMap<>(); PsiTypeParameter[] typeParameters = atomicReferenceArrayClass.getTypeParameters(); if (typeParameters.length == 1) { PsiType componentType = ((PsiArrayType)fromType).getComponentType(); if (componentType instanceof PsiPrimitiveType) componentType = ((PsiPrimitiveType)componentType).getBoxedType(element); substitutor.put(typeParameters[0], componentType); } return factory.createType(atomicReferenceArrayClass, factory.createSubstitutor(substitutor)); } else { PsiClass atomicReferenceClass = psiFacade.findClass(AtomicReference.class.getName(), scope); if (atomicReferenceClass == null) {//show warning return null; } Map<PsiTypeParameter, PsiType> substitutor = new HashMap<>(); PsiTypeParameter[] typeParameters = atomicReferenceClass.getTypeParameters(); if (typeParameters.length == 1) { PsiType type = fromType; if (type instanceof PsiPrimitiveType) type = ((PsiPrimitiveType)fromType).getBoxedType(element); substitutor.put(typeParameters[0], type); } return factory.createType(atomicReferenceClass, factory.createSubstitutor(substitutor)); } }