ModCommand (@NotNull ActionContext context, @NotNull PsiMethod method) { PsiJavaCodeReferenceElement[] referenceElements = method.getThrowsList().getReferenceElements(); return Arrays.stream(referenceElements) .filter(referenceElement -> referenceElement.getCanonicalText().equals(myThrowsCanonicalText)).findFirst() .map(ref -> ModCommand.psiUpdate(ref, PsiElement::delete)) .orElse(ModCommand.nop()); }