mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Keep type annotation on the same line with type in method declaration
This commit is contained in:
+5
-1
@@ -173,8 +173,12 @@ public class JavaChildWrapArranger {
|
||||
|
||||
else if (nodeType == JavaElementType.MODIFIER_LIST) {
|
||||
if (childType == JavaElementType.ANNOTATION) {
|
||||
ASTNode prev = FormatterUtil.getPreviousNonWhitespaceSibling(child);
|
||||
if (prev instanceof PsiKeyword) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (isTypeAnnotationOrFalseIfDumb(child)) {
|
||||
ASTNode prev = FormatterUtil.getPreviousNonWhitespaceSibling(child);
|
||||
if (prev == null || prev.getElementType() != JavaElementType.ANNOTATION || isTypeAnnotationOrFalseIfDumb(prev)) {
|
||||
return Wrap.createWrap(WrapType.NONE, false);
|
||||
}
|
||||
|
||||
@@ -3293,5 +3293,41 @@ public void testSCR260() throws Exception {
|
||||
"};"
|
||||
);
|
||||
}
|
||||
|
||||
public void testKeepTypeAnnotationNearType() {
|
||||
doTextTest(
|
||||
"import java.lang.annotation.ElementType;\n" +
|
||||
"import java.lang.annotation.Retention;\n" +
|
||||
"import java.lang.annotation.RetentionPolicy;\n" +
|
||||
"import java.lang.annotation.Target;\n" +
|
||||
"\n" +
|
||||
"@Target(value=ElementType.TYPE_USE)\n" +
|
||||
"@Retention(value= RetentionPolicy.RUNTIME)\n" +
|
||||
"public @interface X {}\n" +
|
||||
"class Q {\n" +
|
||||
" @Override\n" +
|
||||
" public @X List<Object> objects() {\n" +
|
||||
" return null;\n" +
|
||||
" }\n" +
|
||||
"}",
|
||||
|
||||
"import java.lang.annotation.ElementType;\n" +
|
||||
"import java.lang.annotation.Retention;\n" +
|
||||
"import java.lang.annotation.RetentionPolicy;\n" +
|
||||
"import java.lang.annotation.Target;\n" +
|
||||
"\n" +
|
||||
"@Target(value = ElementType.TYPE_USE)\n" +
|
||||
"@Retention(value = RetentionPolicy.RUNTIME)\n" +
|
||||
"public @interface X {\n" +
|
||||
"}\n" +
|
||||
"\n" +
|
||||
"class Q {\n" +
|
||||
" @Override\n" +
|
||||
" public @X List<Object> objects() {\n" +
|
||||
" return null;\n" +
|
||||
" }\n" +
|
||||
"}"
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user