use of org.jetbrains.plugins.groovy.codeInspection.assignment.ParameterCastFix in project intellij-community by JetBrains.
the class GroovyTypeCheckVisitorHelper method genCastFixes.
@NotNull
public static LocalQuickFix[] genCastFixes(@NotNull GrSignature signature, @NotNull PsiType[] argumentTypes, @Nullable GrArgumentList argumentList) {
if (argumentList == null)
return LocalQuickFix.EMPTY_ARRAY;
final List<GrExpression> args = getExpressionArgumentsOfCall(argumentList);
if (args == null)
return LocalQuickFix.EMPTY_ARRAY;
final List<Pair<Integer, PsiType>> allErrors = new ArrayList<>();
final List<GrClosureSignature> signatures = GrClosureSignatureUtil.generateSimpleSignatures(signature);
for (GrClosureSignature closureSignature : signatures) {
final GrClosureSignatureUtil.MapResultWithError<PsiType> map = GrClosureSignatureUtil.mapSimpleSignatureWithErrors(closureSignature, argumentTypes, id, argumentList, 1);
if (map != null) {
final List<Pair<Integer, PsiType>> errors = map.getErrors();
for (Pair<Integer, PsiType> error : errors) {
if (!(error.first == 0 && PsiImplUtil.hasNamedArguments(argumentList))) {
allErrors.add(error);
}
}
}
}
final ArrayList<LocalQuickFix> fixes = new ArrayList<>();
for (Pair<Integer, PsiType> error : allErrors) {
if (args.size() > error.first && error.second != null) {
fixes.add(new ParameterCastFix(error.first, error.second, args.get(error.first)));
}
}
return fixes.toArray(new LocalQuickFix[fixes.size()]);
}
Aggregations