mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[Java. Code Formatting] Add tests for blank lines around annotated/non-annotated fields
IDEA-110857 GitOrigin-RevId: 84dcb160fb09831989b1defee8ee83cace3beb45
This commit is contained in:
committed by
intellij-monorepo-bot
parent
760f2fcb3b
commit
37c6900424
+16
@@ -0,0 +1,16 @@
|
||||
package org.example;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ClassWithAnnotations {
|
||||
public boolean simpleField1 = true;
|
||||
public boolean simpleField2 = true;
|
||||
@NotNull
|
||||
public Integer annotatedField1 = 2;
|
||||
public boolean simpleField3 = true;
|
||||
@NotNull
|
||||
public Integer annotatedField2 = 2;
|
||||
public boolean simpleField4 = true;
|
||||
@NotNull
|
||||
private Integer annotatedField3 = 2;
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
package org.example;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ClassWithAnnotations {
|
||||
public boolean simpleField1 = true;
|
||||
|
||||
public boolean simpleField2 = true;
|
||||
|
||||
|
||||
@NotNull
|
||||
public Integer annotatedField1 = 2;
|
||||
|
||||
public boolean simpleField3 = true;
|
||||
|
||||
|
||||
@NotNull
|
||||
public Integer annotatedField2 = 2;
|
||||
|
||||
public boolean simpleField4 = true;
|
||||
|
||||
|
||||
@NotNull
|
||||
private Integer annotatedField3 = 2;
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package org.example;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ClassWithAnnotations {
|
||||
public final Boolean b = false;
|
||||
public final Boolean a = false;
|
||||
@NotNull
|
||||
public Boolean d = false;
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package org.example;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ClassWithAnnotations {
|
||||
public final Boolean b = false;
|
||||
public final Boolean a = false;
|
||||
|
||||
|
||||
@NotNull
|
||||
public Boolean d = false;
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
package org.example;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ClassWithAnnotations {
|
||||
public final boolean simpleField1 = true;
|
||||
private @Nullable
|
||||
final Integer annotatedField1 = 10;
|
||||
public Boolean simpleField2 = false;
|
||||
public @NotNull Integer annotatedField2 = 1;
|
||||
private Boolean simpleField3 = false;
|
||||
@NotNull
|
||||
private Integer getAnnotatedField3 = 2;
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package org.example;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class ClassWithAnnotations {
|
||||
public final boolean simpleField1 = true;
|
||||
|
||||
|
||||
private @Nullable
|
||||
final Integer annotatedField1 = 10;
|
||||
public Boolean simpleField2 = false;
|
||||
|
||||
|
||||
public @NotNull Integer annotatedField2 = 1;
|
||||
private Boolean simpleField3 = false;
|
||||
|
||||
|
||||
@NotNull
|
||||
private Integer getAnnotatedField3 = 2;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package org.example;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ClassWithAnnotations {
|
||||
public boolean simpleField1 = true;
|
||||
public boolean simpleField2 = true;
|
||||
@NotNull
|
||||
public Integer annotatedField1 = 2;
|
||||
public boolean simpleField3 = true;
|
||||
@NotNull
|
||||
public Integer annotatedField2 = 2;
|
||||
public boolean simpleField4 = true;
|
||||
@NotNull
|
||||
private Integer annotatedField3 = 2;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package org.example;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ClassWithAnnotations {
|
||||
public boolean simpleField1 = true;
|
||||
public boolean simpleField2 = true;
|
||||
|
||||
|
||||
@NotNull
|
||||
public Integer annotatedField1 = 2;
|
||||
public boolean simpleField3 = true;
|
||||
|
||||
|
||||
@NotNull
|
||||
public Integer annotatedField2 = 2;
|
||||
public boolean simpleField4 = true;
|
||||
|
||||
|
||||
@NotNull
|
||||
private Integer annotatedField3 = 2;
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package org.example;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ClassWithAnnotations {
|
||||
@NotNull
|
||||
public static Integer STATIC_FIELD = -1;
|
||||
@NotNull
|
||||
public Boolean a = true;
|
||||
@NotNull
|
||||
public Boolean d = false;
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
package org.example;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ClassWithAnnotations {
|
||||
@NotNull
|
||||
public static Integer STATIC_FIELD = -1;
|
||||
|
||||
|
||||
@NotNull
|
||||
public Boolean a = true;
|
||||
|
||||
|
||||
@NotNull
|
||||
public Boolean d = false;
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package org.example;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
class ClassWithAnnotations {
|
||||
@NotNull
|
||||
public Boolean d = false;
|
||||
}
|
||||
|
||||
class ClassWithoutAnnotations {
|
||||
public Boolean a = false;
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package org.example;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
class ClassWithAnnotations {
|
||||
@NotNull
|
||||
public Boolean d = false;
|
||||
}
|
||||
|
||||
class ClassWithoutAnnotations {
|
||||
public Boolean a = false;
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.psi.formatter.java
|
||||
|
||||
import com.intellij.lang.java.JavaLanguage
|
||||
|
||||
class JavaFormatterBlankLinesAroundFieldTest : JavaFormatterTestCase() {
|
||||
override fun getBasePath(): String = "psi/formatter/blankLinesAroundField"
|
||||
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
customJavaSettings.BLANK_LINES_AROUND_FIELD_WITH_ANNOTATIONS = 2
|
||||
getSettings(JavaLanguage.INSTANCE).BLANK_LINES_AROUND_FIELD = 0
|
||||
}
|
||||
|
||||
fun testAnnotatedFieldAfterNonAnnotatedFields() = doTest()
|
||||
|
||||
fun testNoBlankLinesAfterLBraceAndBeforeRBrace() = doTest()
|
||||
|
||||
fun testMultipleAnnotatedFields() = doTest()
|
||||
|
||||
fun testDifferentAnnotationLocation() = doTest()
|
||||
|
||||
fun testMixed() = doTest()
|
||||
|
||||
fun testAnnotatedAndNonAnnotatedFieldsRespectEachOther() {
|
||||
getSettings(JavaLanguage.INSTANCE).BLANK_LINES_AROUND_FIELD = 1
|
||||
doTest()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user