diff --git a/src/main/java/com/maddyhome/idea/vim/inspections/UsePlugSyntaxInspection.kt b/src/main/java/com/maddyhome/idea/vim/inspections/UsePlugSyntaxInspection.kt new file mode 100644 index 000000000..88ebfe344 --- /dev/null +++ b/src/main/java/com/maddyhome/idea/vim/inspections/UsePlugSyntaxInspection.kt @@ -0,0 +1,34 @@ +/* + * Copyright 2003-2023 The IdeaVim authors + * + * Use of this source code is governed by an MIT-style + * license that can be found in the LICENSE.txt file or at + * https://opensource.org/licenses/MIT. + */ + +package com.maddyhome.idea.vim.inspections + +import com.intellij.codeInspection.LocalInspectionTool +import com.intellij.codeInspection.ProblemsHolder +import com.intellij.openapi.util.TextRange +import com.intellij.psi.PsiElement +import com.intellij.psi.PsiElementVisitor +import com.intellij.psi.PsiFile +import com.intellij.psi.impl.source.tree.LeafPsiElement + +class UsePlugSyntaxInspection : LocalInspectionTool() { + override fun getGroupDisplayName(): String { + return "Vim" + } + + override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean): PsiElementVisitor { + val file = holder.file + if (file.name != ".ideavimrc" && file.name != "_ideavimrc") return PsiElementVisitor.EMPTY_VISITOR + return object : PsiElementVisitor() { + override fun visitElement(element: PsiElement) { + if (element !is LeafPsiElement) return + holder.registerProblem(element, TextRange.create(10, 20), "Hi there") + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 0d7bc2e74..fc2cd1bef 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -92,6 +92,12 @@ <statistics.applicationUsagesCollector implementation="com.maddyhome.idea.vim.statistic.ShortcutConflictState"/> <statistics.counterUsagesCollector implementationClass="com.maddyhome.idea.vim.statistic.ActionTracker"/> + + +<!-- <localInspection language="textmate" shortName="UsePlug" bundle="messages.IdeaVimBundle"--> +<!-- key="use.plug.inspection.display.name" groupKey="use.plug.inspection.group.display.name"--> +<!-- enabledByDefault="true" level="WARNING"--> +<!-- implementationClass="com.maddyhome.idea.vim.inspections.UsePlugSyntaxInspection"/>--> </extensions> <xi:include href="/META-INF/includes/ApplicationServices.xml" xpointer="xpointer(/idea-plugin/*)"/> diff --git a/src/main/resources/inspectionDescriptions/UsePlug.html b/src/main/resources/inspectionDescriptions/UsePlug.html new file mode 100644 index 000000000..17e3b1aab --- /dev/null +++ b/src/main/resources/inspectionDescriptions/UsePlug.html @@ -0,0 +1,29 @@ +<!-- + ~ Copyright 2003-2023 The IdeaVim authors + ~ + ~ Use of this source code is governed by an MIT-style + ~ license that can be found in the LICENSE.txt file or at + ~ https://opensource.org/licenses/MIT. + --> + +<html> +<body> +Write your description here. +Start the description with a verb in 3rd person singular, like reports, detects, highlights. +In the first sentence, briefly explain what exactly the inspection helps you detect. +Make sure the sentence is not very long and complicated. +<p> + The first sentence must be in a dedicated paragraph separated from the rest of the text. This will make the + description easier to read. + Make sure the description doesn’t just repeat the inspection title. +</p> +<p> + See https://jetbrains.design/intellij/text/inspections/#descriptions for more information. +</p> +<!-- tooltip end --> +<p>Text after this comment will only be shown in the settings of the inspection.</p> + +<p>To open related settings directly from the description, add a link with `settings://$` optionally followed by `?$` to + pre-select a UI element.</p> +</body> +</html> \ No newline at end of file diff --git a/src/main/resources/inspectionDescriptions/UsePlugSyntax.html b/src/main/resources/inspectionDescriptions/UsePlugSyntax.html new file mode 100644 index 000000000..17e3b1aab --- /dev/null +++ b/src/main/resources/inspectionDescriptions/UsePlugSyntax.html @@ -0,0 +1,29 @@ +<!-- + ~ Copyright 2003-2023 The IdeaVim authors + ~ + ~ Use of this source code is governed by an MIT-style + ~ license that can be found in the LICENSE.txt file or at + ~ https://opensource.org/licenses/MIT. + --> + +<html> +<body> +Write your description here. +Start the description with a verb in 3rd person singular, like reports, detects, highlights. +In the first sentence, briefly explain what exactly the inspection helps you detect. +Make sure the sentence is not very long and complicated. +<p> + The first sentence must be in a dedicated paragraph separated from the rest of the text. This will make the + description easier to read. + Make sure the description doesn’t just repeat the inspection title. +</p> +<p> + See https://jetbrains.design/intellij/text/inspections/#descriptions for more information. +</p> +<!-- tooltip end --> +<p>Text after this comment will only be shown in the settings of the inspection.</p> + +<p>To open related settings directly from the description, add a link with `settings://$` optionally followed by `?$` to + pre-select a UI element.</p> +</body> +</html> \ No newline at end of file diff --git a/src/main/resources/messages/IdeaVimBundle.properties b/src/main/resources/messages/IdeaVimBundle.properties index 69162d5f7..58fb60f11 100644 --- a/src/main/resources/messages/IdeaVimBundle.properties +++ b/src/main/resources/messages/IdeaVimBundle.properties @@ -141,3 +141,5 @@ global.command.not.found.g=Pattern not found: {0} e_interr=Interrupted progress.title.macro.execution=Macro execution stop=Stop +use.plug.inspection.group.display.name=Create property +use.plug.inspection.display.name=Create property2