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)

This commit is contained in:
anna
2012-10-09 17:54:34 +02:00
parent 573abd10e3
commit 3259aa5646
2 changed files with 4 additions and 2 deletions
@@ -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);
@@ -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<LocalQuickFix> result = new ArrayList<LocalQuickFix>();
LOG.assertTrue(parameter.isValid());
for (ChangeVariableTypeQuickFixProvider fixProvider : Extensions.getExtensions(ChangeVariableTypeQuickFixProvider.EP_NAME)) {