diff --git a/analysis/analysis-api-fe10/tests-gen/org/jetbrains/kotlin/analysis/api/fe10/test/cases/generated/cases/symbols/Fe10IdeNormalAnalysisSourceModuleSymbolByReferenceTestGenerated.java b/analysis/analysis-api-fe10/tests-gen/org/jetbrains/kotlin/analysis/api/fe10/test/cases/generated/cases/symbols/Fe10IdeNormalAnalysisSourceModuleSymbolByReferenceTestGenerated.java index bdb5e64b207..1a75364cff2 100644 --- a/analysis/analysis-api-fe10/tests-gen/org/jetbrains/kotlin/analysis/api/fe10/test/cases/generated/cases/symbols/Fe10IdeNormalAnalysisSourceModuleSymbolByReferenceTestGenerated.java +++ b/analysis/analysis-api-fe10/tests-gen/org/jetbrains/kotlin/analysis/api/fe10/test/cases/generated/cases/symbols/Fe10IdeNormalAnalysisSourceModuleSymbolByReferenceTestGenerated.java @@ -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 { diff --git a/analysis/analysis-api-fir/tests-gen/org/jetbrains/kotlin/analysis/api/fir/test/cases/generated/cases/symbols/FirIdeNormalAnalysisSourceModuleSymbolByReferenceTestGenerated.java b/analysis/analysis-api-fir/tests-gen/org/jetbrains/kotlin/analysis/api/fir/test/cases/generated/cases/symbols/FirIdeNormalAnalysisSourceModuleSymbolByReferenceTestGenerated.java index 3eaf3b2cd06..7647964d734 100644 --- a/analysis/analysis-api-fir/tests-gen/org/jetbrains/kotlin/analysis/api/fir/test/cases/generated/cases/symbols/FirIdeNormalAnalysisSourceModuleSymbolByReferenceTestGenerated.java +++ b/analysis/analysis-api-fir/tests-gen/org/jetbrains/kotlin/analysis/api/fir/test/cases/generated/cases/symbols/FirIdeNormalAnalysisSourceModuleSymbolByReferenceTestGenerated.java @@ -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 { diff --git a/analysis/analysis-api-standalone/tests-gen/org/jetbrains/kotlin/analysis/api/standalone/fir/test/cases/generated/cases/symbols/FirStandaloneNormalAnalysisSourceModuleSymbolByReferenceTestGenerated.java b/analysis/analysis-api-standalone/tests-gen/org/jetbrains/kotlin/analysis/api/standalone/fir/test/cases/generated/cases/symbols/FirStandaloneNormalAnalysisSourceModuleSymbolByReferenceTestGenerated.java index 689c4e5d688..e024f2a0772 100644 --- a/analysis/analysis-api-standalone/tests-gen/org/jetbrains/kotlin/analysis/api/standalone/fir/test/cases/generated/cases/symbols/FirStandaloneNormalAnalysisSourceModuleSymbolByReferenceTestGenerated.java +++ b/analysis/analysis-api-standalone/tests-gen/org/jetbrains/kotlin/analysis/api/standalone/fir/test/cases/generated/cases/symbols/FirStandaloneNormalAnalysisSourceModuleSymbolByReferenceTestGenerated.java @@ -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 { diff --git a/analysis/analysis-api-standalone/tests/org/jetbrains/kotlin/analysis/api/standalone/fir/test/StandaloneModeConfigurator.kt b/analysis/analysis-api-standalone/tests/org/jetbrains/kotlin/analysis/api/standalone/fir/test/StandaloneModeConfigurator.kt index 102f552a4f2..ad9b372845d 100644 --- a/analysis/analysis-api-standalone/tests/org/jetbrains/kotlin/analysis/api/standalone/fir/test/StandaloneModeConfigurator.kt +++ b/analysis/analysis-api-standalone/tests/org/jetbrains/kotlin/analysis/api/standalone/fir/test/StandaloneModeConfigurator.kt @@ -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 { KtSourceModuleFactory() } useDirectives(SealedClassesInheritorsCaclulatorPreAnalysisHandler.Directives) usePreAnalysisHandlers(::SealedClassesInheritorsCaclulatorPreAnalysisHandler) + useConfigurators(::ExternalAnnotationsEnvironmentConfigurator) + useSourcePreprocessor(::ExternalAnnotationsSourcePreprocessor) } } diff --git a/analysis/analysis-api/testData/symbols/symbolByReference/javaMethodWithExternalNotNullAnnotation.descriptors.pretty.txt b/analysis/analysis-api/testData/symbols/symbolByReference/javaMethodWithExternalNotNullAnnotation.descriptors.pretty.txt new file mode 100644 index 00000000000..09daf212b9f --- /dev/null +++ b/analysis/analysis-api/testData/symbols/symbolByReference/javaMethodWithExternalNotNullAnnotation.descriptors.pretty.txt @@ -0,0 +1 @@ +open fun foo(): kotlin.String! \ No newline at end of file diff --git a/analysis/analysis-api/testData/symbols/symbolByReference/javaMethodWithExternalNotNullAnnotation.descriptors.txt b/analysis/analysis-api/testData/symbols/symbolByReference/javaMethodWithExternalNotNullAnnotation.descriptors.txt new file mode 100644 index 00000000000..4b2a5a9d675 --- /dev/null +++ b/analysis/analysis-api/testData/symbols/symbolByReference/javaMethodWithExternalNotNullAnnotation.descriptors.txt @@ -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 \ No newline at end of file diff --git a/analysis/analysis-api/testData/symbols/symbolByReference/javaMethodWithExternalNotNullAnnotation.kt b/analysis/analysis-api/testData/symbols/symbolByReference/javaMethodWithExternalNotNullAnnotation.kt new file mode 100644 index 00000000000..02bcdd8a168 --- /dev/null +++ b/analysis/analysis-api/testData/symbols/symbolByReference/javaMethodWithExternalNotNullAnnotation.kt @@ -0,0 +1,14 @@ +// FILE: main.kt +fun some() { + JavaClass().foo(); +} +// FILE: JavaClass.java +public class JavaClass { + public String foo() {}; +} +// FILE: annotations.xml + + + + + \ No newline at end of file diff --git a/analysis/analysis-api/testData/symbols/symbolByReference/javaMethodWithExternalNotNullAnnotation.pretty.txt b/analysis/analysis-api/testData/symbols/symbolByReference/javaMethodWithExternalNotNullAnnotation.pretty.txt new file mode 100644 index 00000000000..609d595f02b --- /dev/null +++ b/analysis/analysis-api/testData/symbols/symbolByReference/javaMethodWithExternalNotNullAnnotation.pretty.txt @@ -0,0 +1 @@ +open fun foo(): kotlin.String \ No newline at end of file diff --git a/analysis/analysis-api/testData/symbols/symbolByReference/javaMethodWithExternalNotNullAnnotation.txt b/analysis/analysis-api/testData/symbols/symbolByReference/javaMethodWithExternalNotNullAnnotation.txt new file mode 100644 index 00000000000..98ef5889440 --- /dev/null +++ b/analysis/analysis-api/testData/symbols/symbolByReference/javaMethodWithExternalNotNullAnnotation.txt @@ -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 \ No newline at end of file diff --git a/analysis/analysis-api/testData/symbols/symbolByReference/javaMethodWithNotNullAnnotation.descriptors.txt b/analysis/analysis-api/testData/symbols/symbolByReference/javaMethodWithNotNullAnnotation.descriptors.txt new file mode 100644 index 00000000000..f75e4697aa9 --- /dev/null +++ b/analysis/analysis-api/testData/symbols/symbolByReference/javaMethodWithNotNullAnnotation.descriptors.txt @@ -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 diff --git a/analysis/analysis-api/testData/symbols/symbolByReference/javaMethodWithNotNullAnnotation.kt b/analysis/analysis-api/testData/symbols/symbolByReference/javaMethodWithNotNullAnnotation.kt new file mode 100644 index 00000000000..e1d3749af51 --- /dev/null +++ b/analysis/analysis-api/testData/symbols/symbolByReference/javaMethodWithNotNullAnnotation.kt @@ -0,0 +1,11 @@ +// FILE: main.kt +fun some() { + JavaClass().foo(); +} +// FILE: JavaClass.java +import import org.jetbrains.annotations.NotNull; + +public class JavaClass { + @NotNull + public String foo() {}; +} diff --git a/analysis/analysis-api/testData/symbols/symbolByReference/javaMethodWithNotNullAnnotation.pretty.txt b/analysis/analysis-api/testData/symbols/symbolByReference/javaMethodWithNotNullAnnotation.pretty.txt new file mode 100644 index 00000000000..08bf28dfef5 --- /dev/null +++ b/analysis/analysis-api/testData/symbols/symbolByReference/javaMethodWithNotNullAnnotation.pretty.txt @@ -0,0 +1 @@ +open fun foo(): kotlin.String diff --git a/analysis/analysis-api/testData/symbols/symbolByReference/javaMethodWithNotNullAnnotation.txt b/analysis/analysis-api/testData/symbols/symbolByReference/javaMethodWithNotNullAnnotation.txt new file mode 100644 index 00000000000..c0eff4aae8b --- /dev/null +++ b/analysis/analysis-api/testData/symbols/symbolByReference/javaMethodWithNotNullAnnotation.txt @@ -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 diff --git a/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/TestModuleStructureFactory.kt b/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/TestModuleStructureFactory.kt index 60e53053754..5f063459ade 100644 --- a/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/TestModuleStructureFactory.kt +++ b/analysis/analysis-test-framework/tests/org/jetbrains/kotlin/analysis/test/framework/project/structure/TestModuleStructureFactory.kt @@ -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 { 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 { } } } - - } diff --git a/analysis/low-level-api-fir/testData/getOrBuildFir/wholeDeclaration/externalJavaAnnotation.kt b/analysis/low-level-api-fir/testData/getOrBuildFir/wholeDeclaration/externalJavaAnnotation.kt new file mode 100644 index 00000000000..5421206ade8 --- /dev/null +++ b/analysis/low-level-api-fir/testData/getOrBuildFir/wholeDeclaration/externalJavaAnnotation.kt @@ -0,0 +1,19 @@ +// SKIP_WHEN_OUT_OF_CONTENT_ROOT +// FILE: usage.kt + +fun test() = ClassWithExternalAnnotatedMembers().externalNotNullMethod() + + +// FILE: ClassWithExternalAnnotatedMembers.java +public class ClassWithExternalAnnotatedMembers { + public String externalNotNullMethod() { + return ""; + } +} + +// FILE: annotations.xml + + + + + \ No newline at end of file diff --git a/analysis/low-level-api-fir/testData/getOrBuildFir/wholeDeclaration/externalJavaAnnotation.txt b/analysis/low-level-api-fir/testData/getOrBuildFir/wholeDeclaration/externalJavaAnnotation.txt new file mode 100644 index 00000000000..f063db45860 --- /dev/null +++ b/analysis/low-level-api-fir/testData/getOrBuildFir/wholeDeclaration/externalJavaAnnotation.txt @@ -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|() + } \ No newline at end of file diff --git a/analysis/low-level-api-fir/testData/getOrBuildFir/wholeDeclaration/notNullJavaAnnotation.kt b/analysis/low-level-api-fir/testData/getOrBuildFir/wholeDeclaration/notNullJavaAnnotation.kt new file mode 100644 index 00000000000..9e96a1dff85 --- /dev/null +++ b/analysis/low-level-api-fir/testData/getOrBuildFir/wholeDeclaration/notNullJavaAnnotation.kt @@ -0,0 +1,15 @@ +// SKIP_WHEN_OUT_OF_CONTENT_ROOT +// FILE: usage.kt + +fun test() = ClassWithExternalAnnotatedMembers().notNullMethod() + + +// FILE: ClassWithExternalAnnotatedMembers.java +import org.jetbrains.annotations.NotNull; + +public class ClassWithExternalAnnotatedMembers { + @NotNull + public String notNullMethod() { + return ""; + } +} diff --git a/analysis/low-level-api-fir/testData/getOrBuildFir/wholeDeclaration/notNullJavaAnnotation.txt b/analysis/low-level-api-fir/testData/getOrBuildFir/wholeDeclaration/notNullJavaAnnotation.txt new file mode 100644 index 00000000000..00ab9e77cb3 --- /dev/null +++ b/analysis/low-level-api-fir/testData/getOrBuildFir/wholeDeclaration/notNullJavaAnnotation.txt @@ -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|() + } \ No newline at end of file diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/OutOfContentRootGetOrBuildFirTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/OutOfContentRootGetOrBuildFirTestGenerated.java index 22dc92b5a7f..ccad4c9cf5c 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/OutOfContentRootGetOrBuildFirTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/OutOfContentRootGetOrBuildFirTestGenerated.java @@ -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 { diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/SourceGetOrBuildFirTestGenerated.java b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/SourceGetOrBuildFirTestGenerated.java index d383a30da2c..765696eb2d3 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/SourceGetOrBuildFirTestGenerated.java +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/SourceGetOrBuildFirTestGenerated.java @@ -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 { diff --git a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/test/configurators/AnalysisApiFirSourceLikeTestConfigurator.kt b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/test/configurators/AnalysisApiFirSourceLikeTestConfigurator.kt index f82435a5556..2e25300a02e 100644 --- a/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/test/configurators/AnalysisApiFirSourceLikeTestConfigurator.kt +++ b/analysis/low-level-api-fir/tests/org/jetbrains/kotlin/analysis/low/level/api/fir/test/configurators/AnalysisApiFirSourceLikeTestConfigurator.kt @@ -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) } } diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendForeignAnnotationsCompiledJavaTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendForeignAnnotationsCompiledJavaTestGenerated.java index 013cd627aeb..b5cbd7c3e8f 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendForeignAnnotationsCompiledJavaTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendForeignAnnotationsCompiledJavaTestGenerated.java @@ -23,7 +23,7 @@ public class FirPsiOldFrontendForeignAnnotationsCompiledJavaTestGenerated extend public class Tests { @Test public void testAllFilesPresentInTests() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/foreignAnnotationsTests/tests"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/foreignAnnotationsTests/tests"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true, "externalAnnotations"); } @Test diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated.java index 0958252dc73..bcf8a719415 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated.java @@ -146,6 +146,64 @@ public class FirPsiOldFrontendForeignAnnotationsCompiledJavaWithPsiClassReadingT runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/rxjava3Warnings.kt"); } + @Nested + @TestMetadata("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations") + @TestDataPath("$PROJECT_ROOT") + public class ExternalAnnotations { + @Test + public void testAllFilesPresentInExternalAnnotations() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); + } + + @Test + @TestMetadata("constructorParameterNotNull.kt") + public void testConstructorParameterNotNull() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/constructorParameterNotNull.kt"); + } + + @Test + @TestMetadata("constructorParameterNotNull2.kt") + public void testConstructorParameterNotNull2() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/constructorParameterNotNull2.kt"); + } + + @Test + @TestMetadata("fieldNotNull.kt") + public void testFieldNotNull() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/fieldNotNull.kt"); + } + + @Test + @TestMetadata("fieldNotNullAnnotationWithPackage.kt") + public void testFieldNotNullAnnotationWithPackage() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/fieldNotNullAnnotationWithPackage.kt"); + } + + @Test + @TestMetadata("methodNotNull.kt") + public void testMethodNotNull() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodNotNull.kt"); + } + + @Test + @TestMetadata("methodNotNullFromAnotherModule.kt") + public void testMethodNotNullFromAnotherModule() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodNotNullFromAnotherModule.kt"); + } + + @Test + @TestMetadata("methodParameterNotNull.kt") + public void testMethodParameterNotNull() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodParameterNotNull.kt"); + } + + @Test + @TestMetadata("methodParameterNotNull2.kt") + public void testMethodParameterNotNull2() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodParameterNotNull2.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendForeignAnnotationsSourceJavaTestGenerated.java b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendForeignAnnotationsSourceJavaTestGenerated.java index 062b7292a53..ff73002b2eb 100644 --- a/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendForeignAnnotationsSourceJavaTestGenerated.java +++ b/compiler/fir/analysis-tests/tests-gen/org/jetbrains/kotlin/test/runners/FirPsiOldFrontendForeignAnnotationsSourceJavaTestGenerated.java @@ -146,6 +146,64 @@ public class FirPsiOldFrontendForeignAnnotationsSourceJavaTestGenerated extends runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/rxjava3Warnings.kt"); } + @Nested + @TestMetadata("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations") + @TestDataPath("$PROJECT_ROOT") + public class ExternalAnnotations { + @Test + public void testAllFilesPresentInExternalAnnotations() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); + } + + @Test + @TestMetadata("constructorParameterNotNull.kt") + public void testConstructorParameterNotNull() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/constructorParameterNotNull.kt"); + } + + @Test + @TestMetadata("constructorParameterNotNull2.kt") + public void testConstructorParameterNotNull2() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/constructorParameterNotNull2.kt"); + } + + @Test + @TestMetadata("fieldNotNull.kt") + public void testFieldNotNull() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/fieldNotNull.kt"); + } + + @Test + @TestMetadata("fieldNotNullAnnotationWithPackage.kt") + public void testFieldNotNullAnnotationWithPackage() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/fieldNotNullAnnotationWithPackage.kt"); + } + + @Test + @TestMetadata("methodNotNull.kt") + public void testMethodNotNull() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodNotNull.kt"); + } + + @Test + @TestMetadata("methodNotNullFromAnotherModule.kt") + public void testMethodNotNullFromAnotherModule() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodNotNullFromAnotherModule.kt"); + } + + @Test + @TestMetadata("methodParameterNotNull.kt") + public void testMethodParameterNotNull() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodParameterNotNull.kt"); + } + + @Test + @TestMetadata("methodParameterNotNull2.kt") + public void testMethodParameterNotNull2() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodParameterNotNull2.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/services/SourceFileProvider.kt b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/services/SourceFileProvider.kt index a4224aa64b6..c207662cddc 100644 --- a/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/services/SourceFileProvider.kt +++ b/compiler/test-infrastructure/tests/org/jetbrains/kotlin/test/services/SourceFileProvider.kt @@ -1,10 +1,11 @@ /* - * Copyright 2010-2020 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. */ package org.jetbrains.kotlin.test.services +import com.intellij.codeInsight.ExternalAnnotationsManager import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.StandardFileSystems import com.intellij.psi.PsiManager @@ -139,6 +140,9 @@ val TestFile.isMjsFile: Boolean val TestModule.javaFiles: List get() = files.filter { it.isJavaFile } +val TestFile.isExternalAnnotation: Boolean + get() = name == ExternalAnnotationsManager.ANNOTATIONS_XML + fun SourceFileProvider.getRealJavaFiles(module: TestModule): List { return module.javaFiles.map { getRealFileForSourceFile(it) } } diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/constructorParameterNotNull.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/constructorParameterNotNull.fir.kt new file mode 100644 index 00000000000..1c6ed2fca25 --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/constructorParameterNotNull.fir.kt @@ -0,0 +1,37 @@ +// FILE: ClassWithExternalAnnotatedMembers.java +import org.jetbrains.annotations.NotNull; + +public class ClassWithExternalAnnotatedMembers { + public ClassWithExternalAnnotatedMembers(Integer i) { // with external annotation on parameter + + } + + public ClassWithExternalAnnotatedMembers(@NotNull String s) { + + } + + public ClassWithExternalAnnotatedMembers(Boolean b) { + + } +} + +// FILE: usage.kt +fun test() { + val i: Int? = null + ClassWithExternalAnnotatedMembers(i) + + val s: String? = null + ClassWithExternalAnnotatedMembers(s) + + val b: Boolean? = null + ClassWithExternalAnnotatedMembers(b) + + ClassWithExternalAnnotatedMembers(null) +} + +// FILE: annotations.xml + + + + + \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/constructorParameterNotNull.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/constructorParameterNotNull.kt new file mode 100644 index 00000000000..8f81b0878e9 --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/constructorParameterNotNull.kt @@ -0,0 +1,37 @@ +// FILE: ClassWithExternalAnnotatedMembers.java +import org.jetbrains.annotations.NotNull; + +public class ClassWithExternalAnnotatedMembers { + public ClassWithExternalAnnotatedMembers(Integer i) { // with external annotation on parameter + + } + + public ClassWithExternalAnnotatedMembers(@NotNull String s) { + + } + + public ClassWithExternalAnnotatedMembers(Boolean b) { + + } +} + +// FILE: usage.kt +fun test() { + val i: Int? = null + ClassWithExternalAnnotatedMembers(i) + + val s: String? = null + ClassWithExternalAnnotatedMembers(s) + + val b: Boolean? = null + ClassWithExternalAnnotatedMembers(b) + + ClassWithExternalAnnotatedMembers(null) +} + +// FILE: annotations.xml + + + + + \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/constructorParameterNotNull2.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/constructorParameterNotNull2.fir.kt new file mode 100644 index 00000000000..ff1c4d53c35 --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/constructorParameterNotNull2.fir.kt @@ -0,0 +1,33 @@ +// FILE: ClassWithExternalAnnotatedMembers.java +import org.jetbrains.annotations.NotNull; + +public class ClassWithExternalAnnotatedMembers { + public ClassWithExternalAnnotatedMembers(Integer i) { // with external annotation on parameter + + } + + public ClassWithExternalAnnotatedMembers(@NotNull String s) { + + } +} + +// FILE: usage.kt +fun test() { + val i: Int? = null + ClassWithExternalAnnotatedMembers(i) + + val s: String? = null + ClassWithExternalAnnotatedMembers(s) + + val b: Boolean? = null + ClassWithExternalAnnotatedMembers(b) + + ClassWithExternalAnnotatedMembers(null) +} + +// FILE: annotations.xml + + + + + \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/constructorParameterNotNull2.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/constructorParameterNotNull2.kt new file mode 100644 index 00000000000..3a4dbfe9ccd --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/constructorParameterNotNull2.kt @@ -0,0 +1,33 @@ +// FILE: ClassWithExternalAnnotatedMembers.java +import org.jetbrains.annotations.NotNull; + +public class ClassWithExternalAnnotatedMembers { + public ClassWithExternalAnnotatedMembers(Integer i) { // with external annotation on parameter + + } + + public ClassWithExternalAnnotatedMembers(@NotNull String s) { + + } +} + +// FILE: usage.kt +fun test() { + val i: Int? = null + ClassWithExternalAnnotatedMembers(i) + + val s: String? = null + ClassWithExternalAnnotatedMembers(s) + + val b: Boolean? = null + ClassWithExternalAnnotatedMembers(b) + + ClassWithExternalAnnotatedMembers(null) +} + +// FILE: annotations.xml + + + + + \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/fieldNotNull.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/fieldNotNull.kt new file mode 100644 index 00000000000..db88ade1ed0 --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/fieldNotNull.kt @@ -0,0 +1,39 @@ +// FIR_IDENTICAL +// FILE: ClassWithExternalAnnotatedMembers.java +import org.jetbrains.annotations.NotNull; + +public class ClassWithExternalAnnotatedMembers { + public String externalNotNullField; + + @NotNull + public String explicitNotNullField; + + public static String staticExternalNotNullField; + + @NotNull + public static String staticExplicitNotNullField; +} + +// FILE: usage.kt +fun test() { + val x = ClassWithExternalAnnotatedMembers() + x.externalNotNullField?.foo() + x.explicitNotNullField?.foo() + + ClassWithExternalAnnotatedMembers.staticExternalNotNullField?.foo() + ClassWithExternalAnnotatedMembers.staticExplicitNotNullField?.foo() +} + +fun String.foo() { + +} + +// FILE: annotations.xml + + + + + + + + \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/fieldNotNullAnnotationWithPackage.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/fieldNotNullAnnotationWithPackage.kt new file mode 100644 index 00000000000..f84806de4aa --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/fieldNotNullAnnotationWithPackage.kt @@ -0,0 +1,45 @@ +// FIR_IDENTICAL +// FILE: one/two/ClassWithExternalAnnotatedMembers.java +package one.two; + +import org.jetbrains.annotations.NotNull; + +public class ClassWithExternalAnnotatedMembers { + public String externalNotNullField; + + @NotNull + public String explicitNotNullField; + + public static String staticExternalNotNullField; + + @NotNull + public static String staticExplicitNotNullField; +} + +// FILE: one/usage.kt +package one + +import one.two.ClassWithExternalAnnotatedMembers + +fun test() { + val x = ClassWithExternalAnnotatedMembers() + x.externalNotNullField?.foo() + x.explicitNotNullField?.foo() + + ClassWithExternalAnnotatedMembers.staticExternalNotNullField?.foo() + ClassWithExternalAnnotatedMembers.staticExplicitNotNullField?.foo() +} + +fun String.foo() { + +} + +// FILE: one/two/annotations.xml + + + + + + + + \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodNotNull.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodNotNull.kt new file mode 100644 index 00000000000..b00974b2bb4 --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodNotNull.kt @@ -0,0 +1,47 @@ +// FIR_IDENTICAL +// FILE: ClassWithExternalAnnotatedMembers.java +import org.jetbrains.annotations.NotNull; + +public class ClassWithExternalAnnotatedMembers { + public String externalNotNullMethod() { + return ""; + } + + @NotNull + public String explicitNotNullMethod() { + return ""; + } + + public static String staticExternalNotNullMethod() { + return ""; + } + + @NotNull + public static String staticExplicitNotNullMethod() { + return ""; + } +} + +// FILE: usage.kt +fun test() { + val x = ClassWithExternalAnnotatedMembers() + x.externalNotNullMethod()?.foo() + x.explicitNotNullMethod()?.foo() + + ClassWithExternalAnnotatedMembers.staticExternalNotNullMethod()?.foo() + ClassWithExternalAnnotatedMembers.staticExplicitNotNullMethod()?.foo() +} + +fun String.foo() { + +} + +// FILE: annotations.xml + + + + + + + + \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodNotNullFromAnotherModule.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodNotNullFromAnotherModule.kt new file mode 100644 index 00000000000..7a8cfc87b0e --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodNotNullFromAnotherModule.kt @@ -0,0 +1,72 @@ +// FIR_IDENTICAL +// MODULE: javaModule +// FILE: one/two/FirstModuleClass.java +package one.two; + +import org.jetbrains.annotations.NotNull; + +public class FirstModuleClass { + public String externalNotNullMethod() { + return ""; + } + + @NotNull + public String explicitNotNullMethod() { + return ""; + } +} +// FILE: one/two/annotations.xml + + + + + +// FILE: usage.kt +package usage1 + +import one.two.FirstModuleClass + +fun test() { + val x = FirstModuleClass() + x.externalNotNullMethod()?.foo() + x.explicitNotNullMethod()?.foo() +} + +fun String.foo() { + +} +// MODULE: javaModule2 +// FILE: three/SecondModuleClass.java +package three; + +import org.jetbrains.annotations.NotNull; + +public class SecondModuleClass { + public static String staticExternalNotNullMethod() { + return ""; + } + + @NotNull + public static String staticExplicitNotNullMethod() { + return ""; + } +} +// FILE: three/annotations.xml + + + + + +// FILE: my/pack/usage.kt +package my.pack + +import three.SecondModuleClass + +fun test() { + SecondModuleClass.staticExternalNotNullMethod()?.foo() + SecondModuleClass.staticExplicitNotNullMethod()?.foo() +} + +fun String.foo() { + +} diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodParameterNotNull.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodParameterNotNull.fir.kt new file mode 100644 index 00000000000..ee930de40bc --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodParameterNotNull.fir.kt @@ -0,0 +1,32 @@ +// FILE: ClassWithExternalAnnotatedMembers.java +import org.jetbrains.annotations.NotNull; + +public class ClassWithExternalAnnotatedMembers { + public void method(String s) { + } + + public void method(@NotNull Integer i) { + } +} + +// FILE: usage.kt +fun test() { + val instance = ClassWithExternalAnnotatedMembers() + val i: Int? = null + instance.method(i) + + val s: String? = null + instance.method(s) + + val b: Boolean? = null + instance.method(b) + + instance.method(null) +} + +// FILE: annotations.xml + + + + + \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodParameterNotNull.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodParameterNotNull.kt new file mode 100644 index 00000000000..1b50783d6f7 --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodParameterNotNull.kt @@ -0,0 +1,32 @@ +// FILE: ClassWithExternalAnnotatedMembers.java +import org.jetbrains.annotations.NotNull; + +public class ClassWithExternalAnnotatedMembers { + public void method(String s) { + } + + public void method(@NotNull Integer i) { + } +} + +// FILE: usage.kt +fun test() { + val instance = ClassWithExternalAnnotatedMembers() + val i: Int? = null + instance.method(i) + + val s: String? = null + instance.method(s) + + val b: Boolean? = null + instance.method(b) + + instance.method(null) +} + +// FILE: annotations.xml + + + + + \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodParameterNotNull2.fir.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodParameterNotNull2.fir.kt new file mode 100644 index 00000000000..c33b86ca6f9 --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodParameterNotNull2.fir.kt @@ -0,0 +1,35 @@ +// FILE: ClassWithExternalAnnotatedMembers.java +import org.jetbrains.annotations.NotNull; + +public class ClassWithExternalAnnotatedMembers { + public void method(String s) { + } + + public void method(@NotNull Integer i) { + } + + public void method(Boolean b) { + } +} + +// FILE: usage.kt +fun test() { + val instance = ClassWithExternalAnnotatedMembers() + val i: Int? = null + instance.method(i) + + val s: String? = null + instance.method(s) + + val b: Boolean? = null + instance.method(b) + + instance.method(null) +} + +// FILE: annotations.xml + + + + + \ No newline at end of file diff --git a/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodParameterNotNull2.kt b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodParameterNotNull2.kt new file mode 100644 index 00000000000..3011471de55 --- /dev/null +++ b/compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodParameterNotNull2.kt @@ -0,0 +1,35 @@ +// FILE: ClassWithExternalAnnotatedMembers.java +import org.jetbrains.annotations.NotNull; + +public class ClassWithExternalAnnotatedMembers { + public void method(String s) { + } + + public void method(@NotNull Integer i) { + } + + public void method(Boolean b) { + } +} + +// FILE: usage.kt +fun test() { + val instance = ClassWithExternalAnnotatedMembers() + val i: Int? = null + instance.method(i) + + val s: String? = null + instance.method(s) + + val b: Boolean? = null + instance.method(b) + + instance.method(null) +} + +// FILE: annotations.xml + + + + + \ No newline at end of file diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsCompiledJavaTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsCompiledJavaTestGenerated.java index dbe33a69909..31ddf5e563a 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsCompiledJavaTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsCompiledJavaTestGenerated.java @@ -23,7 +23,7 @@ public class ForeignAnnotationsCompiledJavaTestGenerated extends AbstractForeign public class Tests { @Test public void testAllFilesPresentInTests() throws Exception { - KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/foreignAnnotationsTests/tests"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/foreignAnnotationsTests/tests"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true, "externalAnnotations"); } @Test diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated.java index aead8437434..8b41b4ee9b6 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated.java @@ -146,6 +146,64 @@ public class ForeignAnnotationsCompiledJavaWithPsiClassReadingTestGenerated exte runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/rxjava3Warnings.kt"); } + @Nested + @TestMetadata("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations") + @TestDataPath("$PROJECT_ROOT") + public class ExternalAnnotations { + @Test + public void testAllFilesPresentInExternalAnnotations() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); + } + + @Test + @TestMetadata("constructorParameterNotNull.kt") + public void testConstructorParameterNotNull() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/constructorParameterNotNull.kt"); + } + + @Test + @TestMetadata("constructorParameterNotNull2.kt") + public void testConstructorParameterNotNull2() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/constructorParameterNotNull2.kt"); + } + + @Test + @TestMetadata("fieldNotNull.kt") + public void testFieldNotNull() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/fieldNotNull.kt"); + } + + @Test + @TestMetadata("fieldNotNullAnnotationWithPackage.kt") + public void testFieldNotNullAnnotationWithPackage() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/fieldNotNullAnnotationWithPackage.kt"); + } + + @Test + @TestMetadata("methodNotNull.kt") + public void testMethodNotNull() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodNotNull.kt"); + } + + @Test + @TestMetadata("methodNotNullFromAnotherModule.kt") + public void testMethodNotNullFromAnotherModule() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodNotNullFromAnotherModule.kt"); + } + + @Test + @TestMetadata("methodParameterNotNull.kt") + public void testMethodParameterNotNull() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodParameterNotNull.kt"); + } + + @Test + @TestMetadata("methodParameterNotNull2.kt") + public void testMethodParameterNotNull2() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodParameterNotNull2.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsSourceJavaTestGenerated.java b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsSourceJavaTestGenerated.java index f6acb311765..720071a7cb6 100644 --- a/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsSourceJavaTestGenerated.java +++ b/compiler/tests-common-new/tests-gen/org/jetbrains/kotlin/test/runners/ForeignAnnotationsSourceJavaTestGenerated.java @@ -146,6 +146,64 @@ public class ForeignAnnotationsSourceJavaTestGenerated extends AbstractForeignAn runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/rxjava3Warnings.kt"); } + @Nested + @TestMetadata("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations") + @TestDataPath("$PROJECT_ROOT") + public class ExternalAnnotations { + @Test + public void testAllFilesPresentInExternalAnnotations() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.(reversed|fir|ll)\\.kts?$"), true); + } + + @Test + @TestMetadata("constructorParameterNotNull.kt") + public void testConstructorParameterNotNull() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/constructorParameterNotNull.kt"); + } + + @Test + @TestMetadata("constructorParameterNotNull2.kt") + public void testConstructorParameterNotNull2() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/constructorParameterNotNull2.kt"); + } + + @Test + @TestMetadata("fieldNotNull.kt") + public void testFieldNotNull() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/fieldNotNull.kt"); + } + + @Test + @TestMetadata("fieldNotNullAnnotationWithPackage.kt") + public void testFieldNotNullAnnotationWithPackage() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/fieldNotNullAnnotationWithPackage.kt"); + } + + @Test + @TestMetadata("methodNotNull.kt") + public void testMethodNotNull() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodNotNull.kt"); + } + + @Test + @TestMetadata("methodNotNullFromAnotherModule.kt") + public void testMethodNotNullFromAnotherModule() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodNotNullFromAnotherModule.kt"); + } + + @Test + @TestMetadata("methodParameterNotNull.kt") + public void testMethodParameterNotNull() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodParameterNotNull.kt"); + } + + @Test + @TestMetadata("methodParameterNotNull2.kt") + public void testMethodParameterNotNull2() throws Exception { + runTest("compiler/testData/diagnostics/foreignAnnotationsTests/tests/externalAnnotations/methodParameterNotNull2.kt"); + } + } + @Nested @TestMetadata("compiler/testData/diagnostics/foreignAnnotationsTests/tests/jsr305") @TestDataPath("$PROJECT_ROOT") diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/preprocessors/ExternalAnnotationsSourcePreprocessor.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/preprocessors/ExternalAnnotationsSourcePreprocessor.kt new file mode 100644 index 00000000000..4e8c6b627c1 --- /dev/null +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/preprocessors/ExternalAnnotationsSourcePreprocessor.kt @@ -0,0 +1,26 @@ +/* + * 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. + */ + +package org.jetbrains.kotlin.test.preprocessors + +import org.jetbrains.kotlin.test.model.TestFile +import org.jetbrains.kotlin.test.services.ReversibleSourceFilePreprocessor +import org.jetbrains.kotlin.test.services.TestServices +import org.jetbrains.kotlin.test.services.isExternalAnnotation + +/** + * This preprocessor is required to drop '//' comments from the file to avoid exceptions from XML parser + */ +class ExternalAnnotationsSourcePreprocessor(testServices: TestServices) : ReversibleSourceFilePreprocessor(testServices) { + override fun process(file: TestFile, content: String): String = if (file.isExternalAnnotation) { + content.trim().lineSequence().filterNot { it.startsWith('/') }.joinToString(separator = "\n") + } else { + content + } + + override fun revert(file: TestFile, actualContent: String): String { + return if (file.isExternalAnnotation) file.originalContent.trim() + "\n" else actualContent + } +} diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/AbstractForeignAnnotationsTest.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/AbstractForeignAnnotationsTest.kt index 72755b640f9..d73076432a1 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/AbstractForeignAnnotationsTest.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/runners/AbstractForeignAnnotationsTest.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2020 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. */ @@ -24,7 +24,9 @@ import org.jetbrains.kotlin.test.directives.JvmEnvironmentConfigurationDirective import org.jetbrains.kotlin.test.frontend.classic.handlers.* import org.jetbrains.kotlin.test.model.DependencyKind import org.jetbrains.kotlin.test.model.FrontendKinds +import org.jetbrains.kotlin.test.preprocessors.ExternalAnnotationsSourcePreprocessor import org.jetbrains.kotlin.test.preprocessors.JspecifyMarksCleanupPreprocessor +import org.jetbrains.kotlin.test.services.SourceFilePreprocessor import org.jetbrains.kotlin.test.services.TestServices import org.jetbrains.kotlin.test.services.configuration.* import org.jetbrains.kotlin.test.services.jvm.ForeignAnnotationAgainstCompiledJavaTestSuppressor @@ -69,9 +71,12 @@ abstract class AbstractForeignAnnotationsTestBase(private val kind: ForeignAnnot useConfigurators( ::CommonEnvironmentConfigurator, ::JvmForeignAnnotationsConfigurator, - ::JvmEnvironmentConfigurator + ::JvmEnvironmentConfigurator, + ::ExternalAnnotationsEnvironmentConfigurator, ) + useSourcePreprocessor(::ExternalAnnotationsSourcePreprocessor) + useAdditionalSourceProviders( ::AdditionalDiagnosticsSourceFilesProvider, ::CoroutineHelpersSourceFilesProvider, diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/configuration/ExternalAnnotationsEnvironmentConfigurator.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/configuration/ExternalAnnotationsEnvironmentConfigurator.kt new file mode 100644 index 00000000000..e253ac7ffcb --- /dev/null +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/configuration/ExternalAnnotationsEnvironmentConfigurator.kt @@ -0,0 +1,86 @@ +/* + * 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. + */ + +package org.jetbrains.kotlin.test.services.configuration + +import com.intellij.codeInsight.BaseExternalAnnotationsManager +import com.intellij.codeInsight.ExternalAnnotationsManager +import com.intellij.mock.MockProject +import com.intellij.openapi.project.Project +import com.intellij.openapi.vfs.StandardFileSystems +import com.intellij.openapi.vfs.VirtualFile +import com.intellij.openapi.vfs.VirtualFileManager +import com.intellij.psi.PsiManager +import com.intellij.psi.PsiModifierListOwner +import org.jetbrains.kotlin.asJava.classes.lazyPub +import org.jetbrains.kotlin.config.CompilerConfiguration +import org.jetbrains.kotlin.test.model.TestModule +import org.jetbrains.kotlin.test.services.EnvironmentConfigurator +import org.jetbrains.kotlin.test.services.TestServices +import org.jetbrains.kotlin.test.services.sourceFileProvider + +/** + * Adds the ability to declare 'annotations.xml' file with description of external annotations. + * + * Such synthetic Java annotations can be found by + * [JavaAnnotation.isIdeExternalAnnotation][org.jetbrains.kotlin.load.java.structure.JavaAnnotation.isIdeExternalAnnotation] flag. + * + * @see ExternalAnnotationsManager + * @see org.jetbrains.kotlin.test.preprocessors.ExternalAnnotationsSourcePreprocessor + */ +class ExternalAnnotationsEnvironmentConfigurator(testServices: TestServices) : EnvironmentConfigurator(testServices) { + override fun legacyRegisterCompilerExtensions(project: Project, module: TestModule, configuration: CompilerConfiguration) { + var hasAnnotationFile = false + for (file in module.files) { + if (file.name != ExternalAnnotationsManager.ANNOTATIONS_XML) continue + + // This call is required to copy files into the project to be able to read those xml files from the manager + testServices.sourceFileProvider.getRealFileForSourceFile(file) + hasAnnotationFile = true + } + + if (!hasAnnotationFile) return + + (project as MockProject).picoContainer.unregisterComponent(ExternalAnnotationsManager::class.java.name) + project.registerService( + ExternalAnnotationsManager::class.java, + ExternalAnnotationsManagerForTests( + // We use additionalFilesDirectory as a root of external annotations because this directory contains all + // declared 'annotations.xml' files + externalAnnotationsRootPath = testServices.sourceFileProvider.additionalFilesDirectory.path, + manager = PsiManager.getInstance(project), + ), + ) + } +} + +/** + * Simple [ExternalAnnotationsManager] implementation + * which always suggests searching external annotations inside [externalAnnotationsRootPath]. + * + * @param externalAnnotationsRootPath path to the directory with 'annotations.xml' files + */ +private class ExternalAnnotationsManagerForTests( + externalAnnotationsRootPath: String, + manager: PsiManager, +) : BaseExternalAnnotationsManager(manager) { + private val externalAnnotationsRoots: List by lazyPub { + VirtualFileManager.getInstance() + .getFileSystem(StandardFileSystems.FILE_PROTOCOL) + .findFileByPath(externalAnnotationsRootPath) + ?.let(::listOf) + ?: error("File with external annotations is not found") + } + + /** + * We simply returns [externalAnnotationsRoots] because there is all our declared 'annotations.xml' files + * + * @param libraryFile is a file for which we want to find the corresponding external annotations file if it exists + */ + override fun getExternalAnnotationsRoots(libraryFile: VirtualFile): List = externalAnnotationsRoots + + override fun hasAnyAnnotationsRoots(): Boolean = true + override fun hasConfiguredAnnotationRoot(owner: PsiModifierListOwner): Boolean = true +} \ No newline at end of file diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/impl/ModuleStructureExtractorImpl.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/impl/ModuleStructureExtractorImpl.kt index ade41110a45..66f2c101f4b 100644 --- a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/impl/ModuleStructureExtractorImpl.kt +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/services/impl/ModuleStructureExtractorImpl.kt @@ -46,7 +46,7 @@ class ModuleStructureExtractorImpl( private val environmentConfigurators: List ) : ModuleStructureExtractor(testServices, additionalSourceProviders, moduleStructureTransformers) { companion object { - private val allowedExtensionsForFiles = listOf(".kt", ".kts", ".java", ".js", ".mjs", ".config") + private val allowedExtensionsForFiles = listOf(".kt", ".kts", ".java", ".js", ".mjs", ".config", ".xml") /* * ([^()\n]+) module name diff --git a/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit5CompilerTests.kt b/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit5CompilerTests.kt index 22f4725f082..feb7e671481 100644 --- a/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit5CompilerTests.kt +++ b/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit5CompilerTests.kt @@ -56,7 +56,11 @@ fun generateJUnit5CompilerTests(args: Array, mainClassName: String?) { } testClass { - model("diagnostics/foreignAnnotationsTests/tests", excludedPattern = excludedCustomTestdataPattern) + model( + "diagnostics/foreignAnnotationsTests/tests", + excludedPattern = excludedCustomTestdataPattern, + excludeDirs = listOf("externalAnnotations"), + ) model("diagnostics/foreignAnnotationsTests/java8Tests", excludedPattern = excludedCustomTestdataPattern) model("diagnostics/foreignAnnotationsTests/java11Tests", excludedPattern = excludedCustomTestdataPattern) } @@ -242,7 +246,11 @@ fun generateJUnit5CompilerTests(args: Array, mainClassName: String?) { testClass( suiteTestClassName = "FirPsiOldFrontendForeignAnnotationsCompiledJavaTestGenerated" ) { - model("diagnostics/foreignAnnotationsTests/tests", excludedPattern = excludedCustomTestdataPattern) + model( + "diagnostics/foreignAnnotationsTests/tests", + excludedPattern = excludedCustomTestdataPattern, + excludeDirs = listOf("externalAnnotations"), + ) model("diagnostics/foreignAnnotationsTests/java8Tests", excludedPattern = excludedCustomTestdataPattern) model("diagnostics/foreignAnnotationsTests/java11Tests", excludedPattern = excludedCustomTestdataPattern) }