-
Notifications
You must be signed in to change notification settings - Fork 653
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a More... link to the tooltip to show the inspection description
- Loading branch information
Showing
3 changed files
with
55 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
intellij-plugin/src/main/kotlin/com/apollographql/ijplugin/util/Inspections.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.apollographql.ijplugin.util | ||
|
||
import com.apollographql.ijplugin.ApolloBundle | ||
import com.intellij.codeInsight.daemon.impl.analysis.DaemonTooltipsUtil | ||
import com.intellij.codeInspection.LocalInspectionTool | ||
import com.intellij.codeInspection.LocalQuickFix | ||
import com.intellij.codeInspection.ProblemDescriptorBase | ||
import com.intellij.codeInspection.ProblemHighlightType | ||
import com.intellij.codeInspection.ProblemsHolder | ||
import com.intellij.psi.PsiElement | ||
|
||
context(LocalInspectionTool) | ||
fun ProblemsHolder.registerProblem( | ||
element: PsiElement, | ||
description: String, | ||
withMoreLink: Boolean, | ||
vararg fixes: LocalQuickFix, | ||
) { | ||
registerProblem(element, description, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, withMoreLink, *fixes) | ||
} | ||
|
||
context(LocalInspectionTool) | ||
fun ProblemsHolder.registerProblem( | ||
element: PsiElement, | ||
description: String, | ||
highlightType: ProblemHighlightType, | ||
withMoreLink: Boolean, | ||
vararg fixes: LocalQuickFix, | ||
) { | ||
if (!withMoreLink) { | ||
registerProblem(element, description, highlightType, *fixes) | ||
return | ||
} | ||
registerProblem( | ||
object : ProblemDescriptorBase( | ||
element, | ||
element, | ||
description, | ||
fixes, | ||
highlightType, | ||
false, | ||
null, | ||
true, | ||
isOnTheFly | ||
) { | ||
override fun getTooltipTemplate(): String { | ||
return "<html>$description <a href=\"#inspection/$shortName\">${ApolloBundle.message("inspection.more")}</a> ${DaemonTooltipsUtil.getShortcutText()}" | ||
} | ||
} | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters