1
0
mirror of https://github.com/chylex/IntelliJ-Inspection-Lens.git synced 2025-05-12 23:34:09 +02:00

Optimize processing of inspection descriptions

This commit is contained in:
chylex 2023-01-05 08:37:31 +01:00
parent e2384a98a8
commit 0aff0f49ae
Signed by: chylex
GPG Key ID: 4DE42C8F19A80548

View File

@ -42,13 +42,23 @@ class LensRenderer(info: HighlightInfo) : HintRenderer(null) {
private val ATTRIBUTES_SINGLETON = TextAttributes(null, null, null, null, Font.ITALIC)
private fun getValidDescriptionText(text: String?): String {
return if (text.isNullOrBlank()) " " else addMissingPeriod(StringUtil.unescapeXmlEntities(StringUtil.stripHtml(text, " ")))
return if (text.isNullOrBlank()) " " else addMissingPeriod(convertHtmlToText(text))
}
private fun convertHtmlToText(potentialHtml: String): String {
return potentialHtml
.ifContains('<') { StringUtil.stripHtml(it, " ") }
.ifContains('&', StringUtil::unescapeXmlEntities)
}
private fun addMissingPeriod(text: String): String {
return if (text.endsWith('.')) text else "$text."
}
private inline fun String.ifContains(charToTest: Char, action: (String) -> String): String {
return if (this.contains(charToTest)) action(this) else this
}
private fun fixBaselineForTextRendering(rect: Rectangle) {
rect.y += 1
}