mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[codeInspection] MyAddExplicitTypeArgumentsFix: support preview
GitOrigin-RevId: 2c2f2192db2bb108e824f534440f0eeee8451371
This commit is contained in:
committed by
intellij-monorepo-bot
parent
82cfd789d3
commit
e8d121713c
+15
@@ -7,6 +7,7 @@ import com.intellij.codeInsight.daemon.impl.actions.SuppressByJavaCommentFix;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.JavaHighlightUtil;
|
||||
import com.intellij.codeInsight.daemon.impl.quickfix.AddTypeArgumentsFix;
|
||||
import com.intellij.codeInsight.intention.QuickFixFactory;
|
||||
import com.intellij.codeInsight.intention.preview.IntentionPreviewInfo;
|
||||
import com.intellij.codeInspection.LocalQuickFix;
|
||||
import com.intellij.codeInspection.ProblemDescriptor;
|
||||
import com.intellij.codeInspection.ProblemHighlightType;
|
||||
@@ -333,5 +334,19 @@ public class JavacQuirksInspectionVisitor extends JavaElementVisitor {
|
||||
public boolean startInWriteAction() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull IntentionPreviewInfo generatePreview(@NotNull Project project, @NotNull ProblemDescriptor previewDescriptor) {
|
||||
PsiElement element = previewDescriptor.getPsiElement();
|
||||
if (element instanceof PsiReferenceExpression) {
|
||||
PsiElement parent = element.getParent();
|
||||
if (parent instanceof PsiMethodCallExpression) {
|
||||
PsiExpression withArgs = AddTypeArgumentsFix.addTypeArguments((PsiExpression)parent, null);
|
||||
if (withArgs == null) return IntentionPreviewInfo.EMPTY;
|
||||
CodeStyleManager.getInstance(project).reformat(parent.replace(withArgs));
|
||||
}
|
||||
}
|
||||
return IntentionPreviewInfo.DIFF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user