Skip to content

Commit

Permalink
fix(shirelang): add empty intentions check and change error level in …
Browse files Browse the repository at this point in the history
…ShireIntentionHelper

This commit adds a check for empty intentions in ShireIntentionHelper and changes the logging level from error to warning when the popup fails to show.
  • Loading branch information
phodal committed Sep 12, 2024
1 parent 461361d commit badc42c
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@ class ShireIntentionHelper : IntentionAction, Iconable {

override fun invoke(project: Project, editor: Editor, file: PsiFile) {
val intentions = getAiAssistantIntentions(file, null)
if (intentions.isEmpty()) return

val title = ShireMainBundle.message("intentions.assistant.popup.title")
val popupStep = CustomPopupStep(intentions, project, editor, file, title)
try {
val popup = JBPopupFactory.getInstance().createListPopup(popupStep)
popup.showInBestPositionFor(editor)
} catch (e: Exception) {
logger<ShireIntentionHelper>().error("Failed to show popup", e)
logger<ShireIntentionHelper>().warn("Failed to show popup", e)
}
}

Expand Down

0 comments on commit badc42c

Please sign in to comment.