Java Code Examples for com.intellij.codeInsight.daemon.impl.HighlightInfo#registerFix()

The following examples show how to use com.intellij.codeInsight.daemon.impl.HighlightInfo#registerFix() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PantsScalaHighlightVisitor.java    From intellij-pants-plugin with Apache License 2.0 6 votes vote down vote up
private void tryToExtendInfo(@NotNull HighlightInfo info, @NotNull PsiFile containingFile) {
  List<Pair<HighlightInfo.IntentionActionDescriptor, TextRange>> actionRanges = info.quickFixActionRanges;
  if (actionRanges == null) {
    return;
  }
  for (Pair<HighlightInfo.IntentionActionDescriptor, TextRange> actionAndRange : actionRanges) {
    final TextRange textRange = actionAndRange.getSecond();
    final HighlightInfo.IntentionActionDescriptor actionDescriptor = actionAndRange.getFirst();
    final IntentionAction action = actionDescriptor.getAction();
    if (action instanceof CreateTypeDefinitionQuickFix) {
      final String className = textRange.substring(containingFile.getText());
      final List<PantsQuickFix> missingDependencyFixes =
        PantsUnresolvedReferenceFixFinder.findMissingDependencies(className, containingFile);
      for (PantsQuickFix fix : missingDependencyFixes) {
        info.registerFix(fix, null, fix.getName(), textRange, null);
      }
      if (!missingDependencyFixes.isEmpty()) {
        // we should add only one fix per info
        return;
      }
    }
  }
}
 
Example 2
Source File: LombokHighlightErrorFilter.java    From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void processHook(@NotNull PsiElement highlightedElement, @NotNull HighlightInfo highlightInfo) {
  PsiElement importantParent = PsiTreeUtil.getParentOfType(highlightedElement,
    PsiMethod.class, PsiLambdaExpression.class, PsiMethodReferenceExpression.class, PsiClassInitializer.class
  );

  // applicable only for methods
  if (importantParent instanceof PsiMethod) {
    AddAnnotationFix fix = new AddAnnotationFix(SneakyThrows.class.getCanonicalName(), (PsiModifierListOwner) importantParent);
    highlightInfo.registerFix(fix, null, null, null, null);
  }
}
 
Example 3
Source File: QuickFixAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
/** This is used by TeamCity plugin */
@Deprecated
public static void registerQuickFixAction(@Nullable HighlightInfo info,
                                          @Nullable IntentionAction action,
                                          @Nullable List<IntentionAction> options,
                                          @Nullable String displayName) {
  if (info == null) return;
  info.registerFix(action, options, displayName, null, null);
}
 
Example 4
Source File: QuickFixAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static void registerQuickFixAction(@Nullable HighlightInfo info,
                                          @Nullable TextRange fixRange,
                                          @Nullable IntentionAction action,
                                          @Nullable final HighlightDisplayKey key) {
  if (info == null) return;
  info.registerFix(action, null, HighlightDisplayKey.getDisplayNameByKey(key), fixRange, key);
}
 
Example 5
Source File: QuickFixAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static void registerQuickFixAction(@Nullable HighlightInfo info, @Nullable TextRange fixRange, @Nullable IntentionAction action) {
  if (info == null) return;
  info.registerFix(action, null, null, fixRange, null);
}