tests: apply official code style
#KT-38632 Fixed
This commit is contained in:
+13
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2000-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -40,6 +40,7 @@ import org.jetbrains.kotlin.idea.KotlinFileType
|
||||
import org.jetbrains.kotlin.idea.compiler.configuration.KotlinCommonCompilerArgumentsHolder
|
||||
import org.jetbrains.kotlin.idea.compiler.configuration.KotlinCompilerSettings
|
||||
import org.jetbrains.kotlin.idea.facet.*
|
||||
import org.jetbrains.kotlin.idea.formatter.KotlinStyleGuideCodeStyle
|
||||
import org.jetbrains.kotlin.idea.inspections.UnusedSymbolInspection
|
||||
import org.jetbrains.kotlin.idea.test.CompilerTestDirectives.COMPILER_ARGUMENTS_DIRECTIVE
|
||||
import org.jetbrains.kotlin.idea.test.CompilerTestDirectives.JVM_TARGET_DIRECTIVE
|
||||
@@ -76,6 +77,8 @@ abstract class KotlinLightCodeInsightFixtureTestCase : KotlinLightCodeInsightFix
|
||||
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
|
||||
enableKotlinOfficialCodeStyle(project)
|
||||
// We do it here to avoid possible initialization problems
|
||||
// UnusedSymbolInspection() calls IDEA UnusedDeclarationInspection() in static initializer,
|
||||
// which in turn registers some extensions provoking "modifications aren't allowed during highlighting"
|
||||
@@ -101,7 +104,7 @@ abstract class KotlinLightCodeInsightFixtureTestCase : KotlinLightCodeInsightFix
|
||||
|
||||
override fun tearDown() {
|
||||
LoggedErrorProcessor.restoreDefaultProcessor()
|
||||
|
||||
disableKotlinOfficialCodeStyle(project)
|
||||
super.tearDown()
|
||||
|
||||
if (exceptions.isNotEmpty()) {
|
||||
@@ -312,6 +315,14 @@ fun configureCodeStyleAndRun(
|
||||
}
|
||||
}
|
||||
|
||||
fun enableKotlinOfficialCodeStyle(project: Project) {
|
||||
KotlinStyleGuideCodeStyle.apply(CodeStyle.getSettings(project))
|
||||
}
|
||||
|
||||
fun disableKotlinOfficialCodeStyle(project: Project) {
|
||||
CodeStyle.getSettings(project)
|
||||
}
|
||||
|
||||
private fun rollbackCompilerOptions(project: Project, module: Module, removeFacet: Boolean) {
|
||||
KotlinCompilerSettings.getInstance(project).update { this.additionalArguments = DEFAULT_ADDITIONAL_ARGUMENTS }
|
||||
KotlinCommonCompilerArgumentsHolder.getInstance(project).update { this.languageVersion = LanguageVersion.LATEST_STABLE.versionString }
|
||||
|
||||
+3
-1
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -17,12 +17,14 @@ import kotlin.reflect.full.findAnnotation
|
||||
abstract class KotlinLightPlatformCodeInsightFixtureTestCase : LightPlatformCodeInsightFixtureTestCase() {
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
enableKotlinOfficialCodeStyle(project)
|
||||
(StartupManager.getInstance(project) as StartupManagerImpl).runPostStartupActivities()
|
||||
VfsRootAccess.allowRootAccess(KotlinTestUtils.getHomeDirectory())
|
||||
invalidateLibraryCache(project)
|
||||
}
|
||||
|
||||
override fun tearDown() {
|
||||
disableKotlinOfficialCodeStyle(project)
|
||||
VfsRootAccess.disallowRootAccess(KotlinTestUtils.getHomeDirectory())
|
||||
|
||||
super.tearDown()
|
||||
|
||||
+10
@@ -13,4 +13,14 @@ import com.intellij.testFramework.LightPlatformCodeInsightTestCase
|
||||
abstract class KotlinLightPlatformCodeInsightTestCase : LightPlatformCodeInsightTestCase() {
|
||||
protected inline val project_: Project get() = project
|
||||
protected inline val editor_: Editor get() = editor
|
||||
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
enableKotlinOfficialCodeStyle(project_)
|
||||
}
|
||||
|
||||
override fun tearDown() {
|
||||
disableKotlinOfficialCodeStyle(project_)
|
||||
super.tearDown()
|
||||
}
|
||||
}
|
||||
+9
@@ -15,4 +15,13 @@ abstract class KotlinLightPlatformCodeInsightTestCase : LightPlatformCodeInsight
|
||||
protected inline val project_: Project get() = LightPlatformTestCase.getProject()
|
||||
protected inline val editor_: Editor get() = LightPlatformCodeInsightTestCase.getEditor()
|
||||
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
enableKotlinOfficialCodeStyle(project_)
|
||||
}
|
||||
|
||||
override fun tearDown() {
|
||||
disableKotlinOfficialCodeStyle(project_)
|
||||
super.tearDown()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user