[java-completion] IJ-CR-124074 IDEA-342465 support correctness for completion

- Allow running highlighting on the copy of the file. Add comments

GitOrigin-RevId: c568202e7b1462834ab70fbdb1c3bd0bac448c92
This commit is contained in:
Mikhail Pyltsin
2024-01-22 12:14:30 +01:00
committed by intellij-monorepo-bot
parent 70ecc55cab
commit 897bfa4e1c
2 changed files with 8 additions and 3 deletions

View File

@@ -553,8 +553,13 @@ public abstract class QuickFixFactory {
public abstract @NotNull IntentionAction createDeleteSwitchLabelFix(@NotNull PsiCaseLabelElement labelElement);
/**
* @return The IntentionAction that performs the deletion of the default element.
* Returns null if the fix cannot be created
* (for example, if the file is not physical, it can happen when highlighting is run on the copy of the file).
*/
@Nullable
public abstract IntentionAction createDeleteDefaultFix(@NotNull PsiFile file, @NotNull PsiElement duplicateElement);
public abstract IntentionAction createDeleteDefaultFix(@NotNull PsiFile file, @NotNull PsiElement defaultElement);
public abstract @NotNull IntentionAction createAddAnnotationTargetFix(@NotNull PsiAnnotation annotation, PsiAnnotation.TargetType target);

View File

@@ -1124,10 +1124,10 @@ public final class QuickFixFactoryImpl extends QuickFixFactory {
}
@Override
public @Nullable IntentionAction createDeleteDefaultFix(@NotNull PsiFile file, @NotNull PsiElement duplicateElement) {
public @Nullable IntentionAction createDeleteDefaultFix(@NotNull PsiFile file, @NotNull PsiElement defaultElement) {
if(!file.isPhysical()) return null;
ProblemDescriptor descriptor =
new ProblemDescriptorBase(duplicateElement, duplicateElement, "", null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false, null,
new ProblemDescriptorBase(defaultElement, defaultElement, "", null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false, null,
false, false);
return QuickFixWrapper.wrap(descriptor, new UnnecessaryDefaultInspection.DeleteDefaultFix());
}