FIR IDE: Fix tests in idea-fir
This commit is contained in:
@@ -12,6 +12,8 @@ import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||
import java.io.File
|
||||
|
||||
abstract class AbstractFirPsiCheckerTest : AbstractPsiCheckerTest() {
|
||||
override fun isFirPlugin(): Boolean = true
|
||||
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
FirResolution.enabled = true
|
||||
|
||||
@@ -22,7 +22,6 @@ import org.jetbrains.kotlin.idea.jsonUtils.getString
|
||||
import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase
|
||||
import org.jetbrains.kotlin.idea.test.KotlinLightProjectDescriptor
|
||||
import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor
|
||||
import org.jetbrains.kotlin.idea.util.projectStructure.allModules
|
||||
import org.jetbrains.kotlin.psi.KtCallExpression
|
||||
import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
@@ -30,6 +29,8 @@ import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import java.io.File
|
||||
|
||||
abstract class AbstractFirLazyResolveTest : KotlinLightCodeInsightFixtureTestCase() {
|
||||
override fun isFirPlugin(): Boolean = true
|
||||
|
||||
override fun getProjectDescriptor(): LightProjectDescriptor {
|
||||
if (KotlinTestUtils.isAllFilesPresentTest(getTestName(false))) return super.getProjectDescriptor()
|
||||
val testFile = File(testDataPath, fileName())
|
||||
|
||||
+4
-2
@@ -1,11 +1,13 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.fir
|
||||
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.module.ModuleManager
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.psi.PsiFile
|
||||
import com.intellij.psi.PsiManager
|
||||
@@ -45,7 +47,6 @@ import org.jetbrains.kotlin.idea.multiplatform.setupMppProjectFromDirStructure
|
||||
import org.jetbrains.kotlin.idea.stubs.AbstractMultiModuleTest
|
||||
import org.jetbrains.kotlin.idea.test.ConfigLibraryUtil
|
||||
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
|
||||
import org.jetbrains.kotlin.idea.util.projectStructure.allModules
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||
import org.jetbrains.kotlin.test.TestJdkKind
|
||||
@@ -200,3 +201,4 @@ abstract class AbstractFirMultiModuleResolveTest : AbstractMultiModuleTest() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -8,6 +8,8 @@ package org.jetbrains.kotlin.idea.fir
|
||||
import org.jetbrains.kotlin.idea.AbstractResolveElementCacheTest
|
||||
|
||||
class FirResolveStateTest : AbstractResolveElementCacheTest() {
|
||||
override fun isFirPlugin(): Boolean = true
|
||||
|
||||
fun testSimpleStateCaching() {
|
||||
doTest {
|
||||
val firstStatement = statements[0]
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.fir
|
||||
|
||||
import com.intellij.openapi.module.ModuleManager
|
||||
import com.intellij.openapi.project.Project
|
||||
|
||||
internal fun Project.allModules() = ModuleManager.getInstance(this).modules.toList()
|
||||
+2
@@ -11,6 +11,8 @@ import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||
abstract class AbstractFirHighlightingTest : AbstractHighlightingTest() {
|
||||
override fun getDefaultProjectDescriptor() = ProjectDescriptorWithStdlibSources.INSTANCE
|
||||
|
||||
override fun isFirPlugin() = true
|
||||
|
||||
override fun checkHighlighting(fileText: String) {
|
||||
val checkInfos = !InTextDirectivesUtils.isDirectiveDefined(fileText, NO_CHECK_INFOS_PREFIX);
|
||||
|
||||
|
||||
+9
@@ -5,11 +5,20 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.resolve
|
||||
|
||||
import com.intellij.testFramework.LightProjectDescriptor
|
||||
import org.jetbrains.kotlin.idea.completion.test.configureWithExtraFile
|
||||
import org.jetbrains.kotlin.idea.fir.FirResolution
|
||||
import org.jetbrains.kotlin.idea.test.KotlinLightProjectDescriptor
|
||||
import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescriptor
|
||||
import org.jetbrains.kotlin.idea.test.ProjectDescriptorWithStdlibSources
|
||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||
|
||||
abstract class AbstractFirReferenceResolveTest : AbstractReferenceResolveTest() {
|
||||
override fun isFirPlugin(): Boolean = true
|
||||
|
||||
override fun getProjectDescriptor(): KotlinLightProjectDescriptor =
|
||||
KotlinWithJdkAndRuntimeLightProjectDescriptor.INSTANCE_FULL_JDK
|
||||
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
FirResolution.enabled = true
|
||||
|
||||
+12
-7
@@ -77,20 +77,25 @@ 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"
|
||||
// when done lazily
|
||||
UnusedSymbolInspection()
|
||||
|
||||
if (!isFirPlugin) {
|
||||
// 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"
|
||||
// when done lazily
|
||||
UnusedSymbolInspection()
|
||||
}
|
||||
|
||||
|
||||
runPostStartupActivitiesOnce(project)
|
||||
VfsRootAccess.allowRootAccess(project, KotlinTestUtils.getHomeDirectory())
|
||||
|
||||
editorTrackerProjectOpened(project)
|
||||
|
||||
invalidateLibraryCache(project)
|
||||
if (!isFirPlugin) {
|
||||
invalidateLibraryCache(project)
|
||||
}
|
||||
|
||||
if (captureExceptions) {
|
||||
LoggedErrorProcessor.setNewInstance(object : LoggedErrorProcessor() {
|
||||
|
||||
+6
-13
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.test;
|
||||
@@ -102,4 +91,8 @@ public abstract class KotlinLightCodeInsightFixtureTestCaseBase extends LightCod
|
||||
//noinspection Convert2MethodRef
|
||||
KotlinTestUtils.runTestWithThrowable(this, () -> super.runTest());
|
||||
}
|
||||
|
||||
protected boolean isFirPlugin() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+4
-1
@@ -14,12 +14,15 @@ import java.io.File
|
||||
import kotlin.reflect.full.findAnnotation
|
||||
|
||||
abstract class KotlinLightPlatformCodeInsightFixtureTestCase : LightPlatformCodeInsightFixtureTestCase() {
|
||||
protected open fun isFirPlugin(): Boolean = false
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
enableKotlinOfficialCodeStyle(project)
|
||||
runPostStartupActivitiesOnce(project)
|
||||
VfsRootAccess.allowRootAccess(KotlinTestUtils.getHomeDirectory())
|
||||
invalidateLibraryCache(project)
|
||||
if (!isFirPlugin()) {
|
||||
invalidateLibraryCache(project)
|
||||
}
|
||||
}
|
||||
|
||||
override fun tearDown() = runAll(
|
||||
|
||||
Reference in New Issue
Block a user