mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[kotlin][k2] add tests for external annotations
^KT-62310 GitOrigin-RevId: 284171833e9264b028402d437fe8a62cbeb3623a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
764c8ca8fb
commit
2267a0a3a1
+16
@@ -0,0 +1,16 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.kotlin.idea.fir.externalAnnotations
|
||||
|
||||
import org.jetbrains.kotlin.idea.externalAnnotations.AbstractExternalAnnotationTest
|
||||
import org.jetbrains.kotlin.test.utils.IgnoreTests
|
||||
import java.io.File
|
||||
|
||||
abstract class AbstractK2ExternalAnnotationTest : AbstractExternalAnnotationTest() {
|
||||
override fun isFirPlugin(): Boolean = true
|
||||
|
||||
override fun doTest(kotlinFilePath: String) {
|
||||
val original = File(kotlinFilePath)
|
||||
super.doTest(IgnoreTests.getFirTestFile(original).path)
|
||||
IgnoreTests.cleanUpIdenticalFirTestFile(original)
|
||||
}
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
|
||||
package org.jetbrains.kotlin.idea.fir.externalAnnotations;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.idea.test.JUnit3RunnerWithInners;
|
||||
import org.jetbrains.kotlin.idea.test.KotlinTestUtils;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.jetbrains.kotlin.idea.base.test.TestRoot;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
/**
|
||||
* This class is generated by {@link org.jetbrains.kotlin.testGenerator.generator.TestGenerator}.
|
||||
* DO NOT MODIFY MANUALLY.
|
||||
*/
|
||||
@SuppressWarnings("all")
|
||||
@TestRoot("fir")
|
||||
@TestDataPath("$CONTENT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
@TestMetadata("../idea/tests/testData/externalAnnotations")
|
||||
public class K2ExternalAnnotationTestGenerated extends AbstractK2ExternalAnnotationTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("notNullMethod.kt")
|
||||
public void testNotNullMethod() throws Exception {
|
||||
runTest("../idea/tests/testData/externalAnnotations/notNullMethod.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullableField.kt")
|
||||
public void testNullableField() throws Exception {
|
||||
runTest("../idea/tests/testData/externalAnnotations/nullableField.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullableMethod.kt")
|
||||
public void testNullableMethod() throws Exception {
|
||||
runTest("../idea/tests/testData/externalAnnotations/nullableMethod.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullableMethodParameter.kt")
|
||||
public void testNullableMethodParameter() throws Exception {
|
||||
runTest("../idea/tests/testData/externalAnnotations/nullableMethodParameter.kt");
|
||||
}
|
||||
}
|
||||
+6
-4
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package org.jetbrains.kotlin.idea.externalAnnotations
|
||||
|
||||
import com.intellij.openapi.application.runWriteAction
|
||||
@@ -15,7 +15,7 @@ import org.jetbrains.kotlin.idea.test.KotlinWithJdkAndRuntimeLightProjectDescrip
|
||||
import org.jetbrains.kotlin.idea.test.runAll
|
||||
import java.io.File
|
||||
|
||||
abstract class AbstractExternalAnnotationTest: KotlinLightCodeInsightFixtureTestCase() {
|
||||
abstract class AbstractExternalAnnotationTest : KotlinLightCodeInsightFixtureTestCase() {
|
||||
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
@@ -39,7 +39,7 @@ abstract class AbstractExternalAnnotationTest: KotlinLightCodeInsightFixtureTest
|
||||
}
|
||||
}
|
||||
|
||||
protected fun doTest(kotlinFilePath: String) {
|
||||
protected open fun doTest(kotlinFilePath: String) {
|
||||
myFixture.configureByFiles(kotlinFilePath, dataFilePath(externalAnnotationsFile), dataFilePath(classWithExternalAnnotatedMembers))
|
||||
myFixture.checkHighlighting()
|
||||
}
|
||||
@@ -57,4 +57,6 @@ abstract class AbstractExternalAnnotationTest: KotlinLightCodeInsightFixtureTest
|
||||
private const val classWithExternalAnnotatedMembers = "ClassWithExternalAnnotatedMembers.java"
|
||||
private const val externalAnnotationsFile = "$externalAnnotationsPath/annotations.xml"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract class AbstractK1ExternalAnnotationTest : AbstractExternalAnnotationTest()
|
||||
+1
-1
@@ -18,7 +18,7 @@ import org.junit.runner.RunWith;
|
||||
@TestDataPath("$CONTENT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
@TestMetadata("testData/externalAnnotations")
|
||||
public class ExternalAnnotationTestGenerated extends AbstractExternalAnnotationTest {
|
||||
public class K1ExternalAnnotationTestGenerated extends AbstractK1ExternalAnnotationTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fun test() {
|
||||
val x = ClassWithExternalAnnotatedMembers()
|
||||
x.notNullMethod()<warning descr="[UNNECESSARY_SAFE_CALL] Unnecessary safe call on a non-null receiver of type 'kotlin.String'." textAttributesKey="WARNING_ATTRIBUTES">?.</warning>foo()
|
||||
}
|
||||
|
||||
fun String.foo() {
|
||||
|
||||
}
|
||||
@@ -1,4 +1,8 @@
|
||||
fun test() {
|
||||
val x = ClassWithExternalAnnotatedMembers()
|
||||
x.notNullMethod()<warning descr="[UNNECESSARY_SAFE_CALL] Unnecessary safe call on a non-null receiver of type String!">?.</warning><warning descr="[DEPRECATION] 'toLowerCase(): String' is deprecated. Use lowercase() instead.">toLowerCase</warning>()
|
||||
}
|
||||
x.notNullMethod()<warning descr="[UNNECESSARY_SAFE_CALL] Unnecessary safe call on a non-null receiver of type String!">?.</warning>foo()
|
||||
}
|
||||
|
||||
fun String.foo() {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
fun test() {
|
||||
val x = ClassWithExternalAnnotatedMembers()
|
||||
val y: String = <error descr="[INITIALIZER_TYPE_MISMATCH] Initializer type mismatch: expected 'kotlin.String', actual 'kotlin.String?'." textAttributesKey="ERRORS_ATTRIBUTES">x.nullableField</error>
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
@Suppress("UNUSED_VARIABLE")
|
||||
fun test() {
|
||||
val x = ClassWithExternalAnnotatedMembers()
|
||||
val y: String = <error descr="[INITIALIZER_TYPE_MISMATCH] Initializer type mismatch: expected 'kotlin.String', actual 'kotlin.String?'." textAttributesKey="ERRORS_ATTRIBUTES"><error descr="[TYPE_MISMATCH] Type mismatch: inferred type is 'kotlin.String?', but 'kotlin.String' was expected." textAttributesKey="ERRORS_ATTRIBUTES">x.nullableMethod()</error></error>
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
fun test() {
|
||||
val x = ClassWithExternalAnnotatedMembers()
|
||||
x.methodWithNotNullParameter(<error descr="[NULL_FOR_NONNULL_TYPE] Null cannot be a value of a non-null type 'kotlin.Int'." textAttributesKey="ERRORS_ATTRIBUTES">null</error>)
|
||||
}
|
||||
+3
-2
@@ -65,6 +65,7 @@ import org.jetbrains.kotlin.idea.editor.backspaceHandler.AbstractBackspaceHandle
|
||||
import org.jetbrains.kotlin.idea.editor.commenter.AbstractKotlinCommenterTest
|
||||
import org.jetbrains.kotlin.idea.editor.quickDoc.AbstractQuickDocProviderTest
|
||||
import org.jetbrains.kotlin.idea.externalAnnotations.AbstractExternalAnnotationTest
|
||||
import org.jetbrains.kotlin.idea.externalAnnotations.AbstractK1ExternalAnnotationTest
|
||||
import org.jetbrains.kotlin.idea.folding.AbstractKotlinFoldingTest
|
||||
import org.jetbrains.kotlin.idea.hierarchy.AbstractHierarchyTest
|
||||
import org.jetbrains.kotlin.idea.hierarchy.AbstractHierarchyWithLibTest
|
||||
@@ -461,8 +462,8 @@ private fun assembleWorkspace(): TWorkspace = workspace {
|
||||
model("search/annotations")
|
||||
}
|
||||
|
||||
testClass<AbstractExternalAnnotationTest> {
|
||||
model("externalAnnotations")
|
||||
testClass<AbstractK1ExternalAnnotationTest> {
|
||||
model("externalAnnotations", pattern = KT_WITHOUT_DOTS)
|
||||
}
|
||||
|
||||
testClass<AbstractQuickFixMultiFileTest> {
|
||||
|
||||
+5
@@ -19,6 +19,7 @@ import org.jetbrains.kotlin.idea.fir.completion.test.handlers.AbstractHighLevelJ
|
||||
import org.jetbrains.kotlin.idea.fir.completion.test.handlers.AbstractK2CompletionCharFilterTest
|
||||
import org.jetbrains.kotlin.idea.fir.completion.wheigher.AbstractHighLevelWeigherTest
|
||||
import org.jetbrains.kotlin.idea.fir.documentation.AbstractFirQuickDocTest
|
||||
import org.jetbrains.kotlin.idea.fir.externalAnnotations.AbstractK2ExternalAnnotationTest
|
||||
import org.jetbrains.kotlin.idea.fir.findUsages.AbstractFindUsagesFirTest
|
||||
import org.jetbrains.kotlin.idea.fir.findUsages.AbstractFindUsagesWithDisableComponentSearchFirTest
|
||||
import org.jetbrains.kotlin.idea.fir.findUsages.AbstractKotlinFindUsagesWithLibraryFirTest
|
||||
@@ -223,6 +224,10 @@ private fun assembleWorkspace(): TWorkspace = workspace {
|
||||
testClass<AbstractK2BytecodeToolWindowTest> {
|
||||
model("internal/toolWindow", isRecursive = false, pattern = DIRECTORY, testMethodName = "doTestWithIr")
|
||||
}
|
||||
|
||||
testClass<AbstractK2ExternalAnnotationTest> {
|
||||
model("externalAnnotations", pattern = KT_WITHOUT_DOTS)
|
||||
}
|
||||
}
|
||||
|
||||
testGroup("fir", testDataPath = "../completion/testData") {
|
||||
|
||||
Reference in New Issue
Block a user