Use Jsr305State.DEFAULT instead of IGNORE as a default value
This commit is contained in:
+1
-1
@@ -44,7 +44,7 @@ object IDELanguageSettingsProvider : LanguageSettingsProvider {
|
|||||||
val compilerArguments = settings.mergedCompilerArguments as? K2JVMCompilerArguments ?: continue
|
val compilerArguments = settings.mergedCompilerArguments as? K2JVMCompilerArguments ?: continue
|
||||||
|
|
||||||
val jsr305state = Jsr305State.findByDescription(compilerArguments.jsr305)
|
val jsr305state = Jsr305State.findByDescription(compilerArguments.jsr305)
|
||||||
if (jsr305state != null && jsr305state != Jsr305State.IGNORE) {
|
if (jsr305state != null && jsr305state != Jsr305State.DEFAULT) {
|
||||||
map.put(AnalysisFlag.jsr305, jsr305state)
|
map.put(AnalysisFlag.jsr305, jsr305state)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
import foo.A
|
||||||
|
|
||||||
|
fun main(a: A) {
|
||||||
|
<warning descr="[NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS] Expected type does not accept nulls in Kotlin, but the value may be null in Java">a.field</warning>.length
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
import foo.A
|
||||||
|
|
||||||
|
fun main(a: A) {
|
||||||
|
a.field.length
|
||||||
|
}
|
||||||
Vendored
@@ -0,0 +1,5 @@
|
|||||||
|
import foo.A
|
||||||
|
|
||||||
|
fun main(a: A) {
|
||||||
|
<warning descr="[NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS] Expected type does not accept nulls in Kotlin, but the value may be null in Java">a.field</warning>.length
|
||||||
|
}
|
||||||
@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.idea.highlighter
|
|||||||
import com.intellij.openapi.module.Module
|
import com.intellij.openapi.module.Module
|
||||||
import com.intellij.openapi.roots.ModifiableRootModel
|
import com.intellij.openapi.roots.ModifiableRootModel
|
||||||
import com.intellij.testFramework.LightProjectDescriptor
|
import com.intellij.testFramework.LightProjectDescriptor
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
|
||||||
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime
|
import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime
|
||||||
import org.jetbrains.kotlin.config.JvmTarget
|
import org.jetbrains.kotlin.config.JvmTarget
|
||||||
import org.jetbrains.kotlin.config.KotlinFacetSettingsProvider
|
import org.jetbrains.kotlin.config.KotlinFacetSettingsProvider
|
||||||
@@ -46,13 +45,36 @@ class Jsr305HighlightingTest : KotlinLightCodeInsightFixtureTestCase() {
|
|||||||
super.configureModule(module, model)
|
super.configureModule(module, model)
|
||||||
module.createFacet(TargetPlatformKind.Jvm(JvmTarget.JVM_1_8))
|
module.createFacet(TargetPlatformKind.Jvm(JvmTarget.JVM_1_8))
|
||||||
val facetSettings = KotlinFacetSettingsProvider.getInstance(project).getInitializedSettings(module)
|
val facetSettings = KotlinFacetSettingsProvider.getInstance(project).getInitializedSettings(module)
|
||||||
(facetSettings.compilerArguments as K2JVMCompilerArguments).jsr305 = Jsr305State.STRICT.description
|
|
||||||
|
facetSettings.apply {
|
||||||
|
val jsrStateByTestName =
|
||||||
|
Jsr305State.findByDescription(getTestName(true)) ?: return@apply
|
||||||
|
|
||||||
|
compilerSettings!!.additionalArguments += " -Xjsr305=${jsrStateByTestName.description}"
|
||||||
|
updateMergedArguments()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun testSimple() {
|
fun testIgnore() {
|
||||||
myFixture.configureByFile("A.kt")
|
doTest()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testWarn() {
|
||||||
|
doTest()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testStrict() {
|
||||||
|
doTest()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun testDefault() {
|
||||||
|
doTest()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun doTest() {
|
||||||
|
myFixture.configureByFile("${getTestName(false)}.kt")
|
||||||
myFixture.checkHighlighting()
|
myFixture.checkHighlighting()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user