Search in sources :

Example 1 with ChangeVariableTypeQuickFixProvider

use of com.intellij.codeInsight.quickfix.ChangeVariableTypeQuickFixProvider in project intellij-community by JetBrains.

the class HighlightUtil method getChangeVariableTypeFixes.

@NotNull
public static List<IntentionAction> getChangeVariableTypeFixes(@NotNull PsiVariable parameter, PsiType itemType) {
    if (itemType instanceof PsiMethodReferenceType)
        return Collections.emptyList();
    List<IntentionAction> result = new ArrayList<>();
    if (itemType != null) {
        for (ChangeVariableTypeQuickFixProvider fixProvider : Extensions.getExtensions(ChangeVariableTypeQuickFixProvider.EP_NAME)) {
            Collections.addAll(result, fixProvider.getFixes(parameter, itemType));
        }
    }
    IntentionAction changeFix = getChangeParameterClassFix(parameter.getType(), itemType);
    if (changeFix != null)
        result.add(changeFix);
    return result;
}
Also used : IntentionAction(com.intellij.codeInsight.intention.IntentionAction) ChangeVariableTypeQuickFixProvider(com.intellij.codeInsight.quickfix.ChangeVariableTypeQuickFixProvider)

Example 2 with ChangeVariableTypeQuickFixProvider

use of com.intellij.codeInsight.quickfix.ChangeVariableTypeQuickFixProvider in project intellij-community by JetBrains.

the class UncheckedWarningLocalInspectionBase method getChangeVariableTypeFixes.

@NotNull
private static LocalQuickFix[] getChangeVariableTypeFixes(@NotNull PsiVariable parameter, @Nullable PsiType itemType, LocalQuickFix[] generifyFixes) {
    if (itemType instanceof PsiMethodReferenceType)
        return generifyFixes;
    LOG.assertTrue(parameter.isValid());
    final List<LocalQuickFix> result = new ArrayList<>();
    if (itemType != null) {
        for (ChangeVariableTypeQuickFixProvider fixProvider : Extensions.getExtensions(ChangeVariableTypeQuickFixProvider.EP_NAME)) {
            for (IntentionAction action : fixProvider.getFixes(parameter, itemType)) {
                if (action instanceof LocalQuickFix) {
                    result.add((LocalQuickFix) action);
                }
            }
        }
    }
    if (generifyFixes.length > 0) {
        Collections.addAll(result, generifyFixes);
    }
    return result.toArray(new LocalQuickFix[result.size()]);
}
Also used : IntentionAction(com.intellij.codeInsight.intention.IntentionAction) ArrayList(java.util.ArrayList) ChangeVariableTypeQuickFixProvider(com.intellij.codeInsight.quickfix.ChangeVariableTypeQuickFixProvider) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

IntentionAction (com.intellij.codeInsight.intention.IntentionAction)2 ChangeVariableTypeQuickFixProvider (com.intellij.codeInsight.quickfix.ChangeVariableTypeQuickFixProvider)2 ArrayList (java.util.ArrayList)1 NotNull (org.jetbrains.annotations.NotNull)1