@Override protected void doFix(Project project, ProblemDescriptor descriptor) throws IncorrectOperationException { final PsiElement element = descriptor.getPsiElement(); final PsiElement parent = element.getParent(); if (!(parent instanceof PsiCatchSection)) { return; } final PsiCatchSection catchSection = (PsiCatchSection) parent; final PsiParameter parameter = catchSection.getParameter(); if (parameter == null) { return; } final PsiIdentifier identifier = parameter.getNameIdentifier(); if (identifier == null) { return; } final PsiElementFactory factory = JavaPsiFacade.getInstance(project).getElementFactory(); final PsiIdentifier newIdentifier = factory.createIdentifier("ignored"); identifier.replace(newIdentifier); }
private void checkCatchSection(PsiCatchSection section) { final PsiCodeBlock block = section.getCatchBlock(); if (block == null || !isCatchBlockEmpty(block)) { return; } final PsiParameter parameter = section.getParameter(); if (parameter == null) { return; } final PsiIdentifier identifier = parameter.getNameIdentifier(); if (identifier == null) { return; } @NonNls final String parameterName = parameter.getName(); if (m_ignoreIgnoreParameter && ("ignore".equals(parameterName) || "ignored".equals(parameterName))) { return; } final PsiElement catchToken = section.getFirstChild(); if (catchToken == null) { return; } registerError(catchToken); }