[FIR] add tests on external annotations
Tests are excluded in COMPILED_JAVA mode because in this mode external annotations are not present at all ^KT-62310
This commit is contained in:
committed by
Space Team
parent
e452113a7a
commit
2cac922cd0
+12
@@ -136,6 +136,18 @@ public class Fe10IdeNormalAnalysisSourceModuleSymbolByReferenceTestGenerated ext
|
||||
runTest("analysis/analysis-api/testData/symbols/symbolByReference/javaMethod.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaMethodWithExternalNotNullAnnotation.kt")
|
||||
public void testJavaMethodWithExternalNotNullAnnotation() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/symbols/symbolByReference/javaMethodWithExternalNotNullAnnotation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaMethodWithNotNullAnnotation.kt")
|
||||
public void testJavaMethodWithNotNullAnnotation() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/symbols/symbolByReference/javaMethodWithNotNullAnnotation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaStaticField.kt")
|
||||
public void testJavaStaticField() throws Exception {
|
||||
|
||||
+12
@@ -136,6 +136,18 @@ public class FirIdeNormalAnalysisSourceModuleSymbolByReferenceTestGenerated exte
|
||||
runTest("analysis/analysis-api/testData/symbols/symbolByReference/javaMethod.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaMethodWithExternalNotNullAnnotation.kt")
|
||||
public void testJavaMethodWithExternalNotNullAnnotation() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/symbols/symbolByReference/javaMethodWithExternalNotNullAnnotation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaMethodWithNotNullAnnotation.kt")
|
||||
public void testJavaMethodWithNotNullAnnotation() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/symbols/symbolByReference/javaMethodWithNotNullAnnotation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaStaticField.kt")
|
||||
public void testJavaStaticField() throws Exception {
|
||||
|
||||
+12
@@ -136,6 +136,18 @@ public class FirStandaloneNormalAnalysisSourceModuleSymbolByReferenceTestGenerat
|
||||
runTest("analysis/analysis-api/testData/symbols/symbolByReference/javaMethod.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaMethodWithExternalNotNullAnnotation.kt")
|
||||
public void testJavaMethodWithExternalNotNullAnnotation() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/symbols/symbolByReference/javaMethodWithExternalNotNullAnnotation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaMethodWithNotNullAnnotation.kt")
|
||||
public void testJavaMethodWithNotNullAnnotation() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/symbols/symbolByReference/javaMethodWithNotNullAnnotation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("javaStaticField.kt")
|
||||
public void testJavaStaticField() throws Exception {
|
||||
|
||||
+6
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2023 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.
|
||||
*/
|
||||
|
||||
@@ -16,10 +16,12 @@ import org.jetbrains.kotlin.analysis.test.framework.test.configurators.AnalysisA
|
||||
import org.jetbrains.kotlin.analysis.test.framework.test.configurators.AnalysisApiTestServiceRegistrar
|
||||
import org.jetbrains.kotlin.analysis.test.framework.test.configurators.FrontendKind
|
||||
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
|
||||
import org.jetbrains.kotlin.test.preprocessors.ExternalAnnotationsSourcePreprocessor
|
||||
import org.jetbrains.kotlin.test.services.TestModuleStructure
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.services.configuration.ExternalAnnotationsEnvironmentConfigurator
|
||||
|
||||
public object StandaloneModeConfigurator : AnalysisApiTestConfigurator() {
|
||||
object StandaloneModeConfigurator : AnalysisApiTestConfigurator() {
|
||||
override val analyseInDependentSession: Boolean get() = false
|
||||
override val frontendKind: FrontendKind get() = FrontendKind.Fir
|
||||
|
||||
@@ -31,6 +33,8 @@ public object StandaloneModeConfigurator : AnalysisApiTestConfigurator() {
|
||||
useAdditionalService<KtModuleFactory> { KtSourceModuleFactory() }
|
||||
useDirectives(SealedClassesInheritorsCaclulatorPreAnalysisHandler.Directives)
|
||||
usePreAnalysisHandlers(::SealedClassesInheritorsCaclulatorPreAnalysisHandler)
|
||||
useConfigurators(::ExternalAnnotationsEnvironmentConfigurator)
|
||||
useSourcePreprocessor(::ExternalAnnotationsSourcePreprocessor)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
open fun foo(): kotlin.String!
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
KtFunctionSymbol:
|
||||
annotationsList: []
|
||||
callableIdIfNonLocal: /JavaClass.foo
|
||||
contextReceivers: []
|
||||
contractEffects: []
|
||||
hasStableParameterNames: false
|
||||
isActual: false
|
||||
isBuiltinFunctionInvoke: false
|
||||
isExpect: false
|
||||
isExtension: false
|
||||
isExternal: false
|
||||
isInfix: false
|
||||
isInline: false
|
||||
isOperator: false
|
||||
isOverride: false
|
||||
isStatic: false
|
||||
isSuspend: false
|
||||
modality: OPEN
|
||||
name: foo
|
||||
origin: JAVA
|
||||
receiverParameter: null
|
||||
returnType: KtFlexibleType:
|
||||
annotationsList: []
|
||||
type: kotlin/String!
|
||||
symbolKind: CLASS_MEMBER
|
||||
typeParameters: []
|
||||
valueParameters: []
|
||||
visibility: Public
|
||||
getDispatchReceiver(): KtUsualClassType:
|
||||
annotationsList: []
|
||||
ownTypeArguments: []
|
||||
type: JavaClass
|
||||
getContainingModule: KtSourceModule "Sources of main"
|
||||
deprecationStatus: null
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
// FILE: main.kt
|
||||
fun some() {
|
||||
JavaClass().f<caret>oo();
|
||||
}
|
||||
// FILE: JavaClass.java
|
||||
public class JavaClass {
|
||||
public String foo() {};
|
||||
}
|
||||
// FILE: annotations.xml
|
||||
<root>
|
||||
<item name='JavaClass java.lang.String foo()'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
</root>
|
||||
+1
@@ -0,0 +1 @@
|
||||
open fun foo(): kotlin.String
|
||||
analysis/analysis-api/testData/symbols/symbolByReference/javaMethodWithExternalNotNullAnnotation.txt
Vendored
+38
@@ -0,0 +1,38 @@
|
||||
KtFunctionSymbol:
|
||||
annotationsList: [
|
||||
org/jetbrains/annotations/NotNull()
|
||||
psi: null
|
||||
]
|
||||
callableIdIfNonLocal: /JavaClass.foo
|
||||
contextReceivers: []
|
||||
contractEffects: []
|
||||
hasStableParameterNames: false
|
||||
isActual: false
|
||||
isBuiltinFunctionInvoke: false
|
||||
isExpect: false
|
||||
isExtension: false
|
||||
isExternal: false
|
||||
isInfix: false
|
||||
isInline: false
|
||||
isOperator: false
|
||||
isOverride: false
|
||||
isStatic: false
|
||||
isSuspend: false
|
||||
modality: OPEN
|
||||
name: foo
|
||||
origin: JAVA
|
||||
receiverParameter: null
|
||||
returnType: KtUsualClassType:
|
||||
annotationsList: []
|
||||
ownTypeArguments: []
|
||||
type: @EnhancedNullability kotlin/String
|
||||
symbolKind: CLASS_MEMBER
|
||||
typeParameters: []
|
||||
valueParameters: []
|
||||
visibility: Public
|
||||
getDispatchReceiver(): KtUsualClassType:
|
||||
annotationsList: []
|
||||
ownTypeArguments: []
|
||||
type: JavaClass
|
||||
getContainingModule: KtSourceModule "Sources of main"
|
||||
deprecationStatus: null
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
KtFunctionSymbol:
|
||||
annotationsList: [
|
||||
org/jetbrains/annotations/NotNull()
|
||||
psi: null
|
||||
]
|
||||
callableIdIfNonLocal: /JavaClass.foo
|
||||
contextReceivers: []
|
||||
contractEffects: []
|
||||
hasStableParameterNames: false
|
||||
isActual: false
|
||||
isBuiltinFunctionInvoke: false
|
||||
isExpect: false
|
||||
isExtension: false
|
||||
isExternal: false
|
||||
isInfix: false
|
||||
isInline: false
|
||||
isOperator: false
|
||||
isOverride: false
|
||||
isStatic: false
|
||||
isSuspend: false
|
||||
modality: OPEN
|
||||
name: foo
|
||||
origin: JAVA
|
||||
receiverParameter: null
|
||||
returnType: KtUsualClassType:
|
||||
annotationsList: []
|
||||
ownTypeArguments: []
|
||||
type: kotlin/String
|
||||
symbolKind: CLASS_MEMBER
|
||||
typeParameters: []
|
||||
valueParameters: []
|
||||
visibility: Public
|
||||
getDispatchReceiver(): KtUsualClassType:
|
||||
annotationsList: []
|
||||
ownTypeArguments: []
|
||||
type: JavaClass
|
||||
getContainingModule: KtSourceModule "Sources of main"
|
||||
deprecationStatus: null
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
// FILE: main.kt
|
||||
fun some() {
|
||||
JavaClass().f<caret>oo();
|
||||
}
|
||||
// FILE: JavaClass.java
|
||||
import import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class JavaClass {
|
||||
@NotNull
|
||||
public String foo() {};
|
||||
}
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
open fun foo(): kotlin.String
|
||||
Vendored
+38
@@ -0,0 +1,38 @@
|
||||
KtFunctionSymbol:
|
||||
annotationsList: [
|
||||
org/jetbrains/annotations/NotNull()
|
||||
psi: null
|
||||
]
|
||||
callableIdIfNonLocal: /JavaClass.foo
|
||||
contextReceivers: []
|
||||
contractEffects: []
|
||||
hasStableParameterNames: false
|
||||
isActual: false
|
||||
isBuiltinFunctionInvoke: false
|
||||
isExpect: false
|
||||
isExtension: false
|
||||
isExternal: false
|
||||
isInfix: false
|
||||
isInline: false
|
||||
isOperator: false
|
||||
isOverride: false
|
||||
isStatic: false
|
||||
isSuspend: false
|
||||
modality: OPEN
|
||||
name: foo
|
||||
origin: JAVA
|
||||
receiverParameter: null
|
||||
returnType: KtUsualClassType:
|
||||
annotationsList: []
|
||||
ownTypeArguments: []
|
||||
type: @EnhancedNullability kotlin/String
|
||||
symbolKind: CLASS_MEMBER
|
||||
typeParameters: []
|
||||
valueParameters: []
|
||||
visibility: Public
|
||||
getDispatchReceiver(): KtUsualClassType:
|
||||
annotationsList: []
|
||||
ownTypeArguments: []
|
||||
type: JavaClass
|
||||
getContainingModule: KtSourceModule "Sources of main"
|
||||
deprecationStatus: null
|
||||
+3
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2023 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.
|
||||
*/
|
||||
|
||||
@@ -183,7 +183,7 @@ object TestModuleStructureFactory {
|
||||
fun createSourcePsiFiles(
|
||||
testModule: TestModule,
|
||||
testServices: TestServices,
|
||||
project: Project
|
||||
project: Project,
|
||||
): List<PsiFile> {
|
||||
return testModule.files.map { testFile ->
|
||||
when {
|
||||
@@ -192,7 +192,7 @@ object TestModuleStructureFactory {
|
||||
KtTestUtil.createFile(testFile.name, fileText, project)
|
||||
}
|
||||
|
||||
testFile.isJavaFile -> {
|
||||
testFile.isJavaFile || testFile.isExternalAnnotation -> {
|
||||
val filePath = testServices.sourceFileProvider.getRealFileForSourceFile(testFile)
|
||||
val virtualFile =
|
||||
testServices.environmentManager.getApplicationEnvironment().localFileSystem.findFileByIoFile(filePath)
|
||||
@@ -205,7 +205,5 @@ object TestModuleStructureFactory {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
// SKIP_WHEN_OUT_OF_CONTENT_ROOT
|
||||
// FILE: usage.kt
|
||||
<expr>
|
||||
fun test() = ClassWithExternalAnnotatedMembers().externalNotNullMethod()
|
||||
</expr>
|
||||
|
||||
// FILE: ClassWithExternalAnnotatedMembers.java
|
||||
public class ClassWithExternalAnnotatedMembers {
|
||||
public String externalNotNullMethod() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: annotations.xml
|
||||
<root>
|
||||
<item name='ClassWithExternalAnnotatedMembers java.lang.String externalNotNullMethod()'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
</root>
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
KT element: KtNamedFunction
|
||||
FIR element: FirSimpleFunctionImpl
|
||||
FIR source kind: KtRealSourceElementKind
|
||||
|
||||
FIR element rendered:
|
||||
public final [ResolvedTo(BODY_RESOLVE)] fun test(): R|kotlin/String| {
|
||||
^test R|/ClassWithExternalAnnotatedMembers.ClassWithExternalAnnotatedMembers|().R|/ClassWithExternalAnnotatedMembers.externalNotNullMethod|()
|
||||
}
|
||||
|
||||
FIR FILE:
|
||||
FILE: [ResolvedTo(IMPORTS)] usage.kt
|
||||
public final [ResolvedTo(BODY_RESOLVE)] fun test(): R|kotlin/String| {
|
||||
^test R|/ClassWithExternalAnnotatedMembers.ClassWithExternalAnnotatedMembers|().R|/ClassWithExternalAnnotatedMembers.externalNotNullMethod|()
|
||||
}
|
||||
Vendored
+15
@@ -0,0 +1,15 @@
|
||||
// SKIP_WHEN_OUT_OF_CONTENT_ROOT
|
||||
// FILE: usage.kt
|
||||
<expr>
|
||||
fun test() = ClassWithExternalAnnotatedMembers().notNullMethod()
|
||||
</expr>
|
||||
|
||||
// FILE: ClassWithExternalAnnotatedMembers.java
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ClassWithExternalAnnotatedMembers {
|
||||
@NotNull
|
||||
public String notNullMethod() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
Vendored
+14
@@ -0,0 +1,14 @@
|
||||
KT element: KtNamedFunction
|
||||
FIR element: FirSimpleFunctionImpl
|
||||
FIR source kind: KtRealSourceElementKind
|
||||
|
||||
FIR element rendered:
|
||||
public final [ResolvedTo(BODY_RESOLVE)] fun test(): R|kotlin/String| {
|
||||
^test R|/ClassWithExternalAnnotatedMembers.ClassWithExternalAnnotatedMembers|().R|/ClassWithExternalAnnotatedMembers.notNullMethod|()
|
||||
}
|
||||
|
||||
FIR FILE:
|
||||
FILE: [ResolvedTo(IMPORTS)] usage.kt
|
||||
public final [ResolvedTo(BODY_RESOLVE)] fun test(): R|kotlin/String| {
|
||||
^test R|/ClassWithExternalAnnotatedMembers.ClassWithExternalAnnotatedMembers|().R|/ClassWithExternalAnnotatedMembers.notNullMethod|()
|
||||
}
|
||||
+12
@@ -1163,6 +1163,12 @@ public class OutOfContentRootGetOrBuildFirTestGenerated extends AbstractOutOfCon
|
||||
runTest("analysis/low-level-api-fir/testData/getOrBuildFir/wholeDeclaration/enumEntry.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("externalJavaAnnotation.kt")
|
||||
public void testExternalJavaAnnotation() throws Exception {
|
||||
runTest("analysis/low-level-api-fir/testData/getOrBuildFir/wholeDeclaration/externalJavaAnnotation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionTypeParemeter.kt")
|
||||
public void testFunctionTypeParemeter() throws Exception {
|
||||
@@ -1223,6 +1229,12 @@ public class OutOfContentRootGetOrBuildFirTestGenerated extends AbstractOutOfCon
|
||||
runTest("analysis/low-level-api-fir/testData/getOrBuildFir/wholeDeclaration/nestedClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("notNullJavaAnnotation.kt")
|
||||
public void testNotNullJavaAnnotation() throws Exception {
|
||||
runTest("analysis/low-level-api-fir/testData/getOrBuildFir/wholeDeclaration/notNullJavaAnnotation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("primaryConstructorValValueParameter.kt")
|
||||
public void testPrimaryConstructorValValueParameter() throws Exception {
|
||||
|
||||
+12
@@ -1163,6 +1163,12 @@ public class SourceGetOrBuildFirTestGenerated extends AbstractSourceGetOrBuildFi
|
||||
runTest("analysis/low-level-api-fir/testData/getOrBuildFir/wholeDeclaration/enumEntry.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("externalJavaAnnotation.kt")
|
||||
public void testExternalJavaAnnotation() throws Exception {
|
||||
runTest("analysis/low-level-api-fir/testData/getOrBuildFir/wholeDeclaration/externalJavaAnnotation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("functionTypeParemeter.kt")
|
||||
public void testFunctionTypeParemeter() throws Exception {
|
||||
@@ -1223,6 +1229,12 @@ public class SourceGetOrBuildFirTestGenerated extends AbstractSourceGetOrBuildFi
|
||||
runTest("analysis/low-level-api-fir/testData/getOrBuildFir/wholeDeclaration/nestedClass.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("notNullJavaAnnotation.kt")
|
||||
public void testNotNullJavaAnnotation() throws Exception {
|
||||
runTest("analysis/low-level-api-fir/testData/getOrBuildFir/wholeDeclaration/notNullJavaAnnotation.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("primaryConstructorValValueParameter.kt")
|
||||
public void testPrimaryConstructorValValueParameter() throws Exception {
|
||||
|
||||
+5
-2
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2023 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.
|
||||
*/
|
||||
|
||||
@@ -18,8 +18,10 @@ import org.jetbrains.kotlin.analysis.test.framework.test.configurators.AnalysisA
|
||||
import org.jetbrains.kotlin.analysis.test.framework.test.configurators.AnalysisApiTestServiceRegistrar
|
||||
import org.jetbrains.kotlin.analysis.test.framework.test.configurators.FrontendKind
|
||||
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
|
||||
import org.jetbrains.kotlin.test.preprocessors.ExternalAnnotationsSourcePreprocessor
|
||||
import org.jetbrains.kotlin.test.services.TestModuleStructure
|
||||
import org.jetbrains.kotlin.test.services.TestServices
|
||||
import org.jetbrains.kotlin.test.services.configuration.ExternalAnnotationsEnvironmentConfigurator
|
||||
import org.jetbrains.kotlin.test.services.configuration.JvmEnvironmentConfigurator
|
||||
|
||||
abstract class AnalysisApiFirSourceLikeTestConfigurator(override val analyseInDependentSession: Boolean) : AnalysisApiTestConfigurator() {
|
||||
@@ -30,7 +32,8 @@ abstract class AnalysisApiFirSourceLikeTestConfigurator(override val analyseInDe
|
||||
useDirectives(SealedClassesInheritorsCaclulatorPreAnalysisHandler.Directives)
|
||||
usePreAnalysisHandlers(::SealedClassesInheritorsCaclulatorPreAnalysisHandler)
|
||||
configureOptionalTestCompilerPlugin()
|
||||
useConfigurators(::JvmEnvironmentConfigurator)
|
||||
useConfigurators(::JvmEnvironmentConfigurator, ::ExternalAnnotationsEnvironmentConfigurator)
|
||||
useSourcePreprocessor(::ExternalAnnotationsSourcePreprocessor)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user