[grazie] add grammar error severity, update icons & colors

GitOrigin-RevId: aa69dfd338e259e48ba0b8a7902c0d8052424f23
This commit is contained in:
Peter Gromov
2022-02-17 09:23:56 +00:00
committed by intellij-monorepo-bot
parent ece9ab8de5
commit 430a02200f
13 changed files with 104 additions and 48 deletions
+2 -2
View File
@@ -62,8 +62,8 @@
<additionalTextAttributes scheme="Default" file="colorSchemes/GrazieDefault.xml"/>
<additionalTextAttributes scheme="Darcula" file="colorSchemes/GrazieDarcula.xml"/>
<severitiesProvider implementation="com.intellij.grazie.ide.inspection.style.StyleProblemSeverities"/>
<trafficLightRendererContributor implementation="com.intellij.grazie.ide.inspection.style.StyleProblemsTrafficLightRendererContributor"/>
<severitiesProvider implementation="com.intellij.grazie.ide.TextProblemSeverities"/>
<trafficLightRendererContributor implementation="com.intellij.grazie.ide.StyleProblemsTrafficLightRendererContributor"/>
</extensions>
<extensions defaultExtensionNs="com.intellij.grazie">
@@ -13,8 +13,8 @@ public final class GrazieIcons {
private static @NotNull Icon load(@NotNull String path, int cacheKey, int flags) {
return IconManager.getInstance().loadRasterizedIcon(path, GrazieIcons.class.getClassLoader(), cacheKey, flags);
}
/** 16x16 */ public static final @NotNull Icon GrammarError = load("icons/grammarError.svg", 1325171794, 0);
/** 16x16 */ public static final @NotNull Icon StyleError = load("icons/styleError.svg", 2060433281, 0);
/** 16x16 */ public static final @NotNull Icon StyleSuggestion = load("icons/styleSuggestion.svg", 2100257017, 0);
/** 16x16 */ public static final @NotNull Icon StyleWarning = load("icons/styleWarning.svg", 139367264, 0);
/** 16x16 */ public static final @NotNull Icon GrammarError = load("icons/grammarError.svg", 1531410605, 2);
/** 16x16 */ public static final @NotNull Icon StyleError = load("icons/styleError.svg", 2060433281, 2);
/** 16x16 */ public static final @NotNull Icon StyleSuggestion = load("icons/styleSuggestion.svg", 2100257017, 2);
/** 16x16 */ public static final @NotNull Icon StyleWarning = load("icons/styleWarning.svg", 139367264, 2);
}
@@ -1,4 +1,4 @@
package com.intellij.grazie.ide.inspection.style
package com.intellij.grazie.ide
import com.intellij.codeInsight.daemon.impl.SeverityRegistrar
import com.intellij.codeInsight.daemon.impl.TrafficLightRenderer
@@ -21,9 +21,9 @@ internal class StyleProblemsTrafficLightRendererContributor: TrafficLightRendere
private class StyleProblemTrafficLightRenderer(project: Project, document: Document): TrafficLightRenderer(project, document) {
override fun getErrorCounts(): IntArray {
val errors = super.getErrorCounts()
val errorIndex = severityRegistrar.findSeverityIndex(StyleProblemSeverities.STYLE_ERROR)
val warningIndex = severityRegistrar.findSeverityIndex(StyleProblemSeverities.STYLE_WARNING)
val suggestionIndex = severityRegistrar.findSeverityIndex(StyleProblemSeverities.STYLE_SUGGESTION)
val errorIndex = severityRegistrar.findSeverityIndex(TextProblemSeverities.STYLE_ERROR)
val warningIndex = severityRegistrar.findSeverityIndex(TextProblemSeverities.STYLE_WARNING)
val suggestionIndex = severityRegistrar.findSeverityIndex(TextProblemSeverities.STYLE_SUGGESTION)
if (errors[warningIndex] != 0) {
errors[warningIndex] += errors[suggestionIndex]
errors[suggestionIndex] = 0
@@ -1,4 +1,4 @@
package com.intellij.grazie.ide.inspection.style
package com.intellij.grazie.ide
import com.intellij.codeInsight.daemon.impl.HighlightInfoType
import com.intellij.codeInsight.daemon.impl.HighlightInfoType.HighlightInfoTypeImpl
@@ -10,16 +10,17 @@ import com.intellij.openapi.editor.colors.TextAttributesKey
import com.intellij.spellchecker.SpellCheckerSeveritiesProvider
import javax.swing.Icon
class StyleProblemSeverities: SeveritiesProvider() {
class TextProblemSeverities: SeveritiesProvider() {
override fun getSeveritiesHighlightInfoTypes(): MutableList<HighlightInfoType> {
return mutableListOf(
StyleHighlightInfoType(STYLE_ERROR, StyleProblemTextAttributes.STYLE_ERROR, GrazieIcons.StyleError),
StyleHighlightInfoType(STYLE_WARNING, StyleProblemTextAttributes.STYLE_WARNING, GrazieIcons.StyleWarning),
StyleHighlightInfoType(STYLE_SUGGESTION, StyleProblemTextAttributes.STYLE_SUGGESTION, GrazieIcons.StyleSuggestion)
TextHighlightInfoType(STYLE_ERROR, STYLE_ERROR_ATTRIBUTES, GrazieIcons.StyleError),
TextHighlightInfoType(STYLE_WARNING, STYLE_WARNING_ATTRIBUTES, GrazieIcons.StyleWarning),
TextHighlightInfoType(STYLE_SUGGESTION, STYLE_SUGGESTION_ATTRIBUTES, GrazieIcons.StyleSuggestion),
TextHighlightInfoType(GRAMMAR_ERROR, GRAMMAR_ERROR_ATTRIBUTES, GrazieIcons.GrammarError)
)
}
private class StyleHighlightInfoType(
private class TextHighlightInfoType(
severity: HighlightSeverity,
attributesKey: TextAttributesKey,
private val icon: Icon
@@ -48,5 +49,27 @@ class StyleProblemSeverities: SeveritiesProvider() {
@JvmField
val STYLE_SUGGESTION = createStyleSeverity("STYLE_SUGGESTION", 3)
@JvmField
val GRAMMAR_ERROR = HighlightSeverity(
"GRAMMAR_ERROR",
SpellCheckerSeveritiesProvider.TYPO.myVal + 1,
GrazieBundle.messagePointer("grammar.error.severity.name"),
GrazieBundle.messagePointer("grammar.error.severity.name.capitalized"),
@Suppress("InvalidBundleOrProperty")
GrazieBundle.messagePointer("grammar.error.severity.count")
)
@JvmField
val STYLE_ERROR_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("GRAZIE_STYLE_ERROR")
@JvmField
val STYLE_WARNING_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("GRAZIE_STYLE_WARNING")
@JvmField
val STYLE_SUGGESTION_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("GRAZIE_STYLE_SUGGESTION")
@JvmField
val GRAMMAR_ERROR_ATTRIBUTES = TextAttributesKey.createTextAttributesKey("GRAZIE_GRAMMAR_ERROR")
}
}
@@ -1,14 +0,0 @@
package com.intellij.grazie.ide.inspection.style
import com.intellij.openapi.editor.colors.TextAttributesKey
object StyleProblemTextAttributes {
@JvmField
val STYLE_ERROR = TextAttributesKey.createTextAttributesKey("GRAZIE_STYLE_ERROR")
@JvmField
val STYLE_WARNING = TextAttributesKey.createTextAttributesKey("GRAZIE_STYLE_WARNING")
@JvmField
val STYLE_SUGGESTION = TextAttributesKey.createTextAttributesKey("GRAZIE_STYLE_SUGGESTION")
}
@@ -2,20 +2,26 @@
<list>
<option name="GRAZIE_STYLE_ERROR">
<value>
<option name="EFFECT_COLOR" value="FF6464" />
<option name="EFFECT_TYPE" value="5" />
<option name="EFFECT_COLOR" value="C75450" />
<option name="EFFECT_TYPE" value="BOLD_DOTTED_LINE" />
</value>
</option>
<option name="GRAZIE_STYLE_WARNING">
<value>
<option name="EFFECT_COLOR" value="8A8A00" />
<option name="EFFECT_TYPE" value="5" />
<option name="EFFECT_COLOR" value="F0A732" />
<option name="EFFECT_TYPE" value="BOLD_DOTTED_LINE" />
</value>
</option>
<option name="GRAZIE_STYLE_SUGGESTION">
<value>
<option name="EFFECT_COLOR" value="589DF6" />
<option name="EFFECT_TYPE" value="5" />
<option name="EFFECT_COLOR" value="3592C4" />
<option name="EFFECT_TYPE" value="BOLD_DOTTED_LINE" />
</value>
</option>
<option name="GRAZIE_GRAMMAR_ERROR">
<value>
<option name="EFFECT_COLOR" value="F0A732" />
<option name="EFFECT_TYPE" value="WAVE" />
</value>
</option>
</list>
@@ -2,20 +2,26 @@
<list>
<option name="GRAZIE_STYLE_ERROR">
<value>
<option name="EFFECT_COLOR" value="FF0000" />
<option name="EFFECT_TYPE" value="5" />
<option name="EFFECT_COLOR" value="DB5860" />
<option name="EFFECT_TYPE" value="BOLD_DOTTED_LINE" />
</value>
</option>
<option name="GRAZIE_STYLE_WARNING">
<value>
<option name="EFFECT_COLOR" value="FFFF00" />
<option name="EFFECT_TYPE" value="5" />
<option name="EFFECT_COLOR" value="EDA200" />
<option name="EFFECT_TYPE" value="BOLD_DOTTED_LINE" />
</value>
</option>
<option name="GRAZIE_STYLE_SUGGESTION">
<value>
<option name="EFFECT_COLOR" value="0000FF" />
<option name="EFFECT_TYPE" value="5" />
<option name="EFFECT_COLOR" value="389FD6" />
<option name="EFFECT_TYPE" value="BOLD_DOTTED_LINE" />
</value>
</option>
<option name="GRAZIE_GRAMMAR_ERROR">
<value>
<option name="EFFECT_COLOR" value="EDA200" />
<option name="EFFECT_TYPE" value="WAVE" />
</value>
</option>
</list>
@@ -1,8 +1,8 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M6.68017 12.0708L13.7512 4.99977L11.8228 3.0713L6.68017 8.21389L4.10887 5.64259L2.1804 7.57107L6.68017 12.0708Z" fill="#DB5860"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M2.70711 15.0142L2 14.3071L4.70711 11.6L5.41421 12.3071L2.70711 15.0142Z" fill="#DB5860"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M4 12.3071L4.70711 11.6L7.41421 14.3071L6.70711 15.0142L4 12.3071Z" fill="#DB5860"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M6.70711 15.0142L6 14.3071L8.70711 11.6L9.41421 12.3071L6.70711 15.0142Z" fill="#DB5860"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M8 12.3071L8.70711 11.6L11.4142 14.3071L10.7071 15.0142L8 12.3071Z" fill="#DB5860"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M10.7071 15.0142L10 14.3071L12.7071 11.6L13.4142 12.3071L10.7071 15.0142Z" fill="#DB5860"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M6.68017 12.0708L13.7512 4.99977L11.8228 3.0713L6.68017 8.21389L4.10887 5.64259L2.1804 7.57107L6.68017 12.0708Z" fill="#59A869"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M2.70711 15.0142L2 14.3071L4.70711 11.6L5.41421 12.3071L2.70711 15.0142Z" fill="#DB5860"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M4 12.3071L4.70711 11.6L7.41421 14.3071L6.70711 15.0142L4 12.3071Z" fill="#DB5860"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M6.70711 15.0142L6 14.3071L8.70711 11.6L9.41421 12.3071L6.70711 15.0142Z" fill="#DB5860"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M8 12.3071L8.70711 11.6L11.4142 14.3071L10.7071 15.0142L8 12.3071Z" fill="#DB5860"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M10.7071 15.0142L10 14.3071L12.7071 11.6L13.4142 12.3071L10.7071 15.0142Z" fill="#DB5860"/>
</svg>

Before

Width:  |  Height:  |  Size: 983 B

After

Width:  |  Height:  |  Size: 971 B

@@ -0,0 +1,8 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M6.68017 12.0708L13.7512 4.99977L11.8228 3.0713L6.68017 8.21389L4.10887 5.64259L2.1804 7.57107L6.68017 12.0708Z" fill="#499C54"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M2.70711 15.0142L2 14.3071L4.70711 11.6L5.41421 12.3071L2.70711 15.0142Z" fill="#C75450"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M4 12.3071L4.70711 11.6L7.41421 14.3071L6.70711 15.0142L4 12.3071Z" fill="#C75450"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M6.70711 15.0142L6 14.3071L8.70711 11.6L9.41421 12.3071L6.70711 15.0142Z" fill="#C75450"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M8 12.3071L8.70711 11.6L11.4142 14.3071L10.7071 15.0142L8 12.3071Z" fill="#C75450"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M10.7071 15.0142L10 14.3071L12.7071 11.6L13.4142 12.3071L10.7071 15.0142Z" fill="#C75450"/>
</svg>

After

Width:  |  Height:  |  Size: 971 B

@@ -0,0 +1,8 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M9.75736 3.41427C10.5384 2.63325 11.8047 2.63327 12.5858 3.4143V3.4143C13.3668 4.19537 13.3668 5.46172 12.5857 6.24276L8.50878 10.3195L5.68035 7.4911L9.75736 3.41427Z" fill="#C75450"/>
<path d="M5 8.00003L8 11L5 11V8.00003Z" fill="#C75450"/>
<circle cx="3" cy="14" r="1" fill="#C75450"/>
<circle cx="6" cy="14" r="1" fill="#C75450"/>
<circle cx="9" cy="14" r="1" fill="#C75450"/>
<circle cx="12" cy="14" r="1" fill="#C75450"/>
</svg>

After

Width:  |  Height:  |  Size: 539 B

@@ -0,0 +1,8 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M9.75736 3.41427C10.5384 2.63325 11.8047 2.63327 12.5858 3.4143V3.4143C13.3668 4.19537 13.3668 5.46172 12.5857 6.24276L8.50878 10.3195L5.68035 7.4911L9.75736 3.41427Z" fill="#3592C4"/>
<path d="M5 8.00003L8 11L5 11V8.00003Z" fill="#3592C4"/>
<circle cx="3" cy="14" r="1" fill="#3592C4"/>
<circle cx="6" cy="14" r="1" fill="#3592C4"/>
<circle cx="9" cy="14" r="1" fill="#3592C4"/>
<circle cx="12" cy="14" r="1" fill="#3592C4"/>
</svg>

After

Width:  |  Height:  |  Size: 539 B

@@ -0,0 +1,8 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M9.75736 3.41427C10.5384 2.63325 11.8047 2.63327 12.5858 3.4143V3.4143C13.3668 4.19537 13.3668 5.46172 12.5857 6.24276L8.50878 10.3195L5.68035 7.4911L9.75736 3.41427Z" fill="#F0A732"/>
<path d="M5 8.00003L8 11L5 11V8.00003Z" fill="#F0A732"/>
<circle cx="3" cy="14" r="1" fill="#F0A732"/>
<circle cx="6" cy="14" r="1" fill="#F0A732"/>
<circle cx="9" cy="14" r="1" fill="#F0A732"/>
<circle cx="12" cy="14" r="1" fill="#F0A732"/>
</svg>

After

Width:  |  Height:  |  Size: 539 B

@@ -92,3 +92,6 @@ grazie.spellcheck.dictionary.name=Extended Dictionary
style.problem.severity.name=style issue
style.problem.severity.name.capitalized=Style issue
style.problem.severity.count={0} {0, choice, 0#style issues|1#style issue|2#style issues}
grammar.error.severity.name=grammar error
grammar.error.severity.name.capitalized=Grammar error
grammar.error.severity.count={0} {0, choice, 0#grammar errors|1#grammar error|2#grammar errors}