Search in sources :

Example 1 with UnusedDeclarationFixProvider

use of com.intellij.codeInspection.reference.UnusedDeclarationFixProvider in project intellij-community by JetBrains.

the class UnusedSymbolUtil method createUnusedSymbolInfo.

@Nullable
public static HighlightInfo createUnusedSymbolInfo(@NotNull PsiElement element, @NotNull String message, @NotNull final HighlightInfoType highlightInfoType) {
    HighlightInfo info = HighlightInfo.newHighlightInfo(highlightInfoType).range(element).descriptionAndTooltip(message).create();
    if (info == null) {
        //filtered out
        return null;
    }
    UnusedDeclarationFixProvider[] fixProviders = Extensions.getExtensions(UnusedDeclarationFixProvider.EP_NAME);
    for (UnusedDeclarationFixProvider provider : fixProviders) {
        IntentionAction[] fixes = provider.getQuickFixes(element);
        for (IntentionAction fix : fixes) {
            QuickFixAction.registerQuickFixAction(info, fix);
        }
    }
    return info;
}
Also used : IntentionAction(com.intellij.codeInsight.intention.IntentionAction) UnusedDeclarationFixProvider(com.intellij.codeInspection.reference.UnusedDeclarationFixProvider) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

IntentionAction (com.intellij.codeInsight.intention.IntentionAction)1 UnusedDeclarationFixProvider (com.intellij.codeInspection.reference.UnusedDeclarationFixProvider)1 Nullable (org.jetbrains.annotations.Nullable)1