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:
parent
e2384a98a8
commit
0aff0f49ae
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user