From eeb153d6f8a8a208c99548a8777cf89395d6ab98 Mon Sep 17 00:00:00 2001 From: Aron Griffis Date: Sat, 27 Jul 2024 08:10:53 -0400 Subject: [PATCH] Revert "Set o.e.j.c.compiler.problem.nullUncheckedConversion to ignore by default" This reverts commit 6d8eb7a3677d014fdcf3c4761706832a24f9e68c. --- .../core/internal/preferences/Preferences.java | 2 -- .../internal/preferences/NullAnalysisTest.java | 18 ++++-------------- .../preferences/PreferenceManagerTest.java | 1 - 3 files changed, 4 insertions(+), 17 deletions(-) diff --git a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/preferences/Preferences.java b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/preferences/Preferences.java index 775a513cee..1072c46b15 100644 --- a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/preferences/Preferences.java +++ b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/preferences/Preferences.java @@ -2624,7 +2624,6 @@ private Map generateProjectNullAnalysisOptions(String nonnullTyp options.put(JavaCore.COMPILER_PB_NULL_SPECIFICATION_VIOLATION, defaultOptions.get(JavaCore.COMPILER_PB_NULL_SPECIFICATION_VIOLATION)); options.put(JavaCore.COMPILER_PB_NULL_ANNOTATION_INFERENCE_CONFLICT, defaultOptions.get(JavaCore.COMPILER_PB_NULL_ANNOTATION_INFERENCE_CONFLICT)); options.put(JavaCore.COMPILER_PB_SYNTACTIC_NULL_ANALYSIS_FOR_FIELDS, defaultOptions.get(JavaCore.COMPILER_PB_SYNTACTIC_NULL_ANALYSIS_FOR_FIELDS)); - options.put(JavaCore.COMPILER_PB_NULL_UNCHECKED_CONVERSION, defaultOptions.get(JavaCore.COMPILER_PB_NULL_UNCHECKED_CONVERSION)); } else { options.put(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, "enabled"); options.put(JavaCore.COMPILER_NONNULL_ANNOTATION_NAME, nonnullType != null ? nonnullType : ""); @@ -2636,7 +2635,6 @@ private Map generateProjectNullAnalysisOptions(String nonnullTyp options.put(JavaCore.COMPILER_PB_NULL_ANNOTATION_INFERENCE_CONFLICT, "warning"); options.put(JavaCore.COMPILER_PB_MISSING_NONNULL_BY_DEFAULT_ANNOTATION, "ignore"); options.put(JavaCore.COMPILER_PB_SYNTACTIC_NULL_ANALYSIS_FOR_FIELDS, JavaCore.ENABLED); - options.put(JavaCore.COMPILER_PB_NULL_UNCHECKED_CONVERSION, JavaCore.IGNORE); } return options; } diff --git a/org.eclipse.jdt.ls.tests/src/org/eclipse/jdt/ls/core/internal/preferences/NullAnalysisTest.java b/org.eclipse.jdt.ls.tests/src/org/eclipse/jdt/ls/core/internal/preferences/NullAnalysisTest.java index 78cc55f558..34aa9317f3 100644 --- a/org.eclipse.jdt.ls.tests/src/org/eclipse/jdt/ls/core/internal/preferences/NullAnalysisTest.java +++ b/org.eclipse.jdt.ls.tests/src/org/eclipse/jdt/ls/core/internal/preferences/NullAnalysisTest.java @@ -20,7 +20,6 @@ import java.io.ByteArrayInputStream; import java.util.Collections; -import java.util.Hashtable; import java.util.List; import java.util.Map; @@ -108,21 +107,12 @@ public void testMixedNullAnalysis() throws Exception { assertTrue(marker.getResource() instanceof IFile); assertEquals("TestJDT.java", ((IFile) marker1.getResource()).getFullPath().lastSegment()); IMarker marker2 = getWarningMarker(project, "The return type is incompatible with '@Nonnull String' returned from TestJavax.A.nonnullMethod() (mismatching null constraints)"); - assertNotNull(marker2); - assertTrue(marker2.getResource() instanceof IFile); + assertNotNull(marker); + assertTrue(marker.getResource() instanceof IFile); assertEquals("TestJavax.java", ((IFile) marker2.getResource()).getFullPath().lastSegment()); IMarker marker3 = getWarningMarker(project, "Null type safety: The expression of type 'List' needs unchecked conversion to conform to '@Nonnull List'"); - assertNull(marker3); - IJavaProject javaProject = JavaCore.create(project); - Map options = javaProject.getOptions(true); - assertEquals(JavaCore.IGNORE, options.get(JavaCore.COMPILER_PB_NULL_UNCHECKED_CONVERSION)); - Hashtable defaultOptions = JavaCore.getDefaultOptions(); - options.put(JavaCore.COMPILER_PB_NULL_UNCHECKED_CONVERSION, defaultOptions.get(JavaCore.COMPILER_PB_NULL_UNCHECKED_CONVERSION)); - javaProject.setOptions(options); - waitForBackgroundJobs(); - marker3 = getWarningMarker(project, "Null type safety: The expression of type 'List' needs unchecked conversion to conform to '@Nonnull List'"); - assertNotNull(marker3); - assertTrue(marker3.getResource() instanceof IFile); + assertNotNull(marker); + assertTrue(marker.getResource() instanceof IFile); assertEquals("TestJavax.java", ((IFile) marker3.getResource()).getFullPath().lastSegment()); assertNoErrors(project); } finally { diff --git a/org.eclipse.jdt.ls.tests/src/org/eclipse/jdt/ls/core/internal/preferences/PreferenceManagerTest.java b/org.eclipse.jdt.ls.tests/src/org/eclipse/jdt/ls/core/internal/preferences/PreferenceManagerTest.java index add7cb37ba..32bd377a88 100644 --- a/org.eclipse.jdt.ls.tests/src/org/eclipse/jdt/ls/core/internal/preferences/PreferenceManagerTest.java +++ b/org.eclipse.jdt.ls.tests/src/org/eclipse/jdt/ls/core/internal/preferences/PreferenceManagerTest.java @@ -379,5 +379,4 @@ public void testTelemetrySettings() throws Exception { assertEquals(false, preferenceManager.getPreferences().isTelemetryEnabled()); } } - }