From 3259aa5646b7618ecaadfac0bd95c5e23ea10c27 Mon Sep 17 00:00:00 2001 From: anna Date: Tue, 9 Oct 2012 17:49:37 +0200 Subject: [PATCH] method refs: disable suggestions to change/migrate type of variable if right type is method reference - no way to suggest correct type now (IDEA-92600) --- .../codeInsight/daemon/impl/analysis/HighlightUtil.java | 3 ++- .../uncheckedWarnings/UncheckedWarningLocalInspection.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java index 06b19406945e..174b2b4d9efb 100644 --- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java +++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java @@ -481,7 +481,7 @@ public class HighlightUtil { int start = variable.getTypeElement().getTextRange().getStartOffset(); int end = variable.getTextRange().getEndOffset(); HighlightInfo highlightInfo = checkAssignability(lType, rType, initializer, new TextRange(start, end)); - if (highlightInfo != null && !(rType instanceof PsiMethodReferenceType)) { + if (highlightInfo != null) { registerChangeVariableTypeFixes(variable, rType, highlightInfo); } return highlightInfo; @@ -2534,6 +2534,7 @@ public class HighlightUtil { } public static void registerChangeVariableTypeFixes(PsiVariable parameter, PsiType itemType, HighlightInfo highlightInfo) { + if (itemType instanceof PsiMethodReferenceType) return; for (ChangeVariableTypeQuickFixProvider fixProvider : Extensions.getExtensions(ChangeVariableTypeQuickFixProvider.EP_NAME)) { for (IntentionAction action : fixProvider.getFixes(parameter, itemType)) { QuickFixAction.registerQuickFixAction(highlightInfo, action); diff --git a/java/java-impl/src/com/intellij/codeInspection/uncheckedWarnings/UncheckedWarningLocalInspection.java b/java/java-impl/src/com/intellij/codeInspection/uncheckedWarnings/UncheckedWarningLocalInspection.java index 2eae3fffd3ed..db52ddebb2d8 100644 --- a/java/java-impl/src/com/intellij/codeInspection/uncheckedWarnings/UncheckedWarningLocalInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/uncheckedWarnings/UncheckedWarningLocalInspection.java @@ -272,7 +272,7 @@ public class UncheckedWarningLocalInspection extends BaseJavaLocalInspectionTool if (initializer == null || initializer instanceof PsiArrayInitializerExpression) return; final PsiType initializerType = initializer.getType(); checkRawToGenericsAssignment(initializer, variable.getType(), initializerType, true, - myOnTheFly && !(initializerType instanceof PsiMethodReferenceType) ? getChangeVariableTypeFixes(variable, initializerType) : LocalQuickFix.EMPTY_ARRAY); + myOnTheFly ? getChangeVariableTypeFixes(variable, initializerType) : LocalQuickFix.EMPTY_ARRAY); } @Override @@ -467,6 +467,7 @@ public class UncheckedWarningLocalInspection extends BaseJavaLocalInspectionTool } public static LocalQuickFix[] getChangeVariableTypeFixes(PsiVariable parameter, PsiType itemType) { + if (itemType instanceof PsiMethodReferenceType) return LocalQuickFix.EMPTY_ARRAY; final List result = new ArrayList(); LOG.assertTrue(parameter.isValid()); for (ChangeVariableTypeQuickFixProvider fixProvider : Extensions.getExtensions(ChangeVariableTypeQuickFixProvider.EP_NAME)) {