mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-05 08:06:56 +07:00
[Java. Code Formatting] Add check to TypeAnnotationUtil that language level is at least 8
IDEA-353192 GitOrigin-RevId: e8d2d8270dbc1c39300d5a2d55ef993e433ccdbc
This commit is contained in:
committed by
intellij-monorepo-bot
parent
7fe1e933e6
commit
41cf8f6fe3
@@ -6,7 +6,8 @@ public interface MyTestClass {
|
||||
}
|
||||
|
||||
public class MyRealTestClass implements MyTestClass {
|
||||
@NotNull String implementMe(String arg) {
|
||||
@NotNull
|
||||
String implementMe(String arg) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package org.example;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class Formatter {
|
||||
@NotNull @Nullable String breakLineBetweenAnnotations() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@NotNull String breakLineBetweenTypeAndAnnotations() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable <T> String breakLineBetweenTypeParameterAndAnnotation() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@NotNull <T> String breakLineMixed() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.example;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class Formatter {
|
||||
@NotNull
|
||||
@Nullable
|
||||
String breakLineBetweenAnnotations() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@NotNull
|
||||
String breakLineBetweenTypeAndAnnotations() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
<T> String breakLineBetweenTypeParameterAndAnnotation() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@NotNull
|
||||
<T> String breakLineMixed() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -6,9 +6,11 @@ import com.intellij.application.options.CodeStyle
|
||||
import com.intellij.lang.java.JavaLanguage
|
||||
import com.intellij.openapi.command.WriteCommandAction
|
||||
import com.intellij.openapi.roots.ModuleRootModificationUtil
|
||||
import com.intellij.pom.java.LanguageLevel
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings.WRAP_ALWAYS
|
||||
import com.intellij.testFramework.IdeaTestUtil
|
||||
import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor
|
||||
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase
|
||||
|
||||
@@ -22,6 +24,7 @@ class TypeAnnotationFormatterTest : LightJavaCodeInsightFixtureTestCase() {
|
||||
super.setUp()
|
||||
commonSettings.KEEP_LINE_BREAKS = false
|
||||
commonSettings.METHOD_ANNOTATION_WRAP = WRAP_ALWAYS
|
||||
IdeaTestUtil.setProjectLanguageLevel(myFixture.project, LanguageLevel.JDK_1_8)
|
||||
ModuleRootModificationUtil.updateModel(module, DefaultLightProjectDescriptor::addJetBrainsAnnotations)
|
||||
}
|
||||
|
||||
@@ -52,6 +55,11 @@ class TypeAnnotationFormatterTest : LightJavaCodeInsightFixtureTestCase() {
|
||||
doTest()
|
||||
}
|
||||
|
||||
fun testLowLanguageLevel() {
|
||||
IdeaTestUtil.setProjectLanguageLevel(myFixture.project, LanguageLevel.JDK_1_7)
|
||||
doTest()
|
||||
}
|
||||
|
||||
private fun doTest() {
|
||||
val testName = getTestName(false)
|
||||
myFixture.configureByFile("$testName.java")
|
||||
|
||||
Reference in New Issue
Block a user