idea-plugin / arrow.meta.ide.dsl.editor.inspection / InspectionSyntax

InspectionSyntax

interface InspectionSyntax : InspectionUtilitySyntax

Loosely speaking, Inspection's are easily recognized as “QuickFixes” when the user hit’s a KeyShortCut for missing imports. Interestingly enough, despite calling Inspection's proverbially “QuickFixes”, IntelliJ defines a QuickFix as an aggregation of multiple Intention's. Whereas Intention's analysis your code and users can decide whether they want to apply a suggested Fix, Inspection’s improve upon that very idea and are capable to block the user to compile code at the first place. Additionally, we can scope the Fix in applyTo locally, for each instance per file, or globally to the whole project, assuming it has a universal refactoring task. There are cases, where an universal Fix, might not be obvious, but that doesn’t stop plugin developer’s to notify and direct user’s to helpful resources about this problem.

See Also

addApplicableInspection

Functions

addApplicableInspection registers a Local ApplicableInspection and has KtPsiFactory in Scope to modify the element, project or editor at once within applyTo. The following example is a simplified purityPlugin, where every function that returns Unit has to be suspended. Otherwise the code can not be compiled.open fun <K : KtElement> MetaIde.addApplicableInspection(defaultFixText: String, staticDescription: String?, fixText: (element: K) -> String, kClass: Class<K> = KtElement::class.java as Class<K>, highlightingRange: (element: K) -> TextRange? = Noop.nullable1(), inspectionText: (element: K) -> String, applyTo: KtPsiFactory.(element: K, project: Project, editor: Editor?) -> Unit, isApplicable: (element: K) -> Boolean, groupPath: Array<String>, groupDisplayName: String, inspectionHighlightType: (element: K) -> ProblemHighlightType = { _ -> ProblemHighlightType.GENERIC_ERROR_OR_WARNING }, level: HighlightDisplayLevel = HighlightDisplayLevel.WEAK_WARNING, enabledByDefault: Boolean = true): ExtensionPhase
addGlobalInspection registers a GlobalInspection. InspectionEP is once again a wrapper over the actual GlobalInspectionTool.open fun MetaIde.addGlobalInspection(inspectionTool: GlobalInspectionTool, level: HighlightDisplayLevel, shortName: String, displayName: String, groupPath: Array<String>, groupDisplayName: String): ExtensionPhase
addInspectionSuppressor registers an InspectionSuppressor for the specified PsiElement.open fun MetaIde.addInspectionSuppressor(suppressFor: (element: PsiElement, toolId: String) -> Boolean, suppressAction: (element: PsiElement?, toolId: String) -> List<SuppressQuickFix>): ExtensionPhase
addLocalInspection open fun <K : KtElement> MetaIde.addLocalInspection(inspection: AbstractApplicabilityBasedInspection<K>, groupPath: Array<String>, groupDisplayName: String, level: HighlightDisplayLevel = HighlightDisplayLevel.WEAK_WARNING): ExtensionPhase
registers a LocalInspection. LocalInspectionEP is solely a wrapper over the generic InspectionProfileEntry, which is a Subtype of both GlobalInspectionTool and LocalInspectionTool.open fun MetaIde.addLocalInspection(inspectionTool: LocalInspectionTool, level: HighlightDisplayLevel, shortName: String, displayName: String, groupPath: Array<String>, groupDisplayName: String): ExtensionPhase
applicableInspection defaultFixText is being reused for the shortName and it should be matching the pattern ‘a-zA-Z_0-9.-+’ and not so long staticDescription refers to little description of the inspection For the inspection tool dialog description, the name of the html file should match the defaultFixText/shortNameopen fun <K : KtElement> InspectionSyntax.applicableInspection(defaultFixText: String, staticDescription: String?, fixText: (element: K) -> String, kClass: Class<K> = KtElement::class.java as Class<K>, highlightingRange: (element: K) -> TextRange? = Noop.nullable1(), inspectionText: (element: K) -> String, applyTo: KtPsiFactory.(element: K, project: Project, editor: Editor?) -> Unit, isApplicable: (element: K) -> Boolean, inspectionHighlightType: (element: K) -> ProblemHighlightType = { _: K -> ProblemHighlightType.GENERIC_ERROR_OR_WARNING }, enabledByDefault: Boolean = true): AbstractApplicabilityBasedInspection<K>
inspection open fun InspectionSyntax.inspection(inspectionTool: GlobalInspectionTool, level: HighlightDisplayLevel, shortName: String, displayName: String, groupPath: Array<String>, groupDisplayName: String): InspectionEP
inspectionSuppressor open fun InspectionSyntax.inspectionSuppressor(suppressFor: (element: PsiElement, toolId: String) -> Boolean, suppressAction: (element: PsiElement?, toolId: String) -> List<SuppressQuickFix>): InspectionSuppressor
localInspection open fun InspectionSyntax.localInspection(inspectionTool: LocalInspectionTool, level: HighlightDisplayLevel, shortName: String, displayName: String, groupPath: Array<String>, groupDisplayName: String): LocalInspectionEP
suppressQuickFix open fun InspectionSyntax.suppressQuickFix(name: String, familyName: String, applyFix: (project: Project, descriptor: ProblemDescriptor) -> Unit, isAvailable: (project: Project, context: PsiElement) -> Boolean, isSuppressAll: Boolean): SuppressQuickFix

Inheritors

IdeSyntax interface IdeSyntax : IconProviderSyntax, SyntaxHighlighterSyntax, InspectionSyntax, AnActionSyntax, ColorSettingsSyntax, HintingSyntax, LanguageSyntax, LineMarkerSyntax, LiveTemplateSyntax, NavigationSyntax, SearchSyntax, StructureViewSyntax, UsageSyntax, ExtensionProviderSyntax, DocumentationSyntax, DialogSyntax, PopupSyntax, NotificationSyntax, ToolWindowSyntax, GotoRelatedSyntax, AnnotatorSyntax, ParserSyntax, ApplicationSyntax, FoldingSyntax, EditorSyntax, ResolveScopeSyntax, ResolveProviderSyntax, IntegrationSyntax

Do you like Arrow?

Arrow Org
<