Jspecify: Rename codeanalysis annotations to jspecify ones

This commit is contained in:
Victor Petukhov
2020-10-08 11:41:30 +03:00
parent 59bd7364ab
commit 2685c7efce
36 changed files with 107 additions and 313 deletions
@@ -25,7 +25,7 @@ class JavaTypeEnhancementStateParser(private val collector: MessageCollector) {
fun parse(
jsr305Args: Array<String>?,
supportCompatqualCheckerFrameworkAnnotations: String?,
codeAnalysisState: String?
jspecifyState: String?
): JavaTypeEnhancementState {
val jsr305State = parseJsr305State(jsr305Args)
@@ -42,29 +42,29 @@ class JavaTypeEnhancementStateParser(private val collector: MessageCollector) {
}
}
val codeAnalysisReportLevel = parseCodeAnalysisReportLevel(codeAnalysisState)
val jspecifyReportLevel = parseJspecifyReportLevel(jspecifyState)
val state = JavaTypeEnhancementState(
jsr305State.global ?: ReportLevel.WARN, jsr305State.migration, jsr305State.usedDefined,
enableCompatqualCheckerFrameworkAnnotations =
enableCompatqualCheckerFrameworkAnnotations
?: JavaTypeEnhancementState.COMPATQUAL_CHECKER_FRAMEWORK_ANNOTATIONS_SUPPORT_DEFAULT_VALUE,
jspecifyReportLevel = codeAnalysisReportLevel
jspecifyReportLevel = jspecifyReportLevel
)
return if (state == JavaTypeEnhancementState.DISABLED_JSR_305) JavaTypeEnhancementState.DISABLED_JSR_305 else state
}
private fun parseCodeAnalysisReportLevel(codeAnalysisState: String?): ReportLevel {
if (codeAnalysisState == null) return JavaTypeEnhancementState.DEFAULT_REPORT_LEVEL_FOR_CODE_ANALYSIS
val reportLevel = ReportLevel.findByDescription(codeAnalysisState)
private fun parseJspecifyReportLevel(jspecifyState: String?): ReportLevel {
if (jspecifyState == null) return JavaTypeEnhancementState.DEFAULT_REPORT_LEVEL_FOR_JSPECIFY
val reportLevel = ReportLevel.findByDescription(jspecifyState)
if (reportLevel == null) {
collector.report(
CompilerMessageSeverity.ERROR,
"Unrecognized -Xcodeanalysis-annotations option: $codeAnalysisState. Possible values are 'disable'/'warn'/'strict'"
"Unrecognized -Xjspecify-annotations option: $jspecifyState. Possible values are 'disable'/'warn'/'strict'"
)
return JavaTypeEnhancementState.DEFAULT_REPORT_LEVEL_FOR_CODE_ANALYSIS
return JavaTypeEnhancementState.DEFAULT_REPORT_LEVEL_FOR_JSPECIFY
}
return reportLevel
-7
View File
@@ -1,7 +0,0 @@
@codeanalysis.experimental.annotations.DefaultNotNull
public class A {
public void foo(String x) {}
@codeanalysis.experimental.annotations.Nullable
public String bar() { return null; }
}
-7
View File
@@ -1,7 +0,0 @@
compiler/testData/cli/jvm/codeanalysisUsage.kt:2:11: warning: type mismatch: inferred type is Nothing? but String was expected
a.foo(null)
^
compiler/testData/cli/jvm/codeanalysisUsage.kt:3:5: warning: unsafe use of a nullable receiver of type String?
a.bar().hashCode()
^
OK
-6
View File
@@ -1,6 +0,0 @@
-Xcodeanalysis-annotations=ignore
$TESTDATA_DIR$/codeanalysisUsage.kt
$TESTDATA_DIR$/codeanalysis
$FOREIGN_ANNOTATIONS_DIR$
-d
$TEMP_DIR$
-6
View File
@@ -1,6 +0,0 @@
-Xcodeanalysis-annotations=strict
$TESTDATA_DIR$/codeanalysisUsage.kt
$TESTDATA_DIR$/codeanalysis
$FOREIGN_ANNOTATIONS_DIR$
-d
$TEMP_DIR$
+3 -3
View File
@@ -12,9 +12,6 @@ where advanced options include:
-Xassertions=legacy: calculate condition on each call, check depends on jvm assertion settings in the kotlin package;
default: legacy
-Xbuild-file=<path> Path to the .xml build file to compile
-Xcodeanalysis-annotations=ignore|strict|warn
Specify behavior for Codeanalysis annotations.
Default value is 'warn'
-Xcompile-java Reuse javac analysis and compile Java source files
-Xnormalize-constructor-calls={disable|enable}
Normalize constructor calls (disable: don't normalize; enable: normalize),
@@ -32,6 +29,9 @@ where advanced options include:
-Xjava-package-prefix Package prefix for Java files
-Xjava-source-roots=<path> Paths to directories with Java source files
-Xjavac-arguments=<option[,]> Java compiler arguments
-Xjspecify-annotations=ignore|strict|warn
Specify behavior for jspecify annotations.
Default value is 'warn'
-Xjsr305={ignore/strict/warn}|under-migration:{ignore/strict/warn}|@<fq.name>:{ignore/strict/warn}
Specify behavior for JSR-305 nullability annotations:
-Xjsr305={ignore/strict/warn} globally (all non-@UnderMigration annotations)
+7
View File
@@ -0,0 +1,7 @@
@org.jspecify.annotations.DefaultNotNull
public class A {
public void foo(String x) {}
@org.jspecify.annotations.Nullable
public String bar() { return null; }
}
+6
View File
@@ -0,0 +1,6 @@
-Xjspecify-annotations=ignore
$TESTDATA_DIR$/jspecifyUsage.kt
$TESTDATA_DIR$/jspecify
$FOREIGN_ANNOTATIONS_DIR$
-d
$TEMP_DIR$
+6
View File
@@ -0,0 +1,6 @@
-Xjspecify-annotations=strict
$TESTDATA_DIR$/jspecifyUsage.kt
$TESTDATA_DIR$/jspecify
$FOREIGN_ANNOTATIONS_DIR$
-d
$TEMP_DIR$
@@ -1,6 +1,6 @@
-Xjspecify-annotations=warn
$TESTDATA_DIR$/codeanalysisUsage.kt
$TESTDATA_DIR$/codeanalysis
$TESTDATA_DIR$/jspecifyUsage.kt
$TESTDATA_DIR$/jspecify
$FOREIGN_ANNOTATIONS_DIR$
-d
$TEMP_DIR$
+7
View File
@@ -0,0 +1,7 @@
compiler/testData/cli/jvm/jspecifyUsage.kt:2:11: warning: type mismatch: inferred type is Nothing? but String was expected
a.foo(null)
^
compiler/testData/cli/jvm/jspecifyUsage.kt:3:5: warning: unsafe use of a nullable receiver of type String?
a.bar().hashCode()
^
OK
@@ -1,5 +1,5 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
// CODE_ANALYSIS_STATE ignore
// JSPECIFY_STATE ignore
// FILE: A.java
import org.jspecify.annotations.*;
@@ -28,7 +28,7 @@ public class C {
import org.jspecify.annotations.*;
@DefaultUnknownNullness
@DefaultNullnessUnknown
public class D {
public void bar(A<String, String, String> a) {}
}
@@ -1,5 +1,5 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
// CODE_ANALYSIS_STATE warn
// JSPECIFY_STATE warn
// FILE: A.java
import org.jspecify.annotations.*;
@@ -1,5 +1,5 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
// CODE_ANALYSIS_STATE warn
// JSPECIFY_STATE warn
// FILE: A.java
import org.jspecify.annotations.*;
@@ -1,5 +1,5 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
// CODE_ANALYSIS_STATE warn
// JSPECIFY_STATE warn
// FILE: A.java
import org.jspecify.annotations.*;
@@ -1,5 +1,5 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
// CODE_ANALYSIS_STATE warn
// JSPECIFY_STATE warn
// FILE: A.java
import org.jspecify.annotations.*;
@@ -1,5 +1,5 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
// CODE_ANALYSIS_STATE warn
// JSPECIFY_STATE warn
// FILE: A.java
import org.jspecify.annotations.*;
@@ -1,5 +1,5 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
// CODE_ANALYSIS_STATE warn
// JSPECIFY_STATE warn
// FILE: A.java
import org.jspecify.annotations.*;
@@ -1,5 +1,5 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
// CODE_ANALYSIS_STATE warn
// JSPECIFY_STATE warn
// FILE: A.java
import org.jspecify.annotations.*;
@@ -1,5 +1,5 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
// CODE_ANALYSIS_STATE warn
// JSPECIFY_STATE warn
// FILE: A.java
import org.jspecify.annotations.*;
@@ -31,7 +31,7 @@ abstract class AbstractForeignAnnotationsTest : AbstractDiagnosticsTest() {
private val JSR305_GLOBAL_DIRECTIVE = "JSR305_GLOBAL_REPORT"
private val JSR305_MIGRATION_DIRECTIVE = "JSR305_MIGRATION_REPORT"
private val JSR305_SPECIAL_DIRECTIVE = "JSR305_SPECIAL_REPORT"
private val CODE_ANALYSIS_STATE_SPECIAL_DIRECTIVE = "CODE_ANALYSIS_STATE"
private val JSPECIFY_STATE_SPECIAL_DIRECTIVE = "JSPECIFY_STATE"
override fun getExtraClasspath(): List<File> {
val foreignAnnotations = createJarWithForeignAnnotations()
@@ -77,14 +77,14 @@ abstract class AbstractForeignAnnotationsTest : AbstractDiagnosticsTest() {
name to state
}.toMap()
val codeAnalysisReportLevel = module.getDirectiveValue(CODE_ANALYSIS_STATE_SPECIAL_DIRECTIVE) ?: ReportLevel.STRICT
val jspecifyReportLevel = module.getDirectiveValue(JSPECIFY_STATE_SPECIAL_DIRECTIVE) ?: ReportLevel.STRICT
return mapOf(
JvmAnalysisFlags.javaTypeEnhancementState to JavaTypeEnhancementState(
globalState,
migrationState,
userAnnotationsState,
jspecifyReportLevel = codeAnalysisReportLevel
jspecifyReportLevel = jspecifyReportLevel
)
)
}
@@ -25,7 +25,7 @@ public class ForeignJava8AnnotationsNoAnnotationInClasspathTestGenerated extends
}
public void testAllFilesPresentInTests() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/foreignAnnotationsJava8/tests"), Pattern.compile("^(.+)\\.kt$"), null, true);
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/foreignAnnotationsJava8/tests"), Pattern.compile("^(.+)\\.kt$"), null, true, "jspecify");
}
@TestMetadata("checkerFramework.kt")
@@ -43,122 +43,6 @@ public class ForeignJava8AnnotationsNoAnnotationInClasspathTestGenerated extends
runTest("compiler/testData/foreignAnnotationsJava8/tests/typeUseOnObject.kt");
}
@TestMetadata("compiler/testData/foreignAnnotationsJava8/tests/jspecify")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Jspecify extends AbstractForeignJava8AnnotationsNoAnnotationInClasspathTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInJspecify() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/foreignAnnotationsJava8/tests/jspecify"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@TestMetadata("annotatedWildcards.kt")
public void testAnnotatedWildcards() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/annotatedWildcards.kt");
}
@TestMetadata("defaults.kt")
public void testDefaults() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/defaults.kt");
}
@TestMetadata("ignoreAnnotations.kt")
public void testIgnoreAnnotations() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/ignoreAnnotations.kt");
}
@TestMetadata("nonPlatformTypeParameter.kt")
public void testNonPlatformTypeParameter() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/nonPlatformTypeParameter.kt");
}
@TestMetadata("selfType.kt")
public void testSelfType() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/selfType.kt");
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/simple.kt");
}
@TestMetadata("typeArgumentsFromParameterBounds.kt")
public void testTypeArgumentsFromParameterBounds() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/typeArgumentsFromParameterBounds.kt");
}
@TestMetadata("typeParameterBounds.kt")
public void testTypeParameterBounds() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/typeParameterBounds.kt");
}
@TestMetadata("unknownNullnessTypeParameter.kt")
public void testUnknownNullnessTypeParameter() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/unknownNullnessTypeParameter.kt");
}
@TestMetadata("wildcardsWithDefault.kt")
public void testWildcardsWithDefault() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/wildcardsWithDefault.kt");
}
@TestMetadata("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Warnings extends AbstractForeignJava8AnnotationsNoAnnotationInClasspathTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInWarnings() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@TestMetadata("annotatedWildcards.kt")
public void testAnnotatedWildcards() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings/annotatedWildcards.kt");
}
@TestMetadata("defaults.kt")
public void testDefaults() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings/defaults.kt");
}
@TestMetadata("nonPlatformTypeParameter.kt")
public void testNonPlatformTypeParameter() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings/nonPlatformTypeParameter.kt");
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings/simple.kt");
}
@TestMetadata("typeArgumentsFromParameterBounds.kt")
public void testTypeArgumentsFromParameterBounds() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings/typeArgumentsFromParameterBounds.kt");
}
@TestMetadata("typeParameterBounds.kt")
public void testTypeParameterBounds() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings/typeParameterBounds.kt");
}
@TestMetadata("unknownNullnessTypeParameter.kt")
public void testUnknownNullnessTypeParameter() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings/unknownNullnessTypeParameter.kt");
}
@TestMetadata("wildcardsWithDefault.kt")
public void testWildcardsWithDefault() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings/wildcardsWithDefault.kt");
}
}
}
@TestMetadata("compiler/testData/foreignAnnotationsJava8/tests/jsr305")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -25,7 +25,7 @@ public class ForeignJava8AnnotationsNoAnnotationInClasspathWithPsiClassReadingTe
}
public void testAllFilesPresentInTests() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/foreignAnnotationsJava8/tests"), Pattern.compile("^(.+)\\.kt$"), null, true);
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/foreignAnnotationsJava8/tests"), Pattern.compile("^(.+)\\.kt$"), null, true, "jspecify");
}
@TestMetadata("checkerFramework.kt")
@@ -43,122 +43,6 @@ public class ForeignJava8AnnotationsNoAnnotationInClasspathWithPsiClassReadingTe
runTest("compiler/testData/foreignAnnotationsJava8/tests/typeUseOnObject.kt");
}
@TestMetadata("compiler/testData/foreignAnnotationsJava8/tests/jspecify")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Jspecify extends AbstractForeignJava8AnnotationsNoAnnotationInClasspathWithPsiClassReadingTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInJspecify() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/foreignAnnotationsJava8/tests/jspecify"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@TestMetadata("annotatedWildcards.kt")
public void testAnnotatedWildcards() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/annotatedWildcards.kt");
}
@TestMetadata("defaults.kt")
public void testDefaults() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/defaults.kt");
}
@TestMetadata("ignoreAnnotations.kt")
public void testIgnoreAnnotations() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/ignoreAnnotations.kt");
}
@TestMetadata("nonPlatformTypeParameter.kt")
public void testNonPlatformTypeParameter() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/nonPlatformTypeParameter.kt");
}
@TestMetadata("selfType.kt")
public void testSelfType() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/selfType.kt");
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/simple.kt");
}
@TestMetadata("typeArgumentsFromParameterBounds.kt")
public void testTypeArgumentsFromParameterBounds() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/typeArgumentsFromParameterBounds.kt");
}
@TestMetadata("typeParameterBounds.kt")
public void testTypeParameterBounds() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/typeParameterBounds.kt");
}
@TestMetadata("unknownNullnessTypeParameter.kt")
public void testUnknownNullnessTypeParameter() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/unknownNullnessTypeParameter.kt");
}
@TestMetadata("wildcardsWithDefault.kt")
public void testWildcardsWithDefault() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/wildcardsWithDefault.kt");
}
@TestMetadata("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Warnings extends AbstractForeignJava8AnnotationsNoAnnotationInClasspathWithPsiClassReadingTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInWarnings() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
@TestMetadata("annotatedWildcards.kt")
public void testAnnotatedWildcards() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings/annotatedWildcards.kt");
}
@TestMetadata("defaults.kt")
public void testDefaults() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings/defaults.kt");
}
@TestMetadata("nonPlatformTypeParameter.kt")
public void testNonPlatformTypeParameter() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings/nonPlatformTypeParameter.kt");
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings/simple.kt");
}
@TestMetadata("typeArgumentsFromParameterBounds.kt")
public void testTypeArgumentsFromParameterBounds() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings/typeArgumentsFromParameterBounds.kt");
}
@TestMetadata("typeParameterBounds.kt")
public void testTypeParameterBounds() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings/typeParameterBounds.kt");
}
@TestMetadata("unknownNullnessTypeParameter.kt")
public void testUnknownNullnessTypeParameter() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings/unknownNullnessTypeParameter.kt");
}
@TestMetadata("wildcardsWithDefault.kt")
public void testWildcardsWithDefault() throws Exception {
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings/wildcardsWithDefault.kt");
}
}
}
@TestMetadata("compiler/testData/foreignAnnotationsJava8/tests/jsr305")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -105,6 +105,19 @@ public class ForeignJava8AnnotationsTestGenerated extends AbstractForeignJava8An
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/wildcardsWithDefault.kt");
}
@TestMetadata("compiler/testData/foreignAnnotationsJava8/tests/jspecify/kotlin")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Kotlin extends AbstractForeignJava8AnnotationsTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInKotlin() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/foreignAnnotationsJava8/tests/jspecify/kotlin"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
}
@TestMetadata("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -105,6 +105,19 @@ public class JavacForeignJava8AnnotationsTestGenerated extends AbstractJavacFore
runTest("compiler/testData/foreignAnnotationsJava8/tests/jspecify/wildcardsWithDefault.kt");
}
@TestMetadata("compiler/testData/foreignAnnotationsJava8/tests/jspecify/kotlin")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Kotlin extends AbstractJavacForeignJava8AnnotationsTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
public void testAllFilesPresentInKotlin() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/foreignAnnotationsJava8/tests/jspecify/kotlin"), Pattern.compile("^(.+)\\.kt$"), null, true);
}
}
@TestMetadata("compiler/testData/foreignAnnotationsJava8/tests/jspecify/warnings")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -40,11 +40,11 @@ fun main(args: Array<String>) {
}
testClass<AbstractForeignJava8AnnotationsNoAnnotationInClasspathTest> {
model("foreignAnnotationsJava8/tests")
model("foreignAnnotationsJava8/tests", excludeDirs = listOf("jspecify"))
}
testClass<AbstractForeignJava8AnnotationsNoAnnotationInClasspathWithPsiClassReadingTest> {
model("foreignAnnotationsJava8/tests")
model("foreignAnnotationsJava8/tests", excludeDirs = listOf("jspecify"))
}
testClass<AbstractLoadJava8Test> {
+20 -20
View File
@@ -115,26 +115,6 @@ public class CliTestGenerated extends AbstractCliTest {
runTest("compiler/testData/cli/jvm/classpath.args");
}
@TestMetadata("codeanalysisDefault.args")
public void testCodeanalysisDefault() throws Exception {
runTest("compiler/testData/cli/jvm/codeanalysisDefault.args");
}
@TestMetadata("codeanalysisIgnore.args")
public void testCodeanalysisIgnore() throws Exception {
runTest("compiler/testData/cli/jvm/codeanalysisIgnore.args");
}
@TestMetadata("codeanalysisStrict.args")
public void testCodeanalysisStrict() throws Exception {
runTest("compiler/testData/cli/jvm/codeanalysisStrict.args");
}
@TestMetadata("codeanalysisWarn.args")
public void testCodeanalysisWarn() throws Exception {
runTest("compiler/testData/cli/jvm/codeanalysisWarn.args");
}
@TestMetadata("compatqualDefault.args")
public void testCompatqualDefault() throws Exception {
runTest("compiler/testData/cli/jvm/compatqualDefault.args");
@@ -445,6 +425,26 @@ public class CliTestGenerated extends AbstractCliTest {
runTest("compiler/testData/cli/jvm/jdkPathDoesNotExist.args");
}
@TestMetadata("jspecifyDefault.args")
public void testJspecifyDefault() throws Exception {
runTest("compiler/testData/cli/jvm/jspecifyDefault.args");
}
@TestMetadata("jspecifyIgnore.args")
public void testJspecifyIgnore() throws Exception {
runTest("compiler/testData/cli/jvm/jspecifyIgnore.args");
}
@TestMetadata("jspecifyStrict.args")
public void testJspecifyStrict() throws Exception {
runTest("compiler/testData/cli/jvm/jspecifyStrict.args");
}
@TestMetadata("jspecifyWarn.args")
public void testJspecifyWarn() throws Exception {
runTest("compiler/testData/cli/jvm/jspecifyWarn.args");
}
@TestMetadata("jsr305AllIgnore.args")
public void testJsr305AllIgnore() throws Exception {
runTest("compiler/testData/cli/jvm/jsr305AllIgnore.args");
@@ -31,7 +31,7 @@ val DEFAULT_JSPECIFY_APPLICABILITY = listOf(
AnnotationQualifierApplicabilityType.TYPE_USE
)
val CODE_ANALYSIS_DEFAULT_ANNOTATIONS = mapOf(
val JSPECIFY_DEFAULT_ANNOTATIONS = mapOf(
JSPECIFY_DEFAULT_NULLABLE to JavaDefaultQualifiers(
NullabilityQualifierWithMigrationStatus(NullabilityQualifier.NULLABLE),
DEFAULT_JSPECIFY_APPLICABILITY
@@ -58,6 +58,6 @@ val BUILT_IN_TYPE_QUALIFIER_DEFAULT_ANNOTATIONS = mapOf(
NullabilityQualifierWithMigrationStatus(NullabilityQualifier.NOT_NULL),
listOf(AnnotationQualifierApplicabilityType.VALUE_PARAMETER)
)
) + CODE_ANALYSIS_DEFAULT_ANNOTATIONS
) + JSPECIFY_DEFAULT_ANNOTATIONS
val BUILT_IN_TYPE_QUALIFIER_FQ_NAMES = setOf(JAVAX_NONNULL_ANNOTATION, JAVAX_CHECKFORNULL_ANNOTATION)
@@ -92,7 +92,7 @@ class AnnotationTypeQualifierResolver(storageManager: StorageManager, private va
}
private fun resolveDefaultAnnotationState(annotationDescriptor: AnnotationDescriptor): ReportLevel {
if (annotationDescriptor.fqName in CODE_ANALYSIS_DEFAULT_ANNOTATIONS) {
if (annotationDescriptor.fqName in JSPECIFY_DEFAULT_ANNOTATIONS) {
return javaTypeEnhancementState.jspecifyReportLevel
}
@@ -35,7 +35,7 @@ class JavaTypeEnhancementState(
val migrationLevelForJsr305: ReportLevel?,
val userDefinedLevelForSpecificJsr305Annotation: Map<String, ReportLevel>,
val enableCompatqualCheckerFrameworkAnnotations: Boolean = COMPATQUAL_CHECKER_FRAMEWORK_ANNOTATIONS_SUPPORT_DEFAULT_VALUE,
val jspecifyReportLevel: ReportLevel = DEFAULT_REPORT_LEVEL_FOR_CODE_ANALYSIS
val jspecifyReportLevel: ReportLevel = DEFAULT_REPORT_LEVEL_FOR_JSPECIFY
) {
val description: Array<String> by lazy {
val result = mutableListOf<String>()
@@ -61,7 +61,7 @@ class JavaTypeEnhancementState(
const val COMPATQUAL_CHECKER_FRAMEWORK_ANNOTATIONS_SUPPORT_DEFAULT_VALUE = true
@JvmField
val DEFAULT_REPORT_LEVEL_FOR_CODE_ANALYSIS = ReportLevel.WARN
val DEFAULT_REPORT_LEVEL_FOR_JSPECIFY = ReportLevel.WARN
@JvmField
val DEFAULT: JavaTypeEnhancementState = JavaTypeEnhancementState(ReportLevel.WARN, null, emptyMap())