IDEA-368449 Modify NPE message in console for Java 30th anniversary - fixes for review IJ-CR-157699

(cherry picked from commit 7d4bedd084b8e0f4ea21f2d604f42303fdc08513)
(cherry picked from commit cf7435633522f9d259608c07869f4fb56dbe41c3)

GitOrigin-RevId: 3bb18fafc723bfe841fc5f3e28e96011f12ad153
This commit is contained in:
Egor Ushakov
2025-03-13 15:16:06 +01:00
committed by intellij-monorepo-bot
parent 09c679ef2b
commit a0fb854a56
3 changed files with 13 additions and 3 deletions

View File

@@ -6,19 +6,26 @@ import com.intellij.codeInsight.hints.presentation.PresentationRenderer
import com.intellij.execution.filters.Filter.ResultItem
import com.intellij.execution.impl.InlayProvider
import com.intellij.icons.AllIcons
import com.intellij.ide.util.PropertiesComponent
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.editor.EditorCustomElementRenderer
import com.intellij.openapi.editor.Inlay
import com.intellij.openapi.util.registry.Registry
import com.intellij.psi.CommonClassNames
import com.intellij.psi.PsiClass
import java.time.LocalDate
private const val JAVA_EXCEPTIONS_ANNIVERSARY_BANNER_SHOWN = "java.exceptions.anniversary.banner.shown"
class JavaExceptionFilter : JvmExceptionOccurrenceFilter {
override fun applyFilter(
exceptionClassName: String,
classes: MutableList<PsiClass?>,
exceptionStartOffset: Int,
): ResultItem? {
if (exceptionClassName != CommonClassNames.JAVA_LANG_NULL_POINTER_EXCEPTION) {
return null
}
with(Registry.get("java.exceptions.anniversary.banner")) {
if (isOptionEnabled("off")) {
return null
@@ -29,6 +36,11 @@ class JavaExceptionFilter : JvmExceptionOccurrenceFilter {
if (LocalDate.now() !in startDate..endDate) {
return null
}
val counter = PropertiesComponent.getInstance().getInt(JAVA_EXCEPTIONS_ANNIVERSARY_BANNER_SHOWN, 0)
if (counter > 2) {
return null
}
PropertiesComponent.getInstance().setValue(JAVA_EXCEPTIONS_ANNIVERSARY_BANNER_SHOWN, counter + 1, 0)
}
}
return CreateExceptionBreakpointResult(exceptionStartOffset, exceptionStartOffset + exceptionClassName.length)

View File

@@ -427,6 +427,7 @@
<virtualFileSystem implementationClass="com.intellij.openapi.vfs.impl.jrt.JrtFileSystemImpl" key="jrt" physical="true"/>
<registryKey key="use.jdk.vendor.in.suggested.jdk.name" defaultValue="true" description="Include Vendor name in suggested SDK names"/>
<registryKey key="java.exceptions.anniversary.banner" defaultValue="[on*|off|force]" description="Show the java anniversary banner in the console"/>
<sdkType implementation="com.intellij.openapi.projectRoots.impl.JavaSdkImpl"/>

View File

@@ -701,9 +701,6 @@ debugger.hotswap.floating.toolbar.description=Show a floating toolbar with a hot
debugger.hotswap.show.ide.popup=false
debugger.hotswap.show.ide.popup.description=Show hot swap successful notification as a popup, or regular notification otherwise
java.exceptions.anniversary.banner=[on*|off|force]
java.exceptions.anniversary.banner.description=Show the java anniversary banner in the console
index.run.configuration.jre=false
index.run.configuration.jre.restartRequired=true
index.run.configuration.jre.description=Index jre specified in run configuration for goto navigation etc.