mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-86926 Also suggest to change parameter type if types mismatch in assignment implemented
This commit is contained in:
+24
-11
@@ -422,21 +422,34 @@ public class HighlightUtil {
|
||||
if (rType == null) return null;
|
||||
|
||||
HighlightInfo highlightInfo = checkAssignability(lType, rType, rExpr, assignment);
|
||||
if (highlightInfo != null) {
|
||||
PsiVariable leftVar = null;
|
||||
if (lExpr instanceof PsiReferenceExpression) {
|
||||
PsiElement element = ((PsiReferenceExpression)lExpr).resolve();
|
||||
if (element instanceof PsiVariable) {
|
||||
leftVar = (PsiVariable)element;
|
||||
}
|
||||
}
|
||||
if (leftVar != null) {
|
||||
registerChangeVariableTypeFixes(leftVar, rType, highlightInfo);
|
||||
}
|
||||
if (highlightInfo == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
registerChangeVariableTypeFixes(lExpr, rType, highlightInfo);
|
||||
if (lType != null) {
|
||||
registerChangeVariableTypeFixes(rExpr, lType, highlightInfo);
|
||||
}
|
||||
|
||||
return highlightInfo;
|
||||
}
|
||||
|
||||
private static void registerChangeVariableTypeFixes(@NotNull PsiExpression expression,
|
||||
@NotNull PsiType type,
|
||||
@NotNull HighlightInfo highlightInfo) {
|
||||
if (!(expression instanceof PsiReferenceExpression)){
|
||||
return;
|
||||
}
|
||||
|
||||
final PsiElement element = ((PsiReferenceExpression)expression).resolve();
|
||||
|
||||
if (element == null || !(element instanceof PsiVariable)){
|
||||
return;
|
||||
}
|
||||
|
||||
registerChangeVariableTypeFixes((PsiVariable)element, type, highlightInfo);
|
||||
}
|
||||
|
||||
private static boolean isCastIntentionApplicable(@NotNull PsiExpression expression, @Nullable PsiType toType) {
|
||||
while (expression instanceof PsiTypeCastExpression || expression instanceof PsiParenthesizedExpression) {
|
||||
if (expression instanceof PsiTypeCastExpression) {
|
||||
|
||||
Reference in New Issue
Block a user