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

GitOrigin-RevId: 7d4bedd084b8e0f4ea21f2d604f42303fdc08513
This commit is contained in:
Egor Ushakov
2025-03-13 15:16:06 +01:00
committed by intellij-monorepo-bot
parent 0966838ad1
commit 489fca6fae
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

@@ -368,6 +368,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

@@ -728,9 +728,6 @@ debugger.log.jdi.in.unit.tests.description=Enable full JDI logging under DebugPr
debugger.hotswap.floating.toolbar=true
debugger.hotswap.floating.toolbar.description=Show a floating toolbar with a hot swap button on source change
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.