PrepopulatedCollectionModel (PsiExpression mapDefinition) { mapDefinition = PsiUtil.skipParenthesizedExprDown(mapDefinition); if (mapDefinition instanceof PsiReferenceExpression ref) { return fromVariable(ref, "Map", JAVA_UTIL_HASH_MAP, MAP_PUT); } if (mapDefinition instanceof PsiNewExpression newExpression) { PsiAnonymousClass anonymousClass = newExpression.getAnonymousClass(); PsiExpressionList argumentList = newExpression.getArgumentList(); if (argumentList != null) { PsiExpression[] args = argumentList.getExpressions(); PsiJavaCodeReferenceElement classReference = newExpression.getClassReference(); if (classReference != null && PsiUtil.isLanguageLevel10OrHigher(mapDefinition) && JAVA_UTIL_HASH_MAP.equals(classReference.getQualifiedName()) && args.length == 1) { PsiExpression arg = PsiUtil.skipParenthesizedExprDown(args[0]); if (arg != null) { PsiType sourceType = arg.getType(); PsiType targetType = newExpression.getType(); if (targetType != null && sourceType != null && sourceType.isAssignableFrom(targetType)) { return new PrepopulatedCollectionModel(Collections.singletonList(arg), Collections.emptyList(), "Map", true); } } } if (anonymousClass != null && argumentList.isEmpty()) { PsiJavaCodeReferenceElement baseClassReference = anonymousClass.getBaseClassReference(); if (JAVA_UTIL_HASH_MAP.equals(baseClassReference.getQualifiedName())) { return fromInitializer(anonymousClass, "Map", MAP_PUT); } } } } return null; }