NewListTerminal (@NotNull CollectTerminal terminal, @NotNull PsiElement element) { if (terminal.getStatus() == ControlFlowUtils.InitializerUsageStatus.UNKNOWN) return null; String intermediateSteps = terminal.getIntermediateStepsFromCollection(); if (intermediateSteps == null) return null; WrapperCandidate candidate = WrapperCandidate.tryExtract(terminal, element); if (candidate == null) return null; if (!(candidate.myCandidate instanceof PsiCallExpression callExpression)) return null; PsiClass targetClass = PsiUtil.resolveClassInClassTypeOnly(candidate.myCandidate.getType()); if (!InheritanceUtil.isInheritor(targetClass, JAVA_UTIL_COLLECTION)) return null; if ("java.util.concurrent.PriorityBlockingQueue".equals(targetClass.getQualifiedName()) || "java.util.PriorityQueue".equals(targetClass.getQualifiedName())) { return null; } if (!ConstructionUtils.isPrepopulatedCollectionInitializer(callExpression)) return null; if (JAVA_UTIL_HASH_SET.equals(targetClass.getQualifiedName()) && intermediateSteps.equals(".distinct()")) { intermediateSteps = ""; } PsiExpressionList argumentList = callExpression.getArgumentList(); if (argumentList == null) return null; PsiExpression[] args = argumentList.getExpressions(); if (args.length != 1 || !terminal.isTargetReference(args[0])) return null; return new NewListTerminal(terminal, candidate.myVar, intermediateSteps, callExpression, candidate.myType); }