Skip to content

Commit

Permalink
Fix ArrayIndexOutOfBoundsException in AliMissingOverrideAnnotationIns…
Browse files Browse the repository at this point in the history
…pection

Related to #999

Add checks for empty arrays in `AliMissingOverrideAnnotationInspection.kt` to prevent `ArrayIndexOutOfBoundsException`.

* Add a check for empty `infos` array before accessing elements in the `buildFix` method.
* Add a check for null `psiElement` before calling `buildFix` in the `manualBuildFix` method.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/alibaba/p3c/issues/999?shareId=XXXX-XXXX-XXXX-XXXX).
  • Loading branch information
xuantan committed Aug 5, 2024
1 parent 6c59c8c commit 7c9665a
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,20 @@ class AliMissingOverrideAnnotationInspection : MissingOverrideAnnotationInspecti
override fun createOptionsPanel(): JComponent? = null

override fun buildFix(vararg infos: Any): InspectionGadgetsFix? {
if (infos.isEmpty()) {
return null
}
val fix = super.buildFix(*infos) ?: return null
return DecorateInspectionGadgetsFix(fix,
P3cBundle.getMessage("com.alibaba.p3c.idea.quickfix.standalone.AliMissingOverrideAnnotationInspection"))
}

override fun manualBuildFix(psiElement: PsiElement, isOnTheFly: Boolean): LocalQuickFix? = buildFix(psiElement)
override fun manualBuildFix(psiElement: PsiElement, isOnTheFly: Boolean): LocalQuickFix? {
if (psiElement == null) {
return null
}
return buildFix(psiElement)
}

override fun getDefaultLevel(): HighlightDisplayLevel = HighlightDisplayLevels.BLOCKER

Expand Down

0 comments on commit 7c9665a

Please sign in to comment.