better formatting for inner classes and annotations on Classes, Methods and Fields

This commit is contained in:
unknown
2009-09-29 12:11:45 +04:00
parent 69909667b9
commit f15fb2e1b8
2 changed files with 14 additions and 1 deletions
@@ -358,6 +358,7 @@ public class ClsClassImpl extends ClsRepositoryPsiElement<PsiClassStub<?>> imple
PsiClass[] classes = getInnerClasses();
if (classes.length > 0) {
goNextLine(newIndentLevel, buffer);
goNextLine(newIndentLevel, buffer);
for (int i = 0; i < classes.length; i++) {
PsiClass aClass = classes[i];
@@ -62,11 +62,23 @@ public class ClsModifierListImpl extends ClsRepositoryPsiElement<PsiModifierList
throw new IncorrectOperationException(CAN_NOT_MODIFY_MESSAGE);
}
private boolean isAnnotationFormattingAllowed() {
final PsiElement element = getParent();
return element instanceof PsiClass
|| element instanceof PsiMethod
|| element instanceof PsiField;
}
public void appendMirrorText(final int indentLevel, final StringBuffer buffer) {
PsiAnnotation[] annotations = getAnnotations();
final boolean formattingAllowed = isAnnotationFormattingAllowed();
for (PsiAnnotation annotation : annotations) {
((ClsAnnotationImpl)annotation).appendMirrorText(indentLevel, buffer);
buffer.append(' ');
if (formattingAllowed) {
goNextLine(indentLevel, buffer);
} else {
buffer.append(' ');
}
}
PsiElement parent = getParent();