void (int indentLevel, @NotNull StringBuilder buffer) { PsiElement parent = getParent(); PsiAnnotation[] annotations = getAnnotations(); boolean separateAnnotations = parent instanceof PsiClass || parent instanceof PsiMethod || parent instanceof PsiField || parent instanceof PsiJavaModule; for (PsiAnnotation annotation : annotations) { appendText(annotation, indentLevel, buffer, separateAnnotations ? NEXT_LINE : " "); } boolean isClass = parent instanceof PsiClass; boolean isInterface = isClass && ((PsiClass)parent).isInterface(); boolean isEnum = isClass && ((PsiClass)parent).isEnum(); boolean isInterfaceClass = isClass && parent.getParent() instanceof PsiClass && ((PsiClass)parent.getParent()).isInterface(); boolean isMethod = parent instanceof PsiMethod; boolean isInterfaceMethod = isMethod && parent.getParent() instanceof PsiClass && ((PsiClass)parent.getParent()).isInterface(); boolean isField = parent instanceof PsiField; boolean isInterfaceField = isField && parent.getParent() instanceof PsiClass && ((PsiClass)parent.getParent()).isInterface(); boolean isEnumConstant = parent instanceof PsiEnumConstant; if (hasModifierProperty(PsiModifier.PUBLIC) && !isInterfaceMethod && !isInterfaceField && !isInterfaceClass && !isEnumConstant) { buffer.append(PsiModifier.PUBLIC).append(' '); } if (hasModifierProperty(PsiModifier.PROTECTED)) { buffer.append(PsiModifier.PROTECTED).append(' '); } if (hasModifierProperty(PsiModifier.PRIVATE)) { buffer.append(PsiModifier.PRIVATE).append(' '); } if (hasModifierProperty(PsiModifier.STATIC) && !isInterfaceField && !isEnumConstant) { buffer.append(PsiModifier.STATIC).append(' '); } if (hasModifierProperty(PsiModifier.ABSTRACT) && !isInterface && !isInterfaceMethod) { buffer.append(PsiModifier.ABSTRACT).append(' '); } if (hasModifierProperty(PsiModifier.FINAL) && !isEnum && !isInterfaceField && !isEnumConstant) { buffer.append(PsiModifier.FINAL).append(' '); } if (hasModifierProperty(PsiModifier.SEALED)) { buffer.append(PsiModifier.SEALED).append(' '); } if (hasModifierProperty(PsiModifier.NATIVE)) { buffer.append(PsiModifier.NATIVE).append(' '); } if (hasModifierProperty(PsiModifier.SYNCHRONIZED)) { buffer.append(PsiModifier.SYNCHRONIZED).append(' '); } if (hasModifierProperty(PsiModifier.TRANSIENT)) { buffer.append(PsiModifier.TRANSIENT).append(' '); } if (hasModifierProperty(PsiModifier.VOLATILE)) { buffer.append(PsiModifier.VOLATILE).append(' '); } if (hasModifierProperty(PsiModifier.STRICTFP)) { buffer.append(PsiModifier.STRICTFP).append(' '); } if (hasModifierProperty(PsiModifier.DEFAULT)) { buffer.append(PsiModifier.DEFAULT).append(' '); } if (hasModifierProperty(PsiModifier.OPEN)) { buffer.append(PsiModifier.OPEN).append(' '); } if (hasModifierProperty(PsiModifier.TRANSITIVE)) { buffer.append(PsiModifier.TRANSITIVE).append(' '); } }