PsiMethod (@NotNull PsiClass aClass, @NotNull PsiMethod method, boolean toCopyJavaDoc, boolean insertOverrideIfPossible, @NotNull PsiMethod result) { PsiUtil.setModifierProperty(result, PsiModifier.ABSTRACT, aClass.isInterface() && method.hasModifierProperty(PsiModifier.ABSTRACT)); PsiUtil.setModifierProperty(result, PsiModifier.NATIVE, false); if (!toCopyJavaDoc){ deleteDocComment(result); } //method type params are not allowed when overriding from raw type final PsiTypeParameterList list = result.getTypeParameterList(); if (list != null) { final PsiClass containingClass = method.getContainingClass(); if (containingClass != null) { for (PsiClassType classType : aClass.getSuperTypes()) { if (InheritanceUtil.isInheritorOrSelf(PsiUtil.resolveClassInType(classType), containingClass, true) && classType.isRaw()) { list.replace(JavaPsiFacade.getElementFactory(aClass.getProject()).createTypeParameterList()); break; } } } } annotateOnOverrideImplement(result, aClass, method, insertOverrideIfPossible); if (JavaCodeStyleSettings.getInstance(aClass.getContainingFile()).REPEAT_SYNCHRONIZED && method.hasModifierProperty(PsiModifier.SYNCHRONIZED)) { result.getModifierList().setModifierProperty(PsiModifier.SYNCHRONIZED, true); } final PsiCodeBlock body = JavaPsiFacade.getElementFactory(method.getProject()).createCodeBlockFromText("{}", null); PsiCodeBlock oldBody = result.getBody(); if (oldBody != null) { oldBody.replace(body); } else { result.add(body); } setupMethodBody(result, method, aClass); // probably, it's better to reformat the whole method - it can go from other style sources final Project project = method.getProject(); CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(project); CommonCodeStyleSettings javaSettings = CodeStyle.getLanguageSettings(aClass.getContainingFile(), JavaLanguage.INSTANCE); boolean keepBreaks = javaSettings.KEEP_LINE_BREAKS; javaSettings.KEEP_LINE_BREAKS = false; try { result = (PsiMethod)JavaCodeStyleManager.getInstance(project).shortenClassReferences(result); result = (PsiMethod)codeStyleManager.reformat(result); } finally { javaSettings.KEEP_LINE_BREAKS = keepBreaks; } return result; }