/** Remove @Default and @Nullable from the method parameter if they exist. */ @Override public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) { PsiElement element = descriptor.getPsiElement(); if (element == null) { return; } if (!(element instanceof PsiParameter)) { return; } PsiModifierList modifierList = ((PsiParameter) element).getModifierList(); PsiAnnotation gaeNullableAnnotation = modifierList.findAnnotation(GctConstants.APP_ENGINE_ANNOTATION_NULLABLE); if (gaeNullableAnnotation != null) { gaeNullableAnnotation.delete(); } PsiAnnotation javaxNullableAnnotation = modifierList.findAnnotation("javax.annotation.Nullable"); if (javaxNullableAnnotation != null) { javaxNullableAnnotation.delete(); } PsiAnnotation defaultValueAnnotation = modifierList.findAnnotation(GctConstants.APP_ENGINE_ANNOTATION_DEFAULT_VALUE); if (defaultValueAnnotation != null) { defaultValueAnnotation.delete(); } } }
/** * The default generation uses @java.lang.Override for some reason; * Let's clean that up */ void cleanOverrideAnnotation(PsiMethodMember member) { final PsiMethod[] ms = targetClass.findMethodsBySignature( member.getElement(), false); for (PsiMethod m : ms) { PsiModifierList modifierList = m.getModifierList(); PsiAnnotation annotation = modifierList.findAnnotation(Override.class.getName()); if (null != annotation) { annotation.delete(); modifierList.addAnnotation("Override"); } } }