[RDCT] IJPL-162126: Fix availability hints exceptions

`EditorActionAvailabilityHintHandler` adds hints on every highlighter update. If there is a highlighter with action availability hints and subsequent updates, these hints will be added multiple times, causing `logger.error`. The same happens in some other places like `InlinePromptHighlightingPassFactory` which may add hints several times.
This commit changes the assertion from "log error if there is a hint already" to "log error only if there is a *different* hint for this action". It skips already existing hints if they are exactly the same.

GitOrigin-RevId: 83e88ba3a050e291b5634341dd7526620623858f
This commit is contained in:
Vyacheslav Moklev
2024-10-09 17:02:47 +00:00
committed by intellij-monorepo-bot
parent e435d75b2b
commit db7891da87
@@ -161,10 +161,14 @@ private fun UserDataHolderEx.addActionAvailabilityHintImpl(vararg newHints: Edit
putUserDataIfAbsent(hintsKey, hints)
}
for (newHint in newHints) {
if (hints.any { it.actionId == newHint.actionId }) {
logger.error("Availability hint for action '${newHint.actionId}' already exists")
return
val existingHint = hints.find { it.actionId == newHint.actionId }
if (existingHint != null) {
if (existingHint.condition != newHint.condition) {
logger.error("Availability hint for action '${newHint.actionId}' already exists")
}
continue
}
hints.add(newHint)
}
}