mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[grazie] Print global rule id in tests
Merge-request: IJ-MR-176781 Merged-by: Ilia Permiashkin <ilia.permiashkin@jetbrains.com> GitOrigin-RevId: d403c6e47bd5acefe1bbbf94c85add7792c1bbe2
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ad535dd829
commit
0fa80a1ff0
@@ -19,6 +19,7 @@ import ai.grazie.rules.tree.Parameter;
|
||||
import ai.grazie.rules.tree.Tree;
|
||||
import ai.grazie.rules.tree.Tree.ParameterValues;
|
||||
import com.intellij.codeInspection.LocalQuickFix;
|
||||
import com.intellij.codeInspection.util.InspectionMessage;
|
||||
import com.intellij.grazie.GrazieBundle;
|
||||
import com.intellij.grazie.GrazieConfig;
|
||||
import com.intellij.grazie.ide.inspection.auto.AutoFix;
|
||||
@@ -34,6 +35,8 @@ import com.intellij.grazie.text.TextContent.TextDomain;
|
||||
import com.intellij.grazie.utils.HighlightingUtil;
|
||||
import com.intellij.grazie.utils.Text;
|
||||
import com.intellij.grazie.utils.TextStyleDomain;
|
||||
import com.intellij.grazie.utils.TextUtilsKt;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Attachment;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
@@ -511,16 +514,9 @@ public final class TreeRuleChecker {
|
||||
}
|
||||
|
||||
private static boolean shouldSuppressByPlace(ai.grazie.rules.Rule rule, TextContent text) {
|
||||
TextDomain domain = text.getDomain();
|
||||
PsiFile file = text.getContainingFile();
|
||||
TextStyle placeStyle =
|
||||
CommitMessage.isCommitMessage(file) ? TextStyle.Commit :
|
||||
domain == TextDomain.DOCUMENTATION ? TextStyle.CodeDocumentation :
|
||||
domain == TextDomain.COMMENTS ? TextStyle.CodeComment :
|
||||
"ChatInput".equals(file.getLanguage().getID()) ? TextStyle.AIPrompt :
|
||||
null;
|
||||
|
||||
return placeStyle != null && placeStyle.disabledRules().contains(rule.globalId());
|
||||
TextStyleDomain domain = getTextDomain(text);
|
||||
if (domain == TextStyleDomain.Other) return false;
|
||||
return domain.getTextStyle().disabledRules().contains(rule.globalId());
|
||||
}
|
||||
|
||||
private static boolean touchesUnknownFragments(TextContent text, ai.grazie.rules.tree.TextRange range, ai.grazie.rules.Rule rule) {
|
||||
@@ -557,6 +553,13 @@ public final class TreeRuleChecker {
|
||||
this.customFixes = customFixes;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("HardCodedStringLiteral")
|
||||
public @InspectionMessage @NotNull String getDescriptionTemplate(boolean isOnTheFly) {
|
||||
if (ApplicationManager.getApplication().isUnitTestMode()) return match.rule().globalId();
|
||||
return super.getDescriptionTemplate(isOnTheFly);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<LocalQuickFix> getCustomFixes() {
|
||||
return ContainerUtil.concat(customFixes, ContainerUtil.mapNotNull(match.actions(), sug -> {
|
||||
|
||||
@@ -165,9 +165,6 @@ class JavaSupportTest : GrazieTestBase() {
|
||||
}
|
||||
|
||||
fun `test no highlighting after fixing an error within the same range`() {
|
||||
GrazieConfig.update {
|
||||
it.withDomainEnabledRules(TextStyleDomain.CodeDocumentation, setOf("LanguageTool.EN.FILE_EXTENSIONS_CASE"))
|
||||
}
|
||||
runHighlightTestForFile("ide/language/java/PDF.java")
|
||||
myFixture.launchAction(myFixture.findSingleIntention("PDF"))
|
||||
myFixture.checkHighlighting()
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ class PropertiesSupportTest : GrazieTestBase() {
|
||||
ru.text.err2=А <GRAMMAR_ERROR descr="grammar_vse_li_noun">все ли ошибка</GRAMMAR_ERROR> найдены?
|
||||
ru.text.err3=Это случилось <GRAMMAR_ERROR descr="INVALID_DATE">31 ноября</GRAMMAR_ERROR> 2014 г.
|
||||
ru.text.err4=За весь вечер она <GRAMMAR_ERROR descr="ne_proronila_ni">не проронила и слово</GRAMMAR_ERROR>.
|
||||
ru.text.err5=Собрание состоится в <GRAMMAR_ERROR descr="Стандартное написание – «конференц-зале»">конференц зале</GRAMMAR_ERROR>.
|
||||
ru.text.err5=Собрание состоится в <GRAMMAR_ERROR descr="Grazie.RuleEngine.Ru.Spelling.MULTI_WORD">конференц зале</GRAMMAR_ERROR>.
|
||||
ru.text.err6=<GRAMMAR_ERROR descr="WORD_REPEAT_RULE">Он он</GRAMMAR_ERROR> здесь ошибка в тексте.
|
||||
ru.with.newline=Не удалось авторизоваться.\nПопробуйте ещё раз.
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ class SuppressionTests: GrazieTestBase() {
|
||||
fun `test suppressing grammar inspection doesn't affect style issues`() {
|
||||
myFixture.configureByText("A.java", """
|
||||
class A {
|
||||
// Show is <STYLE_SUGGESTION descr="American English does not double '-l-' in suffixes">can<caret>celled</STYLE_SUGGESTION> because of an cat
|
||||
// Show is <STYLE_SUGGESTION descr="Grazie.RuleEngine.En.Style.VARIANT_LEXICAL_DIFFERENCES">can<caret>celled</STYLE_SUGGESTION> because of an cat
|
||||
@SuppressWarnings("GrazieInspection")
|
||||
public static void main() {}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ class SuppressionTests: GrazieTestBase() {
|
||||
fun `test suppress style action generates necessary inspection id`() {
|
||||
myFixture.configureByText("Class.java", """
|
||||
public class Class {
|
||||
// Show is <STYLE_SUGGESTION descr="American English does not double '-l-' in suffixes">can<caret>celled</STYLE_SUGGESTION>
|
||||
// Show is <STYLE_SUGGESTION descr="Grazie.RuleEngine.En.Style.VARIANT_LEXICAL_DIFFERENCES">can<caret>celled</STYLE_SUGGESTION>
|
||||
public static void main() {}
|
||||
}
|
||||
""".trimIndent())
|
||||
@@ -75,7 +75,7 @@ class SuppressionTests: GrazieTestBase() {
|
||||
myFixture.disableInspections(GrazieInspection.Grammar())
|
||||
myFixture.configureByText("Class.java", """
|
||||
public class Class {
|
||||
// Show is <STYLE_SUGGESTION descr="American English does not double '-l-' in suffixes">can<caret>celled</STYLE_SUGGESTION> because of an cat
|
||||
// Show is <STYLE_SUGGESTION descr="Grazie.RuleEngine.En.Style.VARIANT_LEXICAL_DIFFERENCES">can<caret>celled</STYLE_SUGGESTION> because of an cat
|
||||
public static void main() {}
|
||||
}
|
||||
""".trimIndent())
|
||||
|
||||
@@ -45,7 +45,7 @@ class ForMultiLanguageSupport {
|
||||
|
||||
// We don't use the PHP php_strip_whitespace() function
|
||||
|
||||
// If Content-Type is set to text/html, or is unset -> <GRAMMAR_ERROR descr="File types are usually capitalized">html</GRAMMAR_ERROR>
|
||||
// If Content-Type is set to text/html, or is unset -> <GRAMMAR_ERROR descr="Grazie.RuleEngine.En.Spelling.PROPER_NAMES">html</GRAMMAR_ERROR>
|
||||
|
||||
/*
|
||||
for(;;)
|
||||
|
||||
@@ -28,7 +28,7 @@ class ExampleClassWithNoTypos<T> {
|
||||
/**
|
||||
* Adds a [member] to this group.
|
||||
*
|
||||
* @param cancellable Whether the progress can be <STYLE_SUGGESTION descr="American English does not double '-l-' in suffixes">cancelled</STYLE_SUGGESTION>.
|
||||
* @param cancellable Whether the progress can be <STYLE_SUGGESTION descr="Grazie.RuleEngine.En.Style.VARIANT_LEXICAL_DIFFERENCES">cancelled</STYLE_SUGGESTION>.
|
||||
* @param member member to add
|
||||
* @return the new size of the group. And another sentence.
|
||||
*/
|
||||
@@ -93,7 +93,7 @@ class ExampleClassWithTypos<T> {
|
||||
* А <GRAMMAR_ERROR descr="grammar_vse_li_noun">все ли ошибка</GRAMMAR_ERROR> найдены?
|
||||
* Это случилось <GRAMMAR_ERROR descr="INVALID_DATE">31 ноября</GRAMMAR_ERROR> 2014 г.
|
||||
* За весь вечер она <GRAMMAR_ERROR descr="ne_proronila_ni">не проронила и слово</GRAMMAR_ERROR>.
|
||||
* Собрание состоится в <GRAMMAR_ERROR descr="Стандартное написание – «конференц-зале»">конференц зале</GRAMMAR_ERROR>.
|
||||
* Собрание состоится в <GRAMMAR_ERROR descr="Grazie.RuleEngine.Ru.Spelling.MULTI_WORD">конференц зале</GRAMMAR_ERROR>.
|
||||
* <GRAMMAR_ERROR descr="WORD_REPEAT_RULE">Он он</GRAMMAR_ERROR> ошибка.
|
||||
*/
|
||||
// noinspection SqlDialectInspection das daert geschätzt fünf Mannstunden! А еще в коробке лежало пять карандаша
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/// Some <GRAMMAR_ERROR descr="The standard spelling is 'Javadoc'">javadoc</GRAMMAR_ERROR>. Maybe with some <TYPO descr="Typo: In word 'grammr'">grammr</TYPO> and, punctuation, <TYPO descr="Typo: In word 'mistaks'">mistaks</TYPO>.
|
||||
/// Some <GRAMMAR_ERROR descr="Grazie.RuleEngine.En.Spelling.MULTI_WORD">javadoc</GRAMMAR_ERROR>. Maybe with some <TYPO descr="Typo: In word 'grammr'">grammr</TYPO> and, punctuation, <TYPO descr="Typo: In word 'mistaks'">mistaks</TYPO>.
|
||||
///
|
||||
/// ```
|
||||
/// void main(String[] args){
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* In library <GRAMMAR_ERROR descr="File types are usually capitalized"><caret>pdf</GRAMMAR_ERROR> did not fix the problem I faced
|
||||
* In library <GRAMMAR_ERROR descr="Grazie.RuleEngine.En.Spelling.PROPER_NAMES"><caret>pdf</GRAMMAR_ERROR> did not fix the problem I faced
|
||||
*/
|
||||
public class PDF {
|
||||
}
|
||||
@@ -56,7 +56,7 @@ class ExampleClassWithTypos {
|
||||
* А <GRAMMAR_ERROR descr="grammar_vse_li_noun">все ли ошибка</GRAMMAR_ERROR> найдены?
|
||||
* Это случилось <GRAMMAR_ERROR descr="INVALID_DATE">31 ноября</GRAMMAR_ERROR> 2014 г.
|
||||
* За весь вечер она <GRAMMAR_ERROR descr="ne_proronila_ni">не проронила и слово</GRAMMAR_ERROR>.
|
||||
* Собрание состоится в <GRAMMAR_ERROR descr="Стандартное написание – «конференц-зале»">конференц зале</GRAMMAR_ERROR>.
|
||||
* Собрание состоится в <GRAMMAR_ERROR descr="Grazie.RuleEngine.Ru.Spelling.MULTI_WORD">конференц зале</GRAMMAR_ERROR>.
|
||||
* <GRAMMAR_ERROR descr="WORD_REPEAT_RULE">Он он</GRAMMAR_ERROR> ошибка.
|
||||
*/
|
||||
class ForMultiLanguageSupport {
|
||||
|
||||
@@ -50,7 +50,7 @@ foo(<GRAMMAR_ERROR descr="THE_PUNCT">a,</GRAMMAR_ERROR> <GRAMMAR_ERROR descr="TH
|
||||
А <GRAMMAR_ERROR descr="grammar_vse_li_noun">все ли ошибка</GRAMMAR_ERROR> найдены?
|
||||
Это случилось <GRAMMAR_ERROR descr="INVALID_DATE">31 ноября</GRAMMAR_ERROR> 2014 г.
|
||||
За весь вечер она <GRAMMAR_ERROR descr="ne_proronila_ni">не проронила и слово</GRAMMAR_ERROR>.
|
||||
Собрание состоится в <GRAMMAR_ERROR descr="Стандартное написание – «конференц-зале»">конференц зале</GRAMMAR_ERROR>.
|
||||
Собрание состоится в <GRAMMAR_ERROR descr="Grazie.RuleEngine.Ru.Spelling.MULTI_WORD">конференц зале</GRAMMAR_ERROR>.
|
||||
<GRAMMAR_ERROR descr="WORD_REPEAT_RULE">Он он</GRAMMAR_ERROR> ошибка.
|
||||
|
||||
Я предлагаю в своём приложении создавать что-нибудь.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
А <GRAMMAR_ERROR descr="grammar_vse_li_noun">все ли ошибка</GRAMMAR_ERROR> найдены?
|
||||
Это случилось <GRAMMAR_ERROR descr="INVALID_DATE">31 ноября</GRAMMAR_ERROR> 2014 г.
|
||||
За весь вечер она <GRAMMAR_ERROR descr="ne_proronila_ni">не проронила и слово</GRAMMAR_ERROR>.
|
||||
Собрание состоится в <GRAMMAR_ERROR descr="Стандартное написание – «конференц-зале»">конференц зале</GRAMMAR_ERROR>.
|
||||
Собрание состоится в <GRAMMAR_ERROR descr="Grazie.RuleEngine.Ru.Spelling.MULTI_WORD">конференц зале</GRAMMAR_ERROR>.
|
||||
<GRAMMAR_ERROR descr="WORD_REPEAT_RULE">Он он</GRAMMAR_ERROR> ошибка.
|
||||
|
||||
Ignoring code-like constructs:
|
||||
|
||||
@@ -31,7 +31,7 @@ actually return values.
|
||||
А <GRAMMAR_ERROR descr="grammar_vse_li_noun">все ли ошибка</GRAMMAR_ERROR> найдены?
|
||||
Это случилось <GRAMMAR_ERROR descr="INVALID_DATE">31 ноября</GRAMMAR_ERROR> 2014 г.
|
||||
За весь вечер она <GRAMMAR_ERROR descr="ne_proronila_ni">не проронила и слово</GRAMMAR_ERROR>.
|
||||
Собрание состоится в <GRAMMAR_ERROR descr="Стандартное написание – «конференц-зале»">конференц зале</GRAMMAR_ERROR>.
|
||||
Собрание состоится в <GRAMMAR_ERROR descr="Grazie.RuleEngine.Ru.Spelling.MULTI_WORD">конференц зале</GRAMMAR_ERROR>.
|
||||
<GRAMMAR_ERROR descr="WORD_REPEAT_RULE">Он он</GRAMMAR_ERROR> ошибка.
|
||||
|
||||
Я предлагаю в своём приложении создавать что-нибудь.
|
||||
|
||||
@@ -32,7 +32,7 @@ bill-to: &id001
|
||||
А <GRAMMAR_ERROR descr="grammar_vse_li_noun">все ли ошибка</GRAMMAR_ERROR> найдены?
|
||||
Это случилось <GRAMMAR_ERROR descr="INVALID_DATE">31 ноября</GRAMMAR_ERROR> 2014 г.
|
||||
За весь вечер она <GRAMMAR_ERROR descr="ne_proronila_ni">не проронила и слово</GRAMMAR_ERROR>.
|
||||
Собрание состоится в <GRAMMAR_ERROR descr="Стандартное написание – «конференц-зале»">конференц зале</GRAMMAR_ERROR>.
|
||||
Собрание состоится в <GRAMMAR_ERROR descr="Grazie.RuleEngine.Ru.Spelling.MULTI_WORD">конференц зале</GRAMMAR_ERROR>.
|
||||
БОЛЬШИЕ БУКВЫ.
|
||||
Актуальный плагин.
|
||||
На конференции работали советы по секциям: химия, история.
|
||||
|
||||
@@ -56,7 +56,7 @@ class ExampleClassWithTypos<T>(val name: String) {
|
||||
* А <GRAMMAR_ERROR descr="grammar_vse_li_noun">все ли ошибка</GRAMMAR_ERROR> найдены?
|
||||
* Это случилось <GRAMMAR_ERROR descr="INVALID_DATE">31 ноября</GRAMMAR_ERROR> 2014 г.
|
||||
* За весь вечер она <GRAMMAR_ERROR descr="ne_proronila_ni">не проронила и слово</GRAMMAR_ERROR>.
|
||||
* Собрание состоится в <GRAMMAR_ERROR descr="Стандартное написание – «конференц-зале»">конференц зале</GRAMMAR_ERROR>.
|
||||
* Собрание состоится в <GRAMMAR_ERROR descr="Grazie.RuleEngine.Ru.Spelling.MULTI_WORD">конференц зале</GRAMMAR_ERROR>.
|
||||
* <GRAMMAR_ERROR descr="WORD_REPEAT_RULE">Он он</GRAMMAR_ERROR> ошибка.
|
||||
*/
|
||||
class ForMultiLanguageSupport {
|
||||
|
||||
@@ -67,7 +67,7 @@ class ForMultiLanguageSupport:
|
||||
А <GRAMMAR_ERROR descr="grammar_vse_li_noun">все ли ошибка</GRAMMAR_ERROR> найдены?
|
||||
Это случилось <GRAMMAR_ERROR descr="INVALID_DATE">31 ноября</GRAMMAR_ERROR> 2014 г.
|
||||
За весь вечер она <GRAMMAR_ERROR descr="ne_proronila_ni">не проронила и слово</GRAMMAR_ERROR>.
|
||||
Собрание состоится в <GRAMMAR_ERROR descr="Стандартное написание – «конференц-зале»">конференц зале</GRAMMAR_ERROR>.
|
||||
Собрание состоится в <GRAMMAR_ERROR descr="Grazie.RuleEngine.Ru.Spelling.MULTI_WORD">конференц зале</GRAMMAR_ERROR>.
|
||||
<GRAMMAR_ERROR descr="WORD_REPEAT_RULE">Он он</GRAMMAR_ERROR> ошибка.
|
||||
"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user