use of com.intellij.psi.scope.conflictResolvers.JavaMethodsConflictResolver in project intellij-community by JetBrains.
the class PsiDiamondTypeImpl method getStaticFactoryCandidateInfo.
private static JavaResolveResult getStaticFactoryCandidateInfo(final PsiNewExpression newExpression, final PsiElement context) {
return ourDiamondGuard.doPreventingRecursion(context, false, () -> {
final PsiExpressionList argumentList = newExpression.getArgumentList();
if (argumentList == null) {
//token expected diagnostic is provided by parser
return null;
}
final JavaMethodsConflictResolver resolver = new JavaMethodsConflictResolver(argumentList, PsiUtil.getLanguageLevel(newExpression));
final JavaResolveResult[] result = collectStaticFactories(newExpression, resolver);
final PsiMethod staticFactory = result != null && result.length == 1 ? (PsiMethod) result[0].getElement() : null;
if (staticFactory == null) {
//additional diagnostics: inference fails due to unresolved constructor
return JavaResolveResult.EMPTY;
}
final MethodCandidateInfo staticFactoryCandidateInfo = createMethodCandidate(staticFactory, context, false, argumentList);
if (!staticFactory.isVarArgs()) {
return staticFactoryCandidateInfo;
}
final ArrayList<CandidateInfo> conflicts = new ArrayList<>();
conflicts.add(staticFactoryCandidateInfo);
conflicts.add(createMethodCandidate(staticFactory, context, true, argumentList));
return resolver.resolveConflict(conflicts);
});
}
Aggregations