diff --git a/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/base.kt b/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/base.kt index 6c3fc99e910..0aa8eb8dd4a 100644 --- a/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/base.kt +++ b/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/base.kt @@ -1,4 +1,4 @@ -// ERROR: The feature "array literals in annotations" is only available since language version 1.2 +// LANGUAGE_VERSION: 1.2 annotation class Some(val strings: Array) diff --git a/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/base.kt.after b/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/base.kt.after index 6e78f5e46b7..debefedbd58 100644 --- a/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/base.kt.after +++ b/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/base.kt.after @@ -1,4 +1,4 @@ -// ERROR: The feature "array literals in annotations" is only available since language version 1.2 +// LANGUAGE_VERSION: 1.2 annotation class Some(val strings: Array) diff --git a/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/default.kt b/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/default.kt index f0027c35812..d64ec7c4dbd 100644 --- a/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/default.kt +++ b/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/default.kt @@ -1,3 +1,3 @@ -// ERROR: The feature "array literals in annotations" is only available since language version 1.2 +// LANGUAGE_VERSION: 1.2 annotation class Some(val strings: Array = arrayOf("default")) \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/default.kt.after b/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/default.kt.after index ea735dd047d..c629e6e7c2e 100644 --- a/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/default.kt.after +++ b/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/default.kt.after @@ -1,3 +1,3 @@ -// ERROR: The feature "array literals in annotations" is only available since language version 1.2 +// LANGUAGE_VERSION: 1.2 annotation class Some(val strings: Array = ["default"]) \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/defaultNotAnnotation.kt b/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/defaultNotAnnotation.kt index 546edc921a1..c02e852f639 100644 --- a/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/defaultNotAnnotation.kt +++ b/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/defaultNotAnnotation.kt @@ -1,2 +1,3 @@ +// LANGUAGE_VERSION: 1.2 // PROBLEM: none class Some(val strings: Array = arrayOf("default")) \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/empty.kt b/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/empty.kt index 26584ad00eb..d1b3e62c382 100644 --- a/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/empty.kt +++ b/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/empty.kt @@ -1,4 +1,4 @@ -// ERROR: The feature "array literals in annotations" is only available since language version 1.2 +// LANGUAGE_VERSION: 1.2 annotation class Some(val strings: Array) diff --git a/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/empty.kt.after b/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/empty.kt.after index 3b13fc1f591..aa57dcfce10 100644 --- a/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/empty.kt.after +++ b/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/empty.kt.after @@ -1,4 +1,4 @@ -// ERROR: The feature "array literals in annotations" is only available since language version 1.2 +// LANGUAGE_VERSION: 1.2 annotation class Some(val strings: Array) diff --git a/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/intArray.kt b/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/intArray.kt index a76f683df5b..b7743ec53b9 100644 --- a/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/intArray.kt +++ b/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/intArray.kt @@ -1,4 +1,4 @@ -// ERROR: The feature "array literals in annotations" is only available since language version 1.2 +// LANGUAGE_VERSION: 1.2 annotation class Some(val nums: IntArray) diff --git a/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/intArray.kt.after b/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/intArray.kt.after index b8f406a2db2..d46048aae7b 100644 --- a/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/intArray.kt.after +++ b/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/intArray.kt.after @@ -1,4 +1,4 @@ -// ERROR: The feature "array literals in annotations" is only available since language version 1.2 +// LANGUAGE_VERSION: 1.2 annotation class Some(val nums: IntArray) diff --git a/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/noAnnotation.kt b/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/noAnnotation.kt index 4e6912901fb..47202eef891 100644 --- a/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/noAnnotation.kt +++ b/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/noAnnotation.kt @@ -1,3 +1,4 @@ +// LANGUAGE_VERSION: 1.2 // PROBLEM: none fun foo() { diff --git a/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/noArray.kt b/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/noArray.kt index a233ee98822..84bdfee99b0 100644 --- a/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/noArray.kt +++ b/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/noArray.kt @@ -1,3 +1,4 @@ +// LANGUAGE_VERSION: 1.2 // PROBLEM: none // ERROR: Type mismatch: inferred type is Int but Array was expected diff --git a/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/unnamed.kt b/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/unnamed.kt index d0b1e512948..a3e6b9fbba5 100644 --- a/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/unnamed.kt +++ b/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/unnamed.kt @@ -1,4 +1,4 @@ -// ERROR: The feature "array literals in annotations" is only available since language version 1.2 +// LANGUAGE_VERSION: 1.2 annotation class Some(val strings: Array) diff --git a/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/unnamed.kt.after b/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/unnamed.kt.after index f4842540db6..e06b1ec4e90 100644 --- a/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/unnamed.kt.after +++ b/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/unnamed.kt.after @@ -1,4 +1,4 @@ -// ERROR: The feature "array literals in annotations" is only available since language version 1.2 +// LANGUAGE_VERSION: 1.2 annotation class Some(val strings: Array) diff --git a/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/vararg.kt b/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/vararg.kt index f3fcebcf628..67d74a62d86 100644 --- a/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/vararg.kt +++ b/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/vararg.kt @@ -1,4 +1,4 @@ -// ERROR: The feature "array literals in annotations" is only available since language version 1.2 +// LANGUAGE_VERSION: 1.2 annotation class Some(vararg val strings: String) diff --git a/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/vararg.kt.after b/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/vararg.kt.after index bd60cdfb2fc..6b1e9b59e1b 100644 --- a/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/vararg.kt.after +++ b/idea/testData/inspectionsLocal/replaceArrayOfWithLiteral/vararg.kt.after @@ -1,4 +1,4 @@ -// ERROR: The feature "array literals in annotations" is only available since language version 1.2 +// LANGUAGE_VERSION: 1.2 annotation class Some(vararg val strings: String) diff --git a/idea/tests/org/jetbrains/kotlin/idea/inspections/AbstractLocalInspectionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/inspections/AbstractLocalInspectionTest.kt index 02f20209fc3..772243a75ec 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/inspections/AbstractLocalInspectionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/inspections/AbstractLocalInspectionTest.kt @@ -18,11 +18,16 @@ package org.jetbrains.kotlin.idea.inspections import com.google.common.collect.Lists import com.intellij.codeInspection.ProblemDescriptor +import com.intellij.openapi.application.WriteAction +import com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProviderImpl import com.intellij.openapi.util.SystemInfo import com.intellij.openapi.util.io.FileUtil import com.intellij.openapi.vfs.VirtualFile import junit.framework.ComparisonFailure import junit.framework.TestCase +import org.jetbrains.kotlin.config.LanguageFeature +import org.jetbrains.kotlin.idea.facet.configureFacet +import org.jetbrains.kotlin.idea.facet.getOrCreateFacet import org.jetbrains.kotlin.idea.test.DirectiveBasedActionUtils import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase import org.jetbrains.kotlin.idea.util.application.executeWriteCommand @@ -73,6 +78,20 @@ abstract class AbstractLocalInspectionTest : KotlinLightCodeInsightFixtureTestCa val fileText = FileUtil.loadFile(mainFile, true) TestCase.assertTrue("\"\" is missing in file \"$mainFile\"", fileText.contains("")) + val version = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// LANGUAGE_VERSION: ") + if (version != null) { + val accessToken = WriteAction.start() + try { + val modelsProvider = IdeModifiableModelsProviderImpl(project) + val facet = module.getOrCreateFacet(modelsProvider, useProjectSettings = false) + facet.configureFacet(version, LanguageFeature.State.DISABLED, null, modelsProvider) + modelsProvider.commit() + } + finally { + accessToken.finish() + } + } + val minJavaVersion = InTextDirectivesUtils.findStringWithPrefixes(fileText, "// MIN_JAVA_VERSION: ") if (minJavaVersion != null && !SystemInfo.isJavaVersionAtLeast(minJavaVersion)) return