From 7c945e1502faa4921cc0d251f67843d67728cd82 Mon Sep 17 00:00:00 2001 From: Artur Ayukhanov Date: Sat, 25 Nov 2023 19:44:05 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B7=D0=B0=D0=BF=D1=80=D0=B5=D1=89=D0=B5?= =?UTF-8?q?=D0=BD=D0=BD=D0=BE=D0=B5=20=D1=81=D0=BB=D0=BE=D0=B2=D0=BE=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=BA=D0=B0=D0=B7=D1=8B=D0=B2=D0=B0=D0=B5=D1=82?= =?UTF-8?q?=D1=81=D1=8F=20=D0=B2=20=D1=82=D0=B5=D0=BA=D1=81=D1=82=D0=B5=20?= =?UTF-8?q?=D0=B7=D0=B0=D0=BC=D0=B5=D1=87=D0=B0=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../diagnostics/BadWordsDiagnostic.java | 4 +++- .../BadWordsDiagnostic_en.properties | 2 +- .../BadWordsDiagnostic_ru.properties | 2 +- .../diagnostics/BadWordsDiagnosticTest.java | 20 +++++++++---------- 4 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadWordsDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadWordsDiagnostic.java index cd6390ff6c6..023f2ab3765 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadWordsDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadWordsDiagnostic.java @@ -26,6 +26,7 @@ import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticSeverity; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticTag; import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticType; +import com.github._1c_syntax.bsl.languageserver.utils.Ranges; import com.github._1c_syntax.utils.CaseInsensitivePattern; import java.util.ArrayList; @@ -83,7 +84,8 @@ protected void check() { } var matcher = badWords.matcher(moduleLine); while (matcher.find()) { - diagnosticStorage.addDiagnostic(i, matcher.start(), i, matcher.end()); + diagnosticStorage.addDiagnostic(Ranges.create(i, matcher.start(), i, matcher.end()), + info.getMessage(matcher.group())); } } } diff --git a/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadWordsDiagnostic_en.properties b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadWordsDiagnostic_en.properties index 7fa458c1794..5d24e89b057 100644 --- a/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadWordsDiagnostic_en.properties +++ b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadWordsDiagnostic_en.properties @@ -1,4 +1,4 @@ -diagnosticMessage=Prohibited word found. +diagnosticMessage=Prohibited word found <%s>. diagnosticName=Prohibited words badWords=Regular expression for prohibited words. findInComments=Find in comments diff --git a/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadWordsDiagnostic_ru.properties b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadWordsDiagnostic_ru.properties index a3e64facc06..952f8aa5921 100644 --- a/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadWordsDiagnostic_ru.properties +++ b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadWordsDiagnostic_ru.properties @@ -1,4 +1,4 @@ -diagnosticMessage=В тексте модуля найдено запрещенное слово. +diagnosticMessage=В тексте модуля найдено запрещенное слово <%s>. diagnosticName=Запрещенные слова badWords=Регулярное выражение для слов-исключений. findInComments=Искать в комментариях diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadWordsDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadWordsDiagnosticTest.java index a78083610b8..d68ba5ff425 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadWordsDiagnosticTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/BadWordsDiagnosticTest.java @@ -52,12 +52,12 @@ void testConfigure() { assertThat(diagnostics).hasSize(6); assertThat(diagnostics, true) - .hasRange(0, 42, 47) - .hasRange(0, 48, 54) - .hasRange(4, 4, 9) - .hasRange(6, 24, 29) - .hasRange(6, 34, 39) - .hasRange(8, 4, 10); + .hasMessageOnRange("В тексте модуля найдено запрещенное слово <лотус>.", 0, 42, 0, 47) + .hasMessageOnRange("В тексте модуля найдено запрещенное слово <шмотус>.", 0, 48, 0, 54) + .hasMessageOnRange("В тексте модуля найдено запрещенное слово <Лотус>.", 4, 4, 4, 9) + .hasMessageOnRange("В тексте модуля найдено запрещенное слово <Лотус>.", 6, 24, 6, 29) + .hasMessageOnRange("В тексте модуля найдено запрещенное слово <Лотус>.", 6, 34, 6, 39) + .hasMessageOnRange("В тексте модуля найдено запрещенное слово <Шмотус>.", 8, 4, 8, 10); } @Test @@ -72,9 +72,9 @@ void testFindWithoutComments() { assertThat(diagnostics).hasSize(4); assertThat(diagnostics, true) - .hasRange(4, 4, 9) - .hasRange(6, 24, 29) - .hasRange(6, 34, 39) - .hasRange(8, 4, 10); + .hasMessageOnRange("В тексте модуля найдено запрещенное слово <Лотус>.", 4, 4, 4, 9) + .hasMessageOnRange("В тексте модуля найдено запрещенное слово <Лотус>.", 6, 24, 6, 29) + .hasMessageOnRange("В тексте модуля найдено запрещенное слово <Лотус>.", 6, 34, 6, 39) + .hasMessageOnRange("В тексте модуля найдено запрещенное слово <Шмотус>.", 8, 4, 8, 10); } }