diff --git a/docs/diagnostics/CanonicalSpellingKeywordsInQuery.md b/docs/diagnostics/CanonicalSpellingKeywordsInQuery.md new file mode 100644 index 00000000000..2a9f023af00 --- /dev/null +++ b/docs/diagnostics/CanonicalSpellingKeywordsInQuery.md @@ -0,0 +1,126 @@ +# Проверка канонического написания ключевых слов в запросе (CanonicalSpellingKeywordsInQuery) + +| Тип | Поддерживаются
языки | Важность | Включена
по умолчанию | Время на
исправление (мин) | Теги | +|:-------------:|:-----------------------------:|:----------------:|:------------------------------:|:-----------------------------------:|:----------:| +| `Дефект кода` | `BSL` | `Информационный` | `Да` | `1` | `standard` | + + +## Описание диагностики + +В запросах ключевые слова пишутся канонически - заглавными буквами. + +### Ключевые слова + +| RU | EN | +|-------------------|-------------------| +|NULL |NULL | +|--- |OF | +|ПО |ON | +|АВТОНОМЕРЗАПИСИ |RECORDAUTONUMBER | +|АВТОУПОРЯДОЧИВАНИЕ |AUTOORDER | +|БУЛЕВО |BOOLEAN | +|В |IN | +|ВНЕШНЕЕ |OUTER | +|ВНУТРЕННЕЕ |INNER | +|ВОЗР |ASC | +|ВСЕ |ALL | +|ВЫБОР |CASE | +|ВЫБРАТЬ |SELECT | +|ВЫРАЗИТЬ |CAST | +|ГДЕ |WHERE | +|ГОД |YEAR | +|ГРУППИРУЮЩИМ |GROUPING | +|ДАТА |DATE | +|ДАТАВРЕМЯ |DATETIME | +|ДЕКАДА |TENDAYS | +|ДЕНЬ |DAY | +|ДЕНЬГОДА |DAYOFYEAR | +|ДЕНЬНЕДЕЛИ |WEEKDAY | +|ДЛЯ |EN | +|ДОБАВИТЬКДАТЕ |DATEADD | +|ЕСТЬ |IS | +|ЕСТЬNULL |ISNULL | +|ЗНАЧЕНИЕ |VALUE | +|И |AND | +|ИЕРАРХИИ |HIERARCHY | +|ИЕРАРХИЯ |HIERARCHY | +|ИЗ |FROM | +|ИЗМЕНЕНИЯ |UPDATE | +|ИЛИ |OR | +|ИМЕЮЩИЕ |HAVING | +|ИНАЧЕ |ELSE | +|ИНДЕКСИРОВАТЬ |INDEX | +|ИТОГИ |TOTALS | +|Истина |TRUE | +|КАК |AS | +|КВАРТАЛ |QUARTER | +|КОГДА |WHEN | +|КОЛИЧЕСТВО |COUNT | +|КОНЕЦ |END | +|КОНЕЦПЕРИОДА |ENDOFPERIOD | +|ЛЕВОЕ |LEFT | +|Ложь |FALSE | +|МАКСИМУМ |MAX | +|МЕЖДУ |BETWEEN | +|МЕСЯЦ |MONTH | +|МИНИМУМ |MIN | +|МИНУТА |MINUTE | +|НАБОРАМ |SETS | +|НАЧАЛОПЕРИОДА |BEGINOFPERIOD | +|НЕ |NOT | +|НЕДЕЛЯ |WEEK | +|НЕОПРЕДЕЛЕНО |UNDEFINED | +|ОБЩИЕ |OVERALL | +|ОБЪЕДИНИТЬ |UNION | +|ПЕРВЫЕ |TOP | +|ПЕРИОДАМИ |PERIODS | +|ПОДОБНО |LIKE | +|ПОДСТРОКА |SUBSTRING | +|ПОЛНОЕ |FULL | +|ПОЛУГОДИЕ |HALFYEAR | +|ПОМЕСТИТЬ |INTO | +|ПРАВОЕ |RIGHT | +|ПРЕДСТАВЛЕНИЕ |PRESENTATION | +|ПРЕДСТАВЛЕНИЕССЫЛКИ|REFPRESENTATION | +|ПУСТАЯТАБЛИЦА |EMPTYTABLE | +|РАЗЛИЧНЫЕ |DISTINCT | +|РАЗНОСТЬДАТ |DATEDIFF | +|РАЗРЕШЕННЫЕ |ALLOWED | +|СГРУППИРОВАНОПО |GROUPEDBY | +|СГРУППИРОВАТЬ |GROUP | +|СЕКУНДА |SECOND | +|СОЕДИНЕНИЕ |JOIN | +|СПЕЦСИМВОЛ |ESCAPE | +|СРЕДНЕЕ |AVG | +|ССЫЛКА |REFS | +|СТРОКА |STRING | +|СУММА |SUM | +|ТИП |TYPE | +|ТИПЗНАЧЕНИЯ |VALUETYPE | +|ТОГДА |THEN | +|ТОЛЬКО |ONLY | +|УБЫВ |DESC | +|УНИЧТОЖИТЬ |DROP | +|УПОРЯДОЧИТЬ |ORDER | +|ЧАС |HOUR | +|ЧИСЛО |NUMBER | + +## Источники + +* Источник: [Стандарт: Оформление текстов запросов](https://its.1c.ru/db/v8std#content:437:hdoc) + +## Сниппеты + + +### Экранирование кода + +```bsl +// BSLLS:CanonicalSpellingKeywordsInQuery-off +// BSLLS:CanonicalSpellingKeywordsInQuery-on +``` + +### Параметр конфигурационного файла + +```json +"CanonicalSpellingKeywordsInQuery": false +``` diff --git a/docs/diagnostics/CodeOutOfRegion.md b/docs/diagnostics/CodeOutOfRegion.md index fe7c60e9fcd..3fffb40093c 100644 --- a/docs/diagnostics/CodeOutOfRegion.md +++ b/docs/diagnostics/CodeOutOfRegion.md @@ -38,7 +38,7 @@ #КонецОбласти ``` -Таблица соответствия английских имён (полный список в [исходном коде](https://github.com/1c-syntax/bsl-language-server/blob/develop/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Keywords.java#L255)): +Таблица соответствия английских имён (полный список в [исходном коде](https://github.com/1c-syntax/bsl-language-server/blob/develop/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/BSLKeywords.java#L255)): | русск. | англ. | | ------------- | ------------- | | ПрограммныйИнтерфейс | Public | diff --git a/docs/diagnostics/index.md b/docs/diagnostics/index.md index 29e1606340c..7420b191685 100644 --- a/docs/diagnostics/index.md +++ b/docs/diagnostics/index.md @@ -1,4 +1,4 @@ -# Диагностики +# Диагностики Используются для проверки кода на соответствие стандартам кодирования и для поиска возможных ошибок. @@ -24,6 +24,7 @@ [BeginTransactionBeforeTryCatch](BeginTransactionBeforeTryCatch.md) | Нарушение правил работы с транзакциями для метода 'НачатьТранзакцию' | Да | Важный | Ошибка | `standard` [CachedPublic](CachedPublic.md) | Кеширование программного интерфейса | Да | Важный | Дефект кода | `standard`
`design` [CanonicalSpellingKeywords](CanonicalSpellingKeywords.md) | Каноническое написание ключевых слов | Да | Информационный | Дефект кода | `standard` + [CanonicalSpellingKeywordsInQuery](CanonicalSpellingKeywordsInQuery.md) | Проверка канонического написания ключевых слов в запросе | Да | Информационный | Дефект кода | `standard` [CodeAfterAsyncCall](CodeAfterAsyncCall.md) | После вызова асинхронного метода есть строки кода | Нет | Важный | Дефект кода | `suspicious` [CodeBlockBeforeSub](CodeBlockBeforeSub.md) | Определения методов должны размещаться перед операторами тела модуля | Да | Блокирующий | Ошибка | `error` [CodeOutOfRegion](CodeOutOfRegion.md) | Код расположен вне области | Да | Информационный | Дефект кода | `standard` diff --git a/docs/en/diagnostics/CanonicalSpellingKeywords.md b/docs/en/diagnostics/CanonicalSpellingKeywords.md index 30b0d7c0b14..470cfe62774 100644 --- a/docs/en/diagnostics/CanonicalSpellingKeywords.md +++ b/docs/en/diagnostics/CanonicalSpellingKeywords.md @@ -48,7 +48,7 @@ A built-in language constructs, keywords must be written canonically. | Функция | Function | | Экспорт | Export | -### Preprocessor instrutions +### Preprocessor instructions | RU | EN | | ---------------------------------- | ------------------------------ | diff --git a/docs/en/diagnostics/CanonicalSpellingKeywordsInQuery.md b/docs/en/diagnostics/CanonicalSpellingKeywordsInQuery.md new file mode 100644 index 00000000000..cd4898d88a9 --- /dev/null +++ b/docs/en/diagnostics/CanonicalSpellingKeywordsInQuery.md @@ -0,0 +1,125 @@ +# Checking the canonical spelling of keywords in a query (CanonicalSpellingKeywordsInQuery) + +| Type | Scope | Severity | Activated
by default | Minutes
to fix | Tags | +|:------------:|:-----:|:--------:|:-----------------------------:|:-----------------------:|:----------:| +| `Code smell` | `BSL` | `Info` | `Yes` | `1` | `standard` | + + +## Description + +### Keywords + +| RU | EN | +|-------------------|-------------------| +|NULL |NULL | +|--- |OF | +|ПО |ON | +|АВТОНОМЕРЗАПИСИ |RECORDAUTONUMBER | +|АВТОУПОРЯДОЧИВАНИЕ |AUTOORDER | +|БУЛЕВО |BOOLEAN | +|В |IN | +|ВНЕШНЕЕ |OUTER | +|ВНУТРЕННЕЕ |INNER | +|ВОЗР |ASC | +|ВСЕ |ALL | +|ВЫБОР |CASE | +|ВЫБРАТЬ |SELECT | +|ВЫРАЗИТЬ |CAST | +|ГДЕ |WHERE | +|ГОД |YEAR | +|ГРУППИРУЮЩИМ |GROUPING | +|ДАТА |DATE | +|ДАТАВРЕМЯ |DATETIME | +|ДЕКАДА |TENDAYS | +|ДЕНЬ |DAY | +|ДЕНЬГОДА |DAYOFYEAR | +|ДЕНЬНЕДЕЛИ |WEEKDAY | +|ДЛЯ |EN | +|ДОБАВИТЬКДАТЕ |DATEADD | +|ЕСТЬ |IS | +|ЕСТЬNULL |ISNULL | +|ЗНАЧЕНИЕ |VALUE | +|И |AND | +|ИЕРАРХИИ |HIERARCHY | +|ИЕРАРХИЯ |HIERARCHY | +|ИЗ |FROM | +|ИЗМЕНЕНИЯ |UPDATE | +|ИЛИ |OR | +|ИМЕЮЩИЕ |HAVING | +|ИНАЧЕ |ELSE | +|ИНДЕКСИРОВАТЬ |INDEX | +|ИТОГИ |TOTALS | +|Истина |TRUE | +|КАК |AS | +|КВАРТАЛ |QUARTER | +|КОГДА |WHEN | +|КОЛИЧЕСТВО |COUNT | +|КОНЕЦ |END | +|КОНЕЦПЕРИОДА |ENDOFPERIOD | +|ЛЕВОЕ |LEFT | +|Ложь |FALSE | +|МАКСИМУМ |MAX | +|МЕЖДУ |BETWEEN | +|МЕСЯЦ |MONTH | +|МИНИМУМ |MIN | +|МИНУТА |MINUTE | +|НАБОРАМ |SETS | +|НАЧАЛОПЕРИОДА |BEGINOFPERIOD | +|НЕ |NOT | +|НЕДЕЛЯ |WEEK | +|НЕОПРЕДЕЛЕНО |UNDEFINED | +|ОБЩИЕ |OVERALL | +|ОБЪЕДИНИТЬ |UNION | +|ПЕРВЫЕ |TOP | +|ПЕРИОДАМИ |PERIODS | +|ПОДОБНО |LIKE | +|ПОДСТРОКА |SUBSTRING | +|ПОЛНОЕ |FULL | +|ПОЛУГОДИЕ |HALFYEAR | +|ПОМЕСТИТЬ |INTO | +|ПРАВОЕ |RIGHT | +|ПРЕДСТАВЛЕНИЕ |PRESENTATION | +|ПРЕДСТАВЛЕНИЕССЫЛКИ|REFPRESENTATION | +|ПУСТАЯТАБЛИЦА |EMPTYTABLE | +|РАЗЛИЧНЫЕ |DISTINCT | +|РАЗНОСТЬДАТ |DATEDIFF | +|РАЗРЕШЕННЫЕ |ALLOWED | +|СГРУППИРОВАНОПО |GROUPEDBY | +|СГРУППИРОВАТЬ |GROUP | +|СЕКУНДА |SECOND | +|СОЕДИНЕНИЕ |JOIN | +|СПЕЦСИМВОЛ |ESCAPE | +|СРЕДНЕЕ |AVG | +|ССЫЛКА |REFS | +|СТРОКА |STRING | +|СУММА |SUM | +|ТИП |TYPE | +|ТИПЗНАЧЕНИЯ |VALUETYPE | +|ТОГДА |THEN | +|ТОЛЬКО |ONLY | +|УБЫВ |DESC | +|УНИЧТОЖИТЬ |DROP | +|УПОРЯДОЧИТЬ |ORDER | +|ЧАС |HOUR | +|ЧИСЛО |NUMBER | + +## Sources + + +* Источник: [Стандарт: Оформление текстов запросов](https://its.1c.ru/db/v8std#content:437:hdoc) + +## Snippets + + +### Diagnostic ignorance in code + +```bsl +// BSLLS:CanonicalSpellingKeywordsInQuery-off +// BSLLS:CanonicalSpellingKeywordsInQuery-on +``` + +### Parameter for config + +```json +"CanonicalSpellingKeywordsInQuery": false +``` diff --git a/docs/en/diagnostics/CodeOutOfRegion.md b/docs/en/diagnostics/CodeOutOfRegion.md index 90f48949c0c..88639a795c5 100644 --- a/docs/en/diagnostics/CodeOutOfRegion.md +++ b/docs/en/diagnostics/CodeOutOfRegion.md @@ -38,7 +38,7 @@ Correct: #EndRegion ``` -Name matching table (full in [source code](https://github.com/1c-syntax/bsl-language-server/blob/develop/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Keywords.java#L255)): +Name matching table (full in [source code](https://github.com/1c-syntax/bsl-language-server/blob/develop/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/BSLKeywords.java#L255)): | RU | EN | | --------------------------------------- | ---------------------------- | | ПрограммныйИнтерфейс | Public | diff --git a/docs/en/diagnostics/index.md b/docs/en/diagnostics/index.md index be4f569d67a..81bb3be2876 100644 --- a/docs/en/diagnostics/index.md +++ b/docs/en/diagnostics/index.md @@ -1,4 +1,4 @@ -# Diagnostics +# Diagnostics Used for code analysis to meet coding standards and search for possible errors. @@ -24,6 +24,7 @@ Total: **157** [BeginTransactionBeforeTryCatch](BeginTransactionBeforeTryCatch.md) | Violating transaction rules for the 'BeginTransaction' method | Yes | Major | Error | `standard` [CachedPublic](CachedPublic.md) | Cached public methods | Yes | Major | Code smell | `standard`
`design` [CanonicalSpellingKeywords](CanonicalSpellingKeywords.md) | Canonical keyword writing | Yes | Info | Code smell | `standard` + [CanonicalSpellingKeywordsInQuery](CanonicalSpellingKeywordsInQuery.md) | Checking the canonical spelling of keywords in a query | Yes | Info | Code smell | `standard` [CodeAfterAsyncCall](CodeAfterAsyncCall.md) | Lines of code after the asynchronous method call | No | Major | Code smell | `suspicious` [CodeBlockBeforeSub](CodeBlockBeforeSub.md) | Method definitions must be placed before the module body operators | Yes | Blocker | Error | `error` [CodeOutOfRegion](CodeOutOfRegion.md) | Code out of region | Yes | Info | Code smell | `standard` diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractExecuteExternalCodeDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractExecuteExternalCodeDiagnostic.java index 8b54d19b0ef..a6b40ca58f3 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractExecuteExternalCodeDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/AbstractExecuteExternalCodeDiagnostic.java @@ -21,7 +21,7 @@ */ package com.github._1c_syntax.bsl.languageserver.diagnostics; -import com.github._1c_syntax.bsl.languageserver.utils.Keywords; +import com.github._1c_syntax.bsl.languageserver.utils.BSLKeywords; import com.github._1c_syntax.bsl.parser.BSLParser; import com.github._1c_syntax.utils.CaseInsensitivePattern; import org.antlr.v4.runtime.tree.ParseTree; @@ -32,7 +32,7 @@ abstract class AbstractExecuteExternalCodeDiagnostic extends AbstractVisitorDiagnostic { private static final Pattern EVAL_METHOD_NAME = CaseInsensitivePattern.compile( - String.format("^(%s|%s)$", Keywords.EVAL_EN, Keywords.EVAL_RU)); + String.format("^(%s|%s)$", BSLKeywords.EVAL_EN, BSLKeywords.EVAL_RU)); @Override public ParseTree visitExecuteStatement(BSLParser.ExecuteStatementContext ctx) { diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CachedPublicDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CachedPublicDiagnostic.java index 844f2afe167..0269f5a4c4a 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CachedPublicDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CachedPublicDiagnostic.java @@ -27,7 +27,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.Keywords; +import com.github._1c_syntax.bsl.languageserver.utils.BSLKeywords; import com.github._1c_syntax.mdclasses.mdo.MDCommonModule; import com.github._1c_syntax.mdclasses.mdo.support.ModuleType; import com.github._1c_syntax.mdclasses.mdo.support.ReturnValueReuse; @@ -52,7 +52,7 @@ public class CachedPublicDiagnostic extends AbstractDiagnostic { private static final Pattern PUBLIC = CaseInsensitivePattern.compile( - String.format("^(%s|%s)$", Keywords.PUBLIC_REGION_RU, Keywords.PUBLIC_REGION_EN)); + String.format("^(%s|%s)$", BSLKeywords.PUBLIC_REGION_RU, BSLKeywords.PUBLIC_REGION_EN)); @Override protected void check() { diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CanonicalSpellingKeywordsDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CanonicalSpellingKeywordsDiagnostic.java index 3f42b1607ff..b7ffaa41afe 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CanonicalSpellingKeywordsDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CanonicalSpellingKeywordsDiagnostic.java @@ -27,7 +27,7 @@ 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.providers.CodeActionProvider; -import com.github._1c_syntax.bsl.languageserver.utils.Keywords; +import com.github._1c_syntax.bsl.languageserver.utils.BSLKeywords; import com.github._1c_syntax.bsl.parser.BSLParser; import org.antlr.v4.runtime.Token; import org.eclipse.lsp4j.CodeAction; @@ -65,87 +65,87 @@ private static Map> getDefaultPreset() { Map> result = new HashMap<>(); - result.put(BSLParser.IF_KEYWORD, List.of(Keywords.IF_RU, Keywords.IF_EN)); - result.put(BSLParser.THEN_KEYWORD, List.of(Keywords.THEN_RU, Keywords.THEN_EN)); - result.put(BSLParser.ELSE_KEYWORD, List.of(Keywords.ELSE_RU, Keywords.ELSE_EN)); - result.put(BSLParser.ELSIF_KEYWORD, List.of(Keywords.ELSIF_RU, Keywords.ELSIF_EN)); - result.put(BSLParser.ENDIF_KEYWORD, List.of(Keywords.ENDIF_RU, Keywords.ENDIF_EN)); - result.put(BSLParser.FOR_KEYWORD, List.of(Keywords.FOR_RU, Keywords.FOR_EN)); + result.put(BSLParser.IF_KEYWORD, List.of(BSLKeywords.IF_RU, BSLKeywords.IF_EN)); + result.put(BSLParser.THEN_KEYWORD, List.of(BSLKeywords.THEN_RU, BSLKeywords.THEN_EN)); + result.put(BSLParser.ELSE_KEYWORD, List.of(BSLKeywords.ELSE_RU, BSLKeywords.ELSE_EN)); + result.put(BSLParser.ELSIF_KEYWORD, List.of(BSLKeywords.ELSIF_RU, BSLKeywords.ELSIF_EN)); + result.put(BSLParser.ENDIF_KEYWORD, List.of(BSLKeywords.ENDIF_RU, BSLKeywords.ENDIF_EN)); + result.put(BSLParser.FOR_KEYWORD, List.of(BSLKeywords.FOR_RU, BSLKeywords.FOR_EN)); result.put(BSLParser.EACH_KEYWORD, List.of( - Keywords.EACH_RU, Keywords.EACH_LO_RU, Keywords.EACH_EN, Keywords.EACH_LO_EN)); - result.put(BSLParser.IN_KEYWORD, List.of(Keywords.IN_RU, Keywords.IN_EN)); - result.put(BSLParser.DO_KEYWORD, List.of(Keywords.DO_RU, Keywords.DO_EN)); - result.put(BSLParser.WHILE_KEYWORD, List.of(Keywords.WHILE_RU, Keywords.WHILE_EN)); - result.put(BSLParser.BREAK_KEYWORD, List.of(Keywords.BREAK_RU, Keywords.BREAK_EN)); - result.put(BSLParser.CONTINUE_KEYWORD, List.of(Keywords.CONTINUE_RU, Keywords.CONTINUE_EN)); - result.put(BSLParser.ENDDO_KEYWORD, List.of(Keywords.END_DO_RU, Keywords.END_DO_EN)); - result.put(BSLParser.TO_KEYWORD, List.of(Keywords.TO_RU, Keywords.TO_EN)); - result.put(BSLParser.PROCEDURE_KEYWORD, List.of(Keywords.PROCEDURE_RU, Keywords.PROCEDURE_EN)); - result.put(BSLParser.VAL_KEYWORD, List.of(Keywords.VAL_RU, Keywords.VAL_EN)); - result.put(BSLParser.EXPORT_KEYWORD, List.of(Keywords.EXPORT_RU, Keywords.EXPORT_EN)); - result.put(BSLParser.VAR_KEYWORD, List.of(Keywords.VAR_RU, Keywords.VAR_EN)); - result.put(BSLParser.TRY_KEYWORD, List.of(Keywords.TRY_RU, Keywords.TRY_EN)); - result.put(BSLParser.EXECUTE_KEYWORD, List.of(Keywords.EXECUTE_RU, Keywords.EXECUTE_EN)); - result.put(BSLParser.RETURN_KEYWORD, List.of(Keywords.RETURN_RU, Keywords.RETURN_EN)); - result.put(BSLParser.TRUE, List.of(Keywords.TRUE_RU, Keywords.TRUE_EN)); - result.put(BSLParser.EXCEPT_KEYWORD, List.of(Keywords.EXCEPT_RU, Keywords.EXCEPT_EN)); - result.put(BSLParser.RAISE_KEYWORD, List.of(Keywords.RAISE_RU, Keywords.RAISE_EN)); - result.put(BSLParser.ENDTRY_KEYWORD, List.of(Keywords.END_TRY_RU, Keywords.END_TRY_EN)); - result.put(BSLParser.ENDPROCEDURE_KEYWORD, List.of(Keywords.END_PROCEDURE_RU, Keywords.END_PROCEDURE_EN)); - result.put(BSLParser.FUNCTION_KEYWORD, List.of(Keywords.FUNCTION_RU, Keywords.FUNCTION_EN)); - result.put(BSLParser.ENDFUNCTION_KEYWORD, List.of(Keywords.END_FUNCTION_RU, Keywords.END_FUNCTION_EN)); - result.put(BSLParser.FALSE, List.of(Keywords.FALSE_RU, Keywords.FALSE_EN)); - result.put(BSLParser.ADDHANDLER_KEYWORD, List.of(Keywords.ADD_HANDLER_RU, Keywords.ADD_HANDLER_EN)); + BSLKeywords.EACH_RU, BSLKeywords.EACH_LO_RU, BSLKeywords.EACH_EN, BSLKeywords.EACH_LO_EN)); + result.put(BSLParser.IN_KEYWORD, List.of(BSLKeywords.IN_RU, BSLKeywords.IN_EN)); + result.put(BSLParser.DO_KEYWORD, List.of(BSLKeywords.DO_RU, BSLKeywords.DO_EN)); + result.put(BSLParser.WHILE_KEYWORD, List.of(BSLKeywords.WHILE_RU, BSLKeywords.WHILE_EN)); + result.put(BSLParser.BREAK_KEYWORD, List.of(BSLKeywords.BREAK_RU, BSLKeywords.BREAK_EN)); + result.put(BSLParser.CONTINUE_KEYWORD, List.of(BSLKeywords.CONTINUE_RU, BSLKeywords.CONTINUE_EN)); + result.put(BSLParser.ENDDO_KEYWORD, List.of(BSLKeywords.END_DO_RU, BSLKeywords.END_DO_EN)); + result.put(BSLParser.TO_KEYWORD, List.of(BSLKeywords.TO_RU, BSLKeywords.TO_EN)); + result.put(BSLParser.PROCEDURE_KEYWORD, List.of(BSLKeywords.PROCEDURE_RU, BSLKeywords.PROCEDURE_EN)); + result.put(BSLParser.VAL_KEYWORD, List.of(BSLKeywords.VAL_RU, BSLKeywords.VAL_EN)); + result.put(BSLParser.EXPORT_KEYWORD, List.of(BSLKeywords.EXPORT_RU, BSLKeywords.EXPORT_EN)); + result.put(BSLParser.VAR_KEYWORD, List.of(BSLKeywords.VAR_RU, BSLKeywords.VAR_EN)); + result.put(BSLParser.TRY_KEYWORD, List.of(BSLKeywords.TRY_RU, BSLKeywords.TRY_EN)); + result.put(BSLParser.EXECUTE_KEYWORD, List.of(BSLKeywords.EXECUTE_RU, BSLKeywords.EXECUTE_EN)); + result.put(BSLParser.RETURN_KEYWORD, List.of(BSLKeywords.RETURN_RU, BSLKeywords.RETURN_EN)); + result.put(BSLParser.TRUE, List.of(BSLKeywords.TRUE_RU, BSLKeywords.TRUE_EN)); + result.put(BSLParser.EXCEPT_KEYWORD, List.of(BSLKeywords.EXCEPT_RU, BSLKeywords.EXCEPT_EN)); + result.put(BSLParser.RAISE_KEYWORD, List.of(BSLKeywords.RAISE_RU, BSLKeywords.RAISE_EN)); + result.put(BSLParser.ENDTRY_KEYWORD, List.of(BSLKeywords.END_TRY_RU, BSLKeywords.END_TRY_EN)); + result.put(BSLParser.ENDPROCEDURE_KEYWORD, List.of(BSLKeywords.END_PROCEDURE_RU, BSLKeywords.END_PROCEDURE_EN)); + result.put(BSLParser.FUNCTION_KEYWORD, List.of(BSLKeywords.FUNCTION_RU, BSLKeywords.FUNCTION_EN)); + result.put(BSLParser.ENDFUNCTION_KEYWORD, List.of(BSLKeywords.END_FUNCTION_RU, BSLKeywords.END_FUNCTION_EN)); + result.put(BSLParser.FALSE, List.of(BSLKeywords.FALSE_RU, BSLKeywords.FALSE_EN)); + result.put(BSLParser.ADDHANDLER_KEYWORD, List.of(BSLKeywords.ADD_HANDLER_RU, BSLKeywords.ADD_HANDLER_EN)); result.put(BSLParser.REMOVEHANDLER_KEYWORD, List.of( - Keywords.REMOVE_HANDLER_RU, Keywords.REMOVE_HANDLER_EN)); - result.put(BSLParser.GOTO_KEYWORD, List.of(Keywords.GOTO_RU, Keywords.GOTO_EN)); + BSLKeywords.REMOVE_HANDLER_RU, BSLKeywords.REMOVE_HANDLER_EN)); + result.put(BSLParser.GOTO_KEYWORD, List.of(BSLKeywords.GOTO_RU, BSLKeywords.GOTO_EN)); result.put(BSLParser.AND_KEYWORD, List.of( - Keywords.AND_RU, Keywords.AND_UP_EN, Keywords.AND_EN)); + BSLKeywords.AND_RU, BSLKeywords.AND_UP_EN, BSLKeywords.AND_EN)); result.put(BSLParser.OR_KEYWORD, List.of( - Keywords.OR_RU, Keywords.OR_UP_RU, Keywords.OR_EN, Keywords.OR_UP_EN)); + BSLKeywords.OR_RU, BSLKeywords.OR_UP_RU, BSLKeywords.OR_EN, BSLKeywords.OR_UP_EN)); result.put(BSLParser.NOT_KEYWORD, List.of( - Keywords.NOT_RU, Keywords.NOT_UP_RU, Keywords.NOT_EN, Keywords.NOT_UP_EN)); - result.put(BSLParser.NEW_KEYWORD, List.of(Keywords.NEW_RU, Keywords.NEW_EN)); - result.put(BSLParser.UNDEFINED, List.of(Keywords.UNDEFINED_RU, Keywords.UNDEFINED_EN)); - result.put(BSLParser.PREPROC_REGION, List.of(Keywords.REGION_RU, Keywords.REGION_EN)); - result.put(BSLParser.PREPROC_END_REGION, List.of(Keywords.ENDREGION_RU, Keywords.ENDREGION_EN)); - result.put(BSLParser.PREPROC_IF_KEYWORD, List.of(Keywords.IF_RU, Keywords.IF_EN)); - result.put(BSLParser.PREPROC_THEN_KEYWORD, List.of(Keywords.THEN_RU, Keywords.THEN_EN)); - result.put(BSLParser.PREPROC_ELSIF_KEYWORD, List.of(Keywords.ELSIF_RU, Keywords.ELSIF_EN)); - result.put(BSLParser.PREPROC_ELSE_KEYWORD, List.of(Keywords.ELSE_RU, Keywords.ELSE_EN)); - result.put(BSLParser.PREPROC_ENDIF_KEYWORD, List.of(Keywords.ENDIF_RU, Keywords.ENDIF_EN)); + BSLKeywords.NOT_RU, BSLKeywords.NOT_UP_RU, BSLKeywords.NOT_EN, BSLKeywords.NOT_UP_EN)); + result.put(BSLParser.NEW_KEYWORD, List.of(BSLKeywords.NEW_RU, BSLKeywords.NEW_EN)); + result.put(BSLParser.UNDEFINED, List.of(BSLKeywords.UNDEFINED_RU, BSLKeywords.UNDEFINED_EN)); + result.put(BSLParser.PREPROC_REGION, List.of(BSLKeywords.REGION_RU, BSLKeywords.REGION_EN)); + result.put(BSLParser.PREPROC_END_REGION, List.of(BSLKeywords.ENDREGION_RU, BSLKeywords.ENDREGION_EN)); + result.put(BSLParser.PREPROC_IF_KEYWORD, List.of(BSLKeywords.IF_RU, BSLKeywords.IF_EN)); + result.put(BSLParser.PREPROC_THEN_KEYWORD, List.of(BSLKeywords.THEN_RU, BSLKeywords.THEN_EN)); + result.put(BSLParser.PREPROC_ELSIF_KEYWORD, List.of(BSLKeywords.ELSIF_RU, BSLKeywords.ELSIF_EN)); + result.put(BSLParser.PREPROC_ELSE_KEYWORD, List.of(BSLKeywords.ELSE_RU, BSLKeywords.ELSE_EN)); + result.put(BSLParser.PREPROC_ENDIF_KEYWORD, List.of(BSLKeywords.ENDIF_RU, BSLKeywords.ENDIF_EN)); result.put(BSLParser.PREPROC_OR_KEYWORD, List.of( - Keywords.OR_RU, Keywords.OR_UP_RU, Keywords.OR_EN, Keywords.OR_UP_EN)); + BSLKeywords.OR_RU, BSLKeywords.OR_UP_RU, BSLKeywords.OR_EN, BSLKeywords.OR_UP_EN)); result.put(BSLParser.PREPROC_AND_KEYWORD, List.of( - Keywords.AND_RU, Keywords.AND_EN, Keywords.AND_UP_EN)); + BSLKeywords.AND_RU, BSLKeywords.AND_EN, BSLKeywords.AND_UP_EN)); result.put(BSLParser.PREPROC_NOT_KEYWORD, List.of( - Keywords.NOT_RU, Keywords.NOT_UP_RU, Keywords.NOT_EN, Keywords.NOT_UP_EN)); - result.put(BSLParser.PREPROC_SERVER_SYMBOL, List.of(Keywords.SERVER_RU, Keywords.SERVER_EN)); - result.put(BSLParser.PREPROC_CLIENT_SYMBOL, List.of(Keywords.CLIENT_RU, Keywords.CLIENT_EN)); + BSLKeywords.NOT_RU, BSLKeywords.NOT_UP_RU, BSLKeywords.NOT_EN, BSLKeywords.NOT_UP_EN)); + result.put(BSLParser.PREPROC_SERVER_SYMBOL, List.of(BSLKeywords.SERVER_RU, BSLKeywords.SERVER_EN)); + result.put(BSLParser.PREPROC_CLIENT_SYMBOL, List.of(BSLKeywords.CLIENT_RU, BSLKeywords.CLIENT_EN)); result.put(BSLParser.PREPROC_MOBILEAPPCLIENT_SYMBOL, List.of( - Keywords.MOBILE_APP_CLIENT_RU, Keywords.MOBILE_APP_CLIENT_EN)); + BSLKeywords.MOBILE_APP_CLIENT_RU, BSLKeywords.MOBILE_APP_CLIENT_EN)); result.put(BSLParser.PREPROC_MOBILEAPPSERVER_SYMBOL, List.of( - Keywords.MOBILE_APP_SERVER_RU, Keywords.MOBILE_APP_SERVER_EN)); + BSLKeywords.MOBILE_APP_SERVER_RU, BSLKeywords.MOBILE_APP_SERVER_EN)); result.put(BSLParser.PREPROC_MOBILECLIENT_SYMBOL, List.of( - Keywords.MOBILE_CLIENT_RU, Keywords.MOBILE_CLIENT_EN)); + BSLKeywords.MOBILE_CLIENT_RU, BSLKeywords.MOBILE_CLIENT_EN)); result.put(BSLParser.PREPROC_THICKCLIENTORDINARYAPPLICATION_SYMBOL, List.of( - Keywords.THICK_CLIENT_ORDINARY_APPLICATION_RU, Keywords.THICK_CLIENT_ORDINARY_APPLICATION_EN)); + BSLKeywords.THICK_CLIENT_ORDINARY_APPLICATION_RU, BSLKeywords.THICK_CLIENT_ORDINARY_APPLICATION_EN)); result.put(BSLParser.PREPROC_THICKCLIENTMANAGEDAPPLICATION_SYMBOL, List.of( - Keywords.THICK_CLIENT_MANAGED_APPLICATION_RU, Keywords.THICK_CLIENT_MANAGED_APPLICATION_EN)); + BSLKeywords.THICK_CLIENT_MANAGED_APPLICATION_RU, BSLKeywords.THICK_CLIENT_MANAGED_APPLICATION_EN)); result.put(BSLParser.PREPROC_EXTERNALCONNECTION_SYMBOL, List.of( - Keywords.EXTERNAL_CONNECTION_RU, Keywords.EXTERNAL_CONNECTION_EN)); - result.put(BSLParser.PREPROC_THINCLIENT_SYMBOL, List.of(Keywords.THIN_CLIENT_RU, Keywords.THIN_CLIENT_EN)); - result.put(BSLParser.PREPROC_WEBCLIENT_SYMBOL, List.of(Keywords.WEB_CLIENT_RU, Keywords.WEB_CLIENT_EN)); - result.put(BSLParser.PREPROC_ATCLIENT_SYMBOL, List.of(Keywords.AT_CLIENT_RU, Keywords.AT_CLIENT_EN)); - result.put(BSLParser.PREPROC_ATSERVER_SYMBOL, List.of(Keywords.AT_SERVER_RU, Keywords.AT_SERVER_EN)); - result.put(BSLParser.ANNOTATION_ATCLIENT_SYMBOL, List.of(Keywords.AT_CLIENT_RU, Keywords.AT_CLIENT_EN)); - result.put(BSLParser.ANNOTATION_ATSERVER_SYMBOL, List.of(Keywords.AT_SERVER_RU, Keywords.AT_SERVER_EN)); + BSLKeywords.EXTERNAL_CONNECTION_RU, BSLKeywords.EXTERNAL_CONNECTION_EN)); + result.put(BSLParser.PREPROC_THINCLIENT_SYMBOL, List.of(BSLKeywords.THIN_CLIENT_RU, BSLKeywords.THIN_CLIENT_EN)); + result.put(BSLParser.PREPROC_WEBCLIENT_SYMBOL, List.of(BSLKeywords.WEB_CLIENT_RU, BSLKeywords.WEB_CLIENT_EN)); + result.put(BSLParser.PREPROC_ATCLIENT_SYMBOL, List.of(BSLKeywords.AT_CLIENT_RU, BSLKeywords.AT_CLIENT_EN)); + result.put(BSLParser.PREPROC_ATSERVER_SYMBOL, List.of(BSLKeywords.AT_SERVER_RU, BSLKeywords.AT_SERVER_EN)); + result.put(BSLParser.ANNOTATION_ATCLIENT_SYMBOL, List.of(BSLKeywords.AT_CLIENT_RU, BSLKeywords.AT_CLIENT_EN)); + result.put(BSLParser.ANNOTATION_ATSERVER_SYMBOL, List.of(BSLKeywords.AT_SERVER_RU, BSLKeywords.AT_SERVER_EN)); result.put(BSLParser.ANNOTATION_ATSERVERNOCONTEXT_SYMBOL, List.of( - Keywords.AT_SERVER_NO_CONTEXT_RU, Keywords.AT_SERVER_NO_CONTEXT_EN)); + BSLKeywords.AT_SERVER_NO_CONTEXT_RU, BSLKeywords.AT_SERVER_NO_CONTEXT_EN)); result.put(BSLParser.ANNOTATION_ATCLIENTATSERVERNOCONTEXT_SYMBOL, List.of( - Keywords.AT_CLIENT_AT_SERVER_NO_CONTEXT_RU, Keywords.AT_CLIENT_AT_SERVER_NO_CONTEXT_EN)); + BSLKeywords.AT_CLIENT_AT_SERVER_NO_CONTEXT_RU, BSLKeywords.AT_CLIENT_AT_SERVER_NO_CONTEXT_EN)); result.put(BSLParser.ANNOTATION_ATCLIENTATSERVER_SYMBOL, List.of( - Keywords.AT_CLIENT_AT_SERVER_RU, Keywords.AT_CLIENT_AT_SERVER_EN)); + BSLKeywords.AT_CLIENT_AT_SERVER_RU, BSLKeywords.AT_CLIENT_AT_SERVER_EN)); return result; } @@ -153,114 +153,114 @@ private static Map> getDefaultPreset() { private static Map getCanonical() { Map result = new HashMap<>(); - result.put(Keywords.IF_UP_RU, Keywords.IF_RU); - result.put(Keywords.IF_UP_EN, Keywords.IF_EN); - result.put(Keywords.THEN_UP_RU, Keywords.THEN_RU); - result.put(Keywords.THEN_UP_EN, Keywords.THEN_EN); - result.put(Keywords.ELSE_UP_RU, Keywords.ELSE_RU); - result.put(Keywords.ELSE_UP_EN, Keywords.ELSE_EN); - result.put(Keywords.ELSIF_UP_RU, Keywords.ELSIF_RU); - result.put(Keywords.ELSIF_UP_EN, Keywords.ELSIF_EN); - result.put(Keywords.ENDIF_UP_RU, Keywords.ENDIF_RU); - result.put(Keywords.ENDIF_UP_EN, Keywords.ENDIF_EN); - result.put(Keywords.FOR_UP_RU, Keywords.FOR_RU); - result.put(Keywords.FOR_UP_EN, Keywords.FOR_EN); - result.put(Keywords.EACH_UP_RU, Keywords.EACH_RU); - result.put(Keywords.EACH_UP_EN, Keywords.EACH_EN); - result.put(Keywords.IN_UP_RU, Keywords.IN_RU); - result.put(Keywords.IN_UP_EN, Keywords.IN_EN); - result.put(Keywords.DO_UP_RU, Keywords.DO_RU); - result.put(Keywords.DO_UP_EN, Keywords.DO_EN); - result.put(Keywords.WHILE_UP_RU, Keywords.WHILE_RU); - result.put(Keywords.WHILE_UP_EN, Keywords.WHILE_EN); - result.put(Keywords.BREAK_UP_RU, Keywords.BREAK_RU); - result.put(Keywords.BREAK_UP_EN, Keywords.BREAK_EN); - result.put(Keywords.CONTINUE_UP_RU, Keywords.CONTINUE_RU); - result.put(Keywords.CONTINUE_UP_EN, Keywords.CONTINUE_EN); - result.put(Keywords.END_DO_UP_RU, Keywords.END_DO_RU); - result.put(Keywords.END_DO_UP_EN, Keywords.END_DO_EN); - result.put(Keywords.TO_UP_RU, Keywords.TO_RU); - result.put(Keywords.TO_UP_EN, Keywords.TO_EN); - result.put(Keywords.PROCEDURE_UP_RU, Keywords.PROCEDURE_RU); - result.put(Keywords.PROCEDURE_UP_EN, Keywords.PROCEDURE_EN); - result.put(Keywords.VAL_UP_RU, Keywords.VAL_RU); - result.put(Keywords.VAL_UP_EN, Keywords.VAL_EN); - result.put(Keywords.EXPORT_UP_RU, Keywords.EXPORT_RU); - result.put(Keywords.EXPORT_UP_EN, Keywords.EXPORT_EN); - result.put(Keywords.VAR_UP_RU, Keywords.VAR_RU); - result.put(Keywords.VAR_UP_EN, Keywords.VAR_EN); - result.put(Keywords.TRY_UP_RU, Keywords.TRY_RU); - result.put(Keywords.TRY_UP_EN, Keywords.TRY_EN); - result.put(Keywords.EXECUTE_UP_RU, Keywords.EXECUTE_RU); - result.put(Keywords.EXECUTE_UP_EN, Keywords.EXECUTE_EN); - result.put(Keywords.RETURN_UP_RU, Keywords.RETURN_RU); - result.put(Keywords.RETURN_UP_EN, Keywords.RETURN_EN); - result.put(Keywords.TRUE_UP_RU, Keywords.TRUE_RU); - result.put(Keywords.TRUE_UP_EN, Keywords.TRUE_EN); - result.put(Keywords.EXCEPT_UP_RU, Keywords.EXCEPT_RU); - result.put(Keywords.EXCEPT_UP_EN, Keywords.EXCEPT_EN); - result.put(Keywords.RAISE_UP_RU, Keywords.RAISE_RU); - result.put(Keywords.RAISE_UP_EN, Keywords.RAISE_EN); - result.put(Keywords.END_TRY_UP_RU, Keywords.END_TRY_RU); - result.put(Keywords.END_TRY_UP_EN, Keywords.END_TRY_EN); - result.put(Keywords.END_PROCEDURE_UP_RU, Keywords.END_PROCEDURE_RU); - result.put(Keywords.END_PROCEDURE_UP_EN, Keywords.END_PROCEDURE_EN); - result.put(Keywords.FUNCTION_UP_RU, Keywords.FUNCTION_RU); - result.put(Keywords.FUNCTION_UP_EN, Keywords.FUNCTION_EN); - result.put(Keywords.END_FUNCTION_UP_RU, Keywords.END_FUNCTION_RU); - result.put(Keywords.END_FUNCTION_UP_EN, Keywords.END_FUNCTION_EN); - result.put(Keywords.FALSE_UP_RU, Keywords.FALSE_RU); - result.put(Keywords.FALSE_UP_EN, Keywords.FALSE_EN); - result.put(Keywords.ADD_HANDLER_UP_RU, Keywords.ADD_HANDLER_RU); - result.put(Keywords.ADD_HANDLER_UP_EN, Keywords.ADD_HANDLER_EN); - result.put(Keywords.REMOVE_HANDLER_UP_RU, Keywords.REMOVE_HANDLER_RU); - result.put(Keywords.REMOVE_HANDLER_UP_EN, Keywords.REMOVE_HANDLER_EN); - result.put(Keywords.GOTO_UP_RU, Keywords.GOTO_RU); - result.put(Keywords.GOTO_UP_EN, Keywords.GOTO_EN); - result.put(Keywords.AND_RU, Keywords.AND_RU); - result.put(Keywords.AND_UP_EN, Keywords.AND_UP_EN); - result.put(Keywords.OR_UP_RU, Keywords.OR_UP_RU); - result.put(Keywords.OR_UP_EN, Keywords.OR_UP_EN); - result.put(Keywords.NOT_UP_RU, Keywords.NOT_UP_RU); - result.put(Keywords.NOT_UP_EN, Keywords.NOT_UP_EN); - result.put(Keywords.NEW_UP_RU, Keywords.NEW_RU); - result.put(Keywords.NEW_UP_EN, Keywords.NEW_EN); - result.put(Keywords.UNDEFINED_UP_RU, Keywords.UNDEFINED_RU); - result.put(Keywords.UNDEFINED_UP_EN, Keywords.UNDEFINED_EN); - result.put(Keywords.REGION_UP_RU, Keywords.REGION_RU); - result.put(Keywords.REGION_UP_EN, Keywords.REGION_EN); - result.put(Keywords.ENDREGION_UP_RU, Keywords.ENDREGION_RU); - result.put(Keywords.ENDREGION_UP_EN, Keywords.ENDREGION_EN); - result.put(Keywords.SERVER_UP_RU, Keywords.SERVER_RU); - result.put(Keywords.SERVER_UP_EN, Keywords.SERVER_EN); - result.put(Keywords.CLIENT_UP_RU, Keywords.CLIENT_RU); - result.put(Keywords.CLIENT_UP_EN, Keywords.CLIENT_EN); - result.put(Keywords.MOBILE_APP_CLIENT_UP_RU, Keywords.MOBILE_APP_CLIENT_RU); - result.put(Keywords.MOBILE_APP_CLIENT_UP_EN, Keywords.MOBILE_APP_CLIENT_EN); - result.put(Keywords.MOBILE_APP_SERVER_UP_RU, Keywords.MOBILE_APP_SERVER_RU); - result.put(Keywords.MOBILE_APP_SERVER_UP_EN, Keywords.MOBILE_APP_SERVER_EN); - result.put(Keywords.MOBILE_CLIENT_UP_RU, Keywords.MOBILE_CLIENT_RU); - result.put(Keywords.MOBILE_CLIENT_UP_EN, Keywords.MOBILE_CLIENT_EN); - result.put(Keywords.THICK_CLIENT_ORDINARY_APPLICATION_UP_RU, Keywords.THICK_CLIENT_ORDINARY_APPLICATION_RU); - result.put(Keywords.THICK_CLIENT_ORDINARY_APPLICATION_UP_EN, Keywords.THICK_CLIENT_ORDINARY_APPLICATION_EN); - result.put(Keywords.THICK_CLIENT_MANAGED_APPLICATION_UP_RU, Keywords.THICK_CLIENT_MANAGED_APPLICATION_RU); - result.put(Keywords.THICK_CLIENT_MANAGED_APPLICATION_UP_EN, Keywords.THICK_CLIENT_MANAGED_APPLICATION_EN); - result.put(Keywords.EXTERNAL_CONNECTION_UP_RU, Keywords.EXTERNAL_CONNECTION_RU); - result.put(Keywords.EXTERNAL_CONNECTION_UP_EN, Keywords.EXTERNAL_CONNECTION_EN); - result.put(Keywords.THIN_CLIENT_UP_RU, Keywords.THIN_CLIENT_RU); - result.put(Keywords.THIN_CLIENT_UP_EN, Keywords.THIN_CLIENT_EN); - result.put(Keywords.WEB_CLIENT_UP_RU, Keywords.WEB_CLIENT_RU); - result.put(Keywords.WEB_CLIENT_UP_EN, Keywords.WEB_CLIENT_EN); - result.put(Keywords.AT_CLIENT_UP_RU, Keywords.AT_CLIENT_RU); - result.put(Keywords.AT_CLIENT_UP_EN, Keywords.AT_CLIENT_EN); - result.put(Keywords.AT_SERVER_UP_RU, Keywords.AT_SERVER_RU); - result.put(Keywords.AT_SERVER_UP_EN, Keywords.AT_SERVER_EN); - result.put(Keywords.AT_SERVER_NO_CONTEXT_UP_RU, Keywords.AT_SERVER_NO_CONTEXT_RU); - result.put(Keywords.AT_SERVER_NO_CONTEXT_UP_EN, Keywords.AT_SERVER_NO_CONTEXT_EN); - result.put(Keywords.AT_CLIENT_AT_SERVER_NO_CONTEXT_UP_RU, Keywords.AT_CLIENT_AT_SERVER_NO_CONTEXT_RU); - result.put(Keywords.AT_CLIENT_AT_SERVER_NO_CONTEXT_UP_EN, Keywords.AT_CLIENT_AT_SERVER_NO_CONTEXT_EN); - result.put(Keywords.AT_CLIENT_AT_SERVER_UP_RU, Keywords.AT_CLIENT_AT_SERVER_RU); - result.put(Keywords.AT_CLIENT_AT_SERVER_UP_EN, Keywords.AT_CLIENT_AT_SERVER_EN); + result.put(BSLKeywords.IF_UP_RU, BSLKeywords.IF_RU); + result.put(BSLKeywords.IF_UP_EN, BSLKeywords.IF_EN); + result.put(BSLKeywords.THEN_UP_RU, BSLKeywords.THEN_RU); + result.put(BSLKeywords.THEN_UP_EN, BSLKeywords.THEN_EN); + result.put(BSLKeywords.ELSE_UP_RU, BSLKeywords.ELSE_RU); + result.put(BSLKeywords.ELSE_UP_EN, BSLKeywords.ELSE_EN); + result.put(BSLKeywords.ELSIF_UP_RU, BSLKeywords.ELSIF_RU); + result.put(BSLKeywords.ELSIF_UP_EN, BSLKeywords.ELSIF_EN); + result.put(BSLKeywords.ENDIF_UP_RU, BSLKeywords.ENDIF_RU); + result.put(BSLKeywords.ENDIF_UP_EN, BSLKeywords.ENDIF_EN); + result.put(BSLKeywords.FOR_UP_RU, BSLKeywords.FOR_RU); + result.put(BSLKeywords.FOR_UP_EN, BSLKeywords.FOR_EN); + result.put(BSLKeywords.EACH_UP_RU, BSLKeywords.EACH_RU); + result.put(BSLKeywords.EACH_UP_EN, BSLKeywords.EACH_EN); + result.put(BSLKeywords.IN_UP_RU, BSLKeywords.IN_RU); + result.put(BSLKeywords.IN_UP_EN, BSLKeywords.IN_EN); + result.put(BSLKeywords.DO_UP_RU, BSLKeywords.DO_RU); + result.put(BSLKeywords.DO_UP_EN, BSLKeywords.DO_EN); + result.put(BSLKeywords.WHILE_UP_RU, BSLKeywords.WHILE_RU); + result.put(BSLKeywords.WHILE_UP_EN, BSLKeywords.WHILE_EN); + result.put(BSLKeywords.BREAK_UP_RU, BSLKeywords.BREAK_RU); + result.put(BSLKeywords.BREAK_UP_EN, BSLKeywords.BREAK_EN); + result.put(BSLKeywords.CONTINUE_UP_RU, BSLKeywords.CONTINUE_RU); + result.put(BSLKeywords.CONTINUE_UP_EN, BSLKeywords.CONTINUE_EN); + result.put(BSLKeywords.END_DO_UP_RU, BSLKeywords.END_DO_RU); + result.put(BSLKeywords.END_DO_UP_EN, BSLKeywords.END_DO_EN); + result.put(BSLKeywords.TO_UP_RU, BSLKeywords.TO_RU); + result.put(BSLKeywords.TO_UP_EN, BSLKeywords.TO_EN); + result.put(BSLKeywords.PROCEDURE_UP_RU, BSLKeywords.PROCEDURE_RU); + result.put(BSLKeywords.PROCEDURE_UP_EN, BSLKeywords.PROCEDURE_EN); + result.put(BSLKeywords.VAL_UP_RU, BSLKeywords.VAL_RU); + result.put(BSLKeywords.VAL_UP_EN, BSLKeywords.VAL_EN); + result.put(BSLKeywords.EXPORT_UP_RU, BSLKeywords.EXPORT_RU); + result.put(BSLKeywords.EXPORT_UP_EN, BSLKeywords.EXPORT_EN); + result.put(BSLKeywords.VAR_UP_RU, BSLKeywords.VAR_RU); + result.put(BSLKeywords.VAR_UP_EN, BSLKeywords.VAR_EN); + result.put(BSLKeywords.TRY_UP_RU, BSLKeywords.TRY_RU); + result.put(BSLKeywords.TRY_UP_EN, BSLKeywords.TRY_EN); + result.put(BSLKeywords.EXECUTE_UP_RU, BSLKeywords.EXECUTE_RU); + result.put(BSLKeywords.EXECUTE_UP_EN, BSLKeywords.EXECUTE_EN); + result.put(BSLKeywords.RETURN_UP_RU, BSLKeywords.RETURN_RU); + result.put(BSLKeywords.RETURN_UP_EN, BSLKeywords.RETURN_EN); + result.put(BSLKeywords.TRUE_UP_RU, BSLKeywords.TRUE_RU); + result.put(BSLKeywords.TRUE_UP_EN, BSLKeywords.TRUE_EN); + result.put(BSLKeywords.EXCEPT_UP_RU, BSLKeywords.EXCEPT_RU); + result.put(BSLKeywords.EXCEPT_UP_EN, BSLKeywords.EXCEPT_EN); + result.put(BSLKeywords.RAISE_UP_RU, BSLKeywords.RAISE_RU); + result.put(BSLKeywords.RAISE_UP_EN, BSLKeywords.RAISE_EN); + result.put(BSLKeywords.END_TRY_UP_RU, BSLKeywords.END_TRY_RU); + result.put(BSLKeywords.END_TRY_UP_EN, BSLKeywords.END_TRY_EN); + result.put(BSLKeywords.END_PROCEDURE_UP_RU, BSLKeywords.END_PROCEDURE_RU); + result.put(BSLKeywords.END_PROCEDURE_UP_EN, BSLKeywords.END_PROCEDURE_EN); + result.put(BSLKeywords.FUNCTION_UP_RU, BSLKeywords.FUNCTION_RU); + result.put(BSLKeywords.FUNCTION_UP_EN, BSLKeywords.FUNCTION_EN); + result.put(BSLKeywords.END_FUNCTION_UP_RU, BSLKeywords.END_FUNCTION_RU); + result.put(BSLKeywords.END_FUNCTION_UP_EN, BSLKeywords.END_FUNCTION_EN); + result.put(BSLKeywords.FALSE_UP_RU, BSLKeywords.FALSE_RU); + result.put(BSLKeywords.FALSE_UP_EN, BSLKeywords.FALSE_EN); + result.put(BSLKeywords.ADD_HANDLER_UP_RU, BSLKeywords.ADD_HANDLER_RU); + result.put(BSLKeywords.ADD_HANDLER_UP_EN, BSLKeywords.ADD_HANDLER_EN); + result.put(BSLKeywords.REMOVE_HANDLER_UP_RU, BSLKeywords.REMOVE_HANDLER_RU); + result.put(BSLKeywords.REMOVE_HANDLER_UP_EN, BSLKeywords.REMOVE_HANDLER_EN); + result.put(BSLKeywords.GOTO_UP_RU, BSLKeywords.GOTO_RU); + result.put(BSLKeywords.GOTO_UP_EN, BSLKeywords.GOTO_EN); + result.put(BSLKeywords.AND_RU, BSLKeywords.AND_RU); + result.put(BSLKeywords.AND_UP_EN, BSLKeywords.AND_UP_EN); + result.put(BSLKeywords.OR_UP_RU, BSLKeywords.OR_UP_RU); + result.put(BSLKeywords.OR_UP_EN, BSLKeywords.OR_UP_EN); + result.put(BSLKeywords.NOT_UP_RU, BSLKeywords.NOT_UP_RU); + result.put(BSLKeywords.NOT_UP_EN, BSLKeywords.NOT_UP_EN); + result.put(BSLKeywords.NEW_UP_RU, BSLKeywords.NEW_RU); + result.put(BSLKeywords.NEW_UP_EN, BSLKeywords.NEW_EN); + result.put(BSLKeywords.UNDEFINED_UP_RU, BSLKeywords.UNDEFINED_RU); + result.put(BSLKeywords.UNDEFINED_UP_EN, BSLKeywords.UNDEFINED_EN); + result.put(BSLKeywords.REGION_UP_RU, BSLKeywords.REGION_RU); + result.put(BSLKeywords.REGION_UP_EN, BSLKeywords.REGION_EN); + result.put(BSLKeywords.ENDREGION_UP_RU, BSLKeywords.ENDREGION_RU); + result.put(BSLKeywords.ENDREGION_UP_EN, BSLKeywords.ENDREGION_EN); + result.put(BSLKeywords.SERVER_UP_RU, BSLKeywords.SERVER_RU); + result.put(BSLKeywords.SERVER_UP_EN, BSLKeywords.SERVER_EN); + result.put(BSLKeywords.CLIENT_UP_RU, BSLKeywords.CLIENT_RU); + result.put(BSLKeywords.CLIENT_UP_EN, BSLKeywords.CLIENT_EN); + result.put(BSLKeywords.MOBILE_APP_CLIENT_UP_RU, BSLKeywords.MOBILE_APP_CLIENT_RU); + result.put(BSLKeywords.MOBILE_APP_CLIENT_UP_EN, BSLKeywords.MOBILE_APP_CLIENT_EN); + result.put(BSLKeywords.MOBILE_APP_SERVER_UP_RU, BSLKeywords.MOBILE_APP_SERVER_RU); + result.put(BSLKeywords.MOBILE_APP_SERVER_UP_EN, BSLKeywords.MOBILE_APP_SERVER_EN); + result.put(BSLKeywords.MOBILE_CLIENT_UP_RU, BSLKeywords.MOBILE_CLIENT_RU); + result.put(BSLKeywords.MOBILE_CLIENT_UP_EN, BSLKeywords.MOBILE_CLIENT_EN); + result.put(BSLKeywords.THICK_CLIENT_ORDINARY_APPLICATION_UP_RU, BSLKeywords.THICK_CLIENT_ORDINARY_APPLICATION_RU); + result.put(BSLKeywords.THICK_CLIENT_ORDINARY_APPLICATION_UP_EN, BSLKeywords.THICK_CLIENT_ORDINARY_APPLICATION_EN); + result.put(BSLKeywords.THICK_CLIENT_MANAGED_APPLICATION_UP_RU, BSLKeywords.THICK_CLIENT_MANAGED_APPLICATION_RU); + result.put(BSLKeywords.THICK_CLIENT_MANAGED_APPLICATION_UP_EN, BSLKeywords.THICK_CLIENT_MANAGED_APPLICATION_EN); + result.put(BSLKeywords.EXTERNAL_CONNECTION_UP_RU, BSLKeywords.EXTERNAL_CONNECTION_RU); + result.put(BSLKeywords.EXTERNAL_CONNECTION_UP_EN, BSLKeywords.EXTERNAL_CONNECTION_EN); + result.put(BSLKeywords.THIN_CLIENT_UP_RU, BSLKeywords.THIN_CLIENT_RU); + result.put(BSLKeywords.THIN_CLIENT_UP_EN, BSLKeywords.THIN_CLIENT_EN); + result.put(BSLKeywords.WEB_CLIENT_UP_RU, BSLKeywords.WEB_CLIENT_RU); + result.put(BSLKeywords.WEB_CLIENT_UP_EN, BSLKeywords.WEB_CLIENT_EN); + result.put(BSLKeywords.AT_CLIENT_UP_RU, BSLKeywords.AT_CLIENT_RU); + result.put(BSLKeywords.AT_CLIENT_UP_EN, BSLKeywords.AT_CLIENT_EN); + result.put(BSLKeywords.AT_SERVER_UP_RU, BSLKeywords.AT_SERVER_RU); + result.put(BSLKeywords.AT_SERVER_UP_EN, BSLKeywords.AT_SERVER_EN); + result.put(BSLKeywords.AT_SERVER_NO_CONTEXT_UP_RU, BSLKeywords.AT_SERVER_NO_CONTEXT_RU); + result.put(BSLKeywords.AT_SERVER_NO_CONTEXT_UP_EN, BSLKeywords.AT_SERVER_NO_CONTEXT_EN); + result.put(BSLKeywords.AT_CLIENT_AT_SERVER_NO_CONTEXT_UP_RU, BSLKeywords.AT_CLIENT_AT_SERVER_NO_CONTEXT_RU); + result.put(BSLKeywords.AT_CLIENT_AT_SERVER_NO_CONTEXT_UP_EN, BSLKeywords.AT_CLIENT_AT_SERVER_NO_CONTEXT_EN); + result.put(BSLKeywords.AT_CLIENT_AT_SERVER_UP_RU, BSLKeywords.AT_CLIENT_AT_SERVER_RU); + result.put(BSLKeywords.AT_CLIENT_AT_SERVER_UP_EN, BSLKeywords.AT_CLIENT_AT_SERVER_EN); return result; } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CanonicalSpellingKeywordsInQueryDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CanonicalSpellingKeywordsInQueryDiagnostic.java new file mode 100644 index 00000000000..9c96483e2f5 --- /dev/null +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CanonicalSpellingKeywordsInQueryDiagnostic.java @@ -0,0 +1,194 @@ +/* + * This file is a part of BSL Language Server. + * + * Copyright (c) 2018-2021 + * Alexey Sosnoviy , Nikita Gryzlov and contributors + * + * SPDX-License-Identifier: LGPL-3.0-or-later + * + * BSL Language Server is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * BSL Language Server is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with BSL Language Server. + */ +package com.github._1c_syntax.bsl.languageserver.diagnostics; + +import com.github._1c_syntax.bsl.languageserver.context.DocumentContext; +import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticMetadata; +import com.github._1c_syntax.bsl.languageserver.diagnostics.metadata.DiagnosticScope; +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.providers.CodeActionProvider; +import com.github._1c_syntax.bsl.languageserver.utils.SDBLKeywords; +import com.github._1c_syntax.bsl.parser.SDBLParser; +import org.antlr.v4.runtime.Token; +import org.antlr.v4.runtime.tree.ParseTree; +import org.eclipse.lsp4j.CodeAction; +import org.eclipse.lsp4j.CodeActionParams; +import org.eclipse.lsp4j.Diagnostic; +import org.eclipse.lsp4j.TextEdit; + +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.stream.Collectors; + +@DiagnosticMetadata( + type = DiagnosticType.CODE_SMELL, + severity = DiagnosticSeverity.INFO, + minutesToFix = 1, + tags = { + DiagnosticTag.STANDARD + }, + scope = DiagnosticScope.BSL + +) +public class CanonicalSpellingKeywordsInQueryDiagnostic extends AbstractSDBLVisitorDiagnostic implements QuickFixProvider { + + private static final Map> canonicalKeywords = getKeywords(); + + private static Map> getKeywords() { + Map> result = new HashMap<>(); + + result.put(SDBLParser.SELECT, List.of(SDBLKeywords.SELECT_RU, SDBLKeywords.SELECT_EN)); + result.put(SDBLParser.AS, List.of(SDBLKeywords.AS_RU, SDBLKeywords.AS_EN)); + result.put(SDBLParser.ALLOWED, List.of(SDBLKeywords.ALLOWED_RU, SDBLKeywords.ALLOWED_EN)); + result.put(SDBLParser.AND, List.of(SDBLKeywords.AND_RU, SDBLKeywords.AND_EN)); + result.put(SDBLParser.ASC, List.of(SDBLKeywords.ASC_RU, SDBLKeywords.ASC_EN)); + result.put(SDBLParser.AUTOORDER, List.of(SDBLKeywords.AUTOORDER_RU, SDBLKeywords.AUTOORDER_EN)); + result.put(SDBLParser.BETWEEN, List.of(SDBLKeywords.BETWEEN_RU, SDBLKeywords.BETWEEN_EN)); + result.put(SDBLParser.CASE, List.of(SDBLKeywords.CASE_RU, SDBLKeywords.CASE_EN)); + result.put(SDBLParser.CAST, List.of(SDBLKeywords.CAST_RU, SDBLKeywords.CAST_EN)); + result.put(SDBLParser.DESC, List.of(SDBLKeywords.DESC_RU, SDBLKeywords.DESC_EN)); + result.put(SDBLParser.DISTINCT, List.of(SDBLKeywords.DISTINCT_RU, SDBLKeywords.DISTINCT_EN)); + result.put(SDBLParser.DROP, List.of(SDBLKeywords.DROP_RU, SDBLKeywords.DROP_EN)); + result.put(SDBLParser.ELSE, List.of(SDBLKeywords.ELSE_RU, SDBLKeywords.ELSE_EN)); + result.put(SDBLParser.END, List.of(SDBLKeywords.END_RU, SDBLKeywords.END_EN)); + result.put(SDBLParser.ESCAPE, List.of(SDBLKeywords.ESCAPE_RU, SDBLKeywords.ESCAPE_EN)); + result.put(SDBLParser.FALSE, List.of(SDBLKeywords.FALSE_RU, SDBLKeywords.FALSE_EN)); + result.put(SDBLParser.FROM, List.of(SDBLKeywords.FROM_RU, SDBLKeywords.FROM_EN)); + result.put(SDBLParser.HAVING, List.of(SDBLKeywords.HAVING_RU, SDBLKeywords.HAVING_EN)); + result.put(SDBLParser.HIERARCHY, List.of(SDBLKeywords.HIERARCHY_RU, SDBLKeywords.HIERARCHY_EN)); + result.put(SDBLParser.INTO, List.of(SDBLKeywords.INTO_RU, SDBLKeywords.INTO_EN)); + result.put(SDBLParser.IS, List.of(SDBLKeywords.IS_RU, SDBLKeywords.IS_EN)); + result.put(SDBLParser.ISNULL, List.of(SDBLKeywords.ISNULL_RU, SDBLKeywords.ISNULL_EN)); + result.put(SDBLParser.LIKE, List.of(SDBLKeywords.LIKE_RU, SDBLKeywords.LIKE_EN)); + result.put(SDBLParser.NOT, List.of(SDBLKeywords.NOT_RU, SDBLKeywords.NOT_EN)); + result.put(SDBLParser.NULL, List.of(SDBLKeywords.NULL_RU, SDBLKeywords.NULL_EN)); + result.put(SDBLParser.OF, List.of(SDBLKeywords.OF_EN)); // нет на кириллице + result.put(SDBLParser.OR, List.of(SDBLKeywords.OR_RU, SDBLKeywords.OR_EN)); + result.put(SDBLParser.OVERALL, List.of(SDBLKeywords.OVERALL_RU, SDBLKeywords.OVERALL_EN)); + result.put(SDBLParser.THEN, List.of(SDBLKeywords.THEN_RU, SDBLKeywords.THEN_EN)); + result.put(SDBLParser.TOP, List.of(SDBLKeywords.TOP_RU, SDBLKeywords.TOP_EN)); + result.put(SDBLParser.TOTALS, List.of(SDBLKeywords.TOTALS_RU, SDBLKeywords.TOTALS_EN)); + result.put(SDBLParser.TRUE, List.of(SDBLKeywords.TRUE_RU, SDBLKeywords.TRUE_EN)); + result.put(SDBLParser.UNDEFINED, List.of(SDBLKeywords.UNDEFINED_RU, SDBLKeywords.UNDEFINED_EN)); + result.put(SDBLParser.WHEN, List.of(SDBLKeywords.WHEN_RU, SDBLKeywords.WHEN_EN)); + result.put(SDBLParser.WHERE, List.of(SDBLKeywords.WHERE_RU, SDBLKeywords.WHERE_EN)); + result.put(SDBLParser.AVG, List.of(SDBLKeywords.AVG_RU, SDBLKeywords.AVG_EN)); + result.put(SDBLParser.BEGINOFPERIOD, List.of(SDBLKeywords.BEGINOFPERIOD_RU, SDBLKeywords.BEGINOFPERIOD_EN)); + result.put(SDBLParser.BOOLEAN, List.of(SDBLKeywords.BOOLEAN_RU, SDBLKeywords.BOOLEAN_EN)); + result.put(SDBLParser.COUNT, List.of(SDBLKeywords.COUNT_RU, SDBLKeywords.COUNT_EN)); + result.put(SDBLParser.DATE, List.of(SDBLKeywords.DATE_RU, SDBLKeywords.DATE_EN)); + result.put(SDBLParser.DATEADD, List.of(SDBLKeywords.DATEADD_RU, SDBLKeywords.DATEADD_EN)); + result.put(SDBLParser.DATEDIFF, List.of(SDBLKeywords.DATEDIFF_RU, SDBLKeywords.DATEDIFF_EN)); + result.put(SDBLParser.DATETIME, List.of(SDBLKeywords.DATETIME_RU, SDBLKeywords.DATETIME_EN)); + result.put(SDBLParser.DAY, List.of(SDBLKeywords.DAY_RU, SDBLKeywords.DAY_EN)); + result.put(SDBLParser.DAYOFYEAR, List.of(SDBLKeywords.DAYOFYEAR_RU, SDBLKeywords.DAYOFYEAR_EN)); + result.put(SDBLParser.EMPTYTABLE, List.of(SDBLKeywords.EMPTYTABLE_RU, SDBLKeywords.EMPTYTABLE_EN)); + result.put(SDBLParser.ENDOFPERIOD, List.of(SDBLKeywords.ENDOFPERIOD_RU, SDBLKeywords.ENDOFPERIOD_EN)); + result.put(SDBLParser.HALFYEAR, List.of(SDBLKeywords.HALFYEAR_RU, SDBLKeywords.HALFYEAR_EN)); + result.put(SDBLParser.HOUR, List.of(SDBLKeywords.HOUR_RU, SDBLKeywords.HOUR_EN)); + result.put(SDBLParser.MAX, List.of(SDBLKeywords.MAX_RU, SDBLKeywords.MAX_EN)); + result.put(SDBLParser.MIN, List.of(SDBLKeywords.MIN_RU, SDBLKeywords.MIN_EN)); + result.put(SDBLParser.MINUTE, List.of(SDBLKeywords.MINUTE_RU, SDBLKeywords.MINUTE_EN)); + result.put(SDBLParser.MONTH, List.of(SDBLKeywords.MONTH_RU, SDBLKeywords.MONTH_EN)); + result.put(SDBLParser.NUMBER, List.of(SDBLKeywords.NUMBER_RU, SDBLKeywords.NUMBER_EN)); + result.put(SDBLParser.QUARTER, List.of(SDBLKeywords.QUARTER_RU, SDBLKeywords.QUARTER_EN)); + result.put(SDBLParser.ONLY, List.of(SDBLKeywords.ONLY_RU, SDBLKeywords.ONLY_EN)); + result.put(SDBLParser.PERIODS, List.of(SDBLKeywords.PERIODS_RU, SDBLKeywords.PERIODS_EN)); + result.put(SDBLParser.REFS, List.of(SDBLKeywords.REFS_RU, SDBLKeywords.REFS_EN)); + result.put(SDBLParser.PRESENTATION, List.of(SDBLKeywords.PRESENTATION_RU, SDBLKeywords.PRESENTATION_EN)); + result.put(SDBLParser.RECORDAUTONUMBER, List.of(SDBLKeywords.RECORDAUTONUMBER_RU, SDBLKeywords.RECORDAUTONUMBER_EN)); + result.put(SDBLParser.REFPRESENTATION, List.of(SDBLKeywords.REFPRESENTATION_RU, SDBLKeywords.REFPRESENTATION_EN)); + result.put(SDBLParser.SECOND, List.of(SDBLKeywords.SECOND_RU, SDBLKeywords.SECOND_EN)); + result.put(SDBLParser.STRING, List.of(SDBLKeywords.STRING_RU, SDBLKeywords.STRING_EN)); + result.put(SDBLParser.SUBSTRING, List.of(SDBLKeywords.SUBSTRING_RU, SDBLKeywords.SUBSTRING_EN)); + result.put(SDBLParser.SUM, List.of(SDBLKeywords.SUM_RU, SDBLKeywords.SUM_EN)); + result.put(SDBLParser.TENDAYS, List.of(SDBLKeywords.TENDAYS_RU, SDBLKeywords.TENDAYS_EN)); + result.put(SDBLParser.TYPE, List.of(SDBLKeywords.TYPE_RU, SDBLKeywords.TYPE_EN)); + result.put(SDBLParser.VALUE, List.of(SDBLKeywords.VALUE_RU, SDBLKeywords.VALUE_EN)); + result.put(SDBLParser.VALUETYPE, List.of(SDBLKeywords.VALUETYPE_RU, SDBLKeywords.VALUETYPE_EN)); + result.put(SDBLParser.WEEK, List.of(SDBLKeywords.WEEK_RU, SDBLKeywords.WEEK_EN)); + result.put(SDBLParser.WEEKDAY, List.of(SDBLKeywords.WEEKDAY_RU, SDBLKeywords.WEEKDAY_EN)); + result.put(SDBLParser.YEAR, List.of(SDBLKeywords.YEAR_RU, SDBLKeywords.YEAR_EN)); + result.put(SDBLParser.INDEX, List.of(SDBLKeywords.INDEX_RU, SDBLKeywords.INDEX_EN)); + result.put(SDBLParser.GROUP, List.of(SDBLKeywords.GROUP_RU, SDBLKeywords.GROUP_EN)); + result.put(SDBLParser.ORDER, List.of(SDBLKeywords.ORDER_RU, SDBLKeywords.ORDER_EN)); + result.put(SDBLParser.GROUPEDBY, List.of(SDBLKeywords.GROUPEDBY_RU, SDBLKeywords.GROUPEDBY_EN)); + result.put(SDBLParser.GROUPING, List.of(SDBLKeywords.GROUPING_RU, SDBLKeywords.GROUPING_EN)); + result.put(SDBLParser.BY_EN, List.of(SDBLKeywords.ON_EN)); // Странное + result.put(SDBLParser.PO_RU, List.of(SDBLKeywords.ON_RU)); // Cтранное + result.put(SDBLParser.ON_EN, List.of(SDBLKeywords.ON_EN)); + result.put(SDBLParser.SET, List.of(SDBLKeywords.SET_RU, SDBLKeywords.SET_EN)); + result.put(SDBLParser.RIGHT, List.of(SDBLKeywords.RIGHT_RU, SDBLKeywords.RIGHT_EN)); + result.put(SDBLParser.LEFT, List.of(SDBLKeywords.LEFT_RU, SDBLKeywords.LEFT_EN)); + result.put(SDBLParser.INNER, List.of(SDBLKeywords.INNER_RU, SDBLKeywords.INNER_EN)); + result.put(SDBLParser.FULL, List.of(SDBLKeywords.FULL_RU, SDBLKeywords.FULL_EN)); + result.put(SDBLParser.JOIN, List.of(SDBLKeywords.JOIN_RU, SDBLKeywords.JOIN_EN)); + result.put(SDBLParser.OUTER, List.of(SDBLKeywords.OUTER_RU, SDBLKeywords.OUTER_EN)); + result.put(SDBLParser.FOR, List.of(SDBLKeywords.FOR_RU, SDBLKeywords.FOR_EN)); + result.put(SDBLParser.UPDATE, List.of(SDBLKeywords.UPDATE_RU, SDBLKeywords.UPDATE_EN)); + result.put(SDBLParser.ALL, List.of(SDBLKeywords.ALL_RU, SDBLKeywords.ALL_EN)); + result.put(SDBLParser.UNION, List.of(SDBLKeywords.UNION_RU, SDBLKeywords.UNION_EN)); + result.put(SDBLParser.HIERARCHY_FOR_IN, List.of(SDBLKeywords.IN_HIERARCHY_RU, SDBLKeywords.HIERARCHY_EN)); + result.put(SDBLParser.IN, List.of(SDBLKeywords.IN_RU, SDBLKeywords.IN_EN)); + + return result; + + } + + + @Override + public ParseTree visitQueryPackage(SDBLParser.QueryPackageContext ctx) { + + ctx.getTokens().parallelStream().filter((Token t) -> + canonicalKeywords.get(t.getType()) != null && !canonicalKeywords.get(t.getType()).contains(t.getText())) + .forEach(token -> + diagnosticStorage.addDiagnostic( + token, + info.getMessage(token.getText()) + )); + + return ctx; + + } + + @Override + public List getQuickFixes(List diagnostics, CodeActionParams params, DocumentContext documentContext) { + + List textEdits = diagnostics.stream() + .map(Diagnostic::getRange) + .map(range -> new TextEdit(range, documentContext.getText(range).toUpperCase(Locale.ENGLISH))) + .collect(Collectors.toList()); + + return CodeActionProvider.createCodeActions( + textEdits, + info.getResourceString("quickFixMessage"), + documentContext.getUri(), + diagnostics + ); + + } + +} diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleMissingAPIDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleMissingAPIDiagnostic.java index a444932b1dc..9579ae3be80 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleMissingAPIDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CommonModuleMissingAPIDiagnostic.java @@ -28,7 +28,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.Keywords; +import com.github._1c_syntax.bsl.languageserver.utils.BSLKeywords; import com.github._1c_syntax.bsl.languageserver.utils.Ranges; import com.github._1c_syntax.mdclasses.mdo.support.ModuleType; @@ -54,10 +54,10 @@ public class CommonModuleMissingAPIDiagnostic extends AbstractDiagnostic { private static Set makeRegionsAPI() { Set result = new TreeSet<>(String.CASE_INSENSITIVE_ORDER); - result.add(Keywords.PUBLIC_REGION_RU); - result.add(Keywords.PUBLIC_REGION_EN); - result.add(Keywords.INTERNAL_REGION_RU); - result.add(Keywords.INTERNAL_REGION_EN); + result.add(BSLKeywords.PUBLIC_REGION_RU); + result.add(BSLKeywords.PUBLIC_REGION_EN); + result.add(BSLKeywords.INTERNAL_REGION_RU); + result.add(BSLKeywords.INTERNAL_REGION_EN); return result; } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DuplicateRegionDiagnostic.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DuplicateRegionDiagnostic.java index 1be5e7670c7..d07543a011a 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DuplicateRegionDiagnostic.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/DuplicateRegionDiagnostic.java @@ -27,7 +27,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.Keywords; +import com.github._1c_syntax.bsl.languageserver.utils.BSLKeywords; import com.github._1c_syntax.bsl.languageserver.utils.RelatedInformation; import com.github._1c_syntax.bsl.parser.BSLParser; import org.antlr.v4.runtime.tree.ParseTree; @@ -53,26 +53,26 @@ public class DuplicateRegionDiagnostic extends AbstractVisitorDiagnostic { private final Map regionNames = new TreeMap<>(String.CASE_INSENSITIVE_ORDER); public DuplicateRegionDiagnostic() { - regionNames.put(Keywords.PUBLIC_REGION_RU, Keywords.PUBLIC_REGION_EN); - regionNames.put(Keywords.PUBLIC_REGION_EN, Keywords.PUBLIC_REGION_EN); - regionNames.put(Keywords.INTERNAL_REGION_RU, Keywords.INTERNAL_REGION_EN); - regionNames.put(Keywords.INTERNAL_REGION_EN, Keywords.INTERNAL_REGION_EN); - regionNames.put(Keywords.PRIVATE_REGION_RU, Keywords.PRIVATE_REGION_EN); - regionNames.put(Keywords.PRIVATE_REGION_EN, Keywords.PRIVATE_REGION_EN); - regionNames.put(Keywords.EVENT_HANDLERS_REGION_RU, Keywords.EVENT_HANDLERS_REGION_EN); - regionNames.put(Keywords.EVENT_HANDLERS_REGION_EN, Keywords.EVENT_HANDLERS_REGION_EN); - regionNames.put(Keywords.FORM_EVENT_HANDLERS_REGION_RU, Keywords.FORM_EVENT_HANDLERS_REGION_EN); - regionNames.put(Keywords.FORM_EVENT_HANDLERS_REGION_EN, Keywords.FORM_EVENT_HANDLERS_REGION_EN); - regionNames.put(Keywords.FORM_HEADER_ITEMS_EVENT_HANDLERS_REGION_RU, - Keywords.FORM_HEADER_ITEMS_EVENT_HANDLERS_REGION_EN); - regionNames.put(Keywords.FORM_HEADER_ITEMS_EVENT_HANDLERS_REGION_EN, - Keywords.FORM_HEADER_ITEMS_EVENT_HANDLERS_REGION_EN); - regionNames.put(Keywords.FORM_COMMANDS_EVENT_HANDLERS_REGION_RU, Keywords.FORM_COMMANDS_EVENT_HANDLERS_REGION_EN); - regionNames.put(Keywords.FORM_COMMANDS_EVENT_HANDLERS_REGION_EN, Keywords.FORM_COMMANDS_EVENT_HANDLERS_REGION_EN); - regionNames.put(Keywords.VARIABLES_REGION_RU, Keywords.VARIABLES_REGION_EN); - regionNames.put(Keywords.VARIABLES_REGION_EN, Keywords.VARIABLES_REGION_EN); - regionNames.put(Keywords.INITIALIZE_REGION_RU, Keywords.INITIALIZE_REGION_EN); - regionNames.put(Keywords.INITIALIZE_REGION_EN, Keywords.INITIALIZE_REGION_EN); + regionNames.put(BSLKeywords.PUBLIC_REGION_RU, BSLKeywords.PUBLIC_REGION_EN); + regionNames.put(BSLKeywords.PUBLIC_REGION_EN, BSLKeywords.PUBLIC_REGION_EN); + regionNames.put(BSLKeywords.INTERNAL_REGION_RU, BSLKeywords.INTERNAL_REGION_EN); + regionNames.put(BSLKeywords.INTERNAL_REGION_EN, BSLKeywords.INTERNAL_REGION_EN); + regionNames.put(BSLKeywords.PRIVATE_REGION_RU, BSLKeywords.PRIVATE_REGION_EN); + regionNames.put(BSLKeywords.PRIVATE_REGION_EN, BSLKeywords.PRIVATE_REGION_EN); + regionNames.put(BSLKeywords.EVENT_HANDLERS_REGION_RU, BSLKeywords.EVENT_HANDLERS_REGION_EN); + regionNames.put(BSLKeywords.EVENT_HANDLERS_REGION_EN, BSLKeywords.EVENT_HANDLERS_REGION_EN); + regionNames.put(BSLKeywords.FORM_EVENT_HANDLERS_REGION_RU, BSLKeywords.FORM_EVENT_HANDLERS_REGION_EN); + regionNames.put(BSLKeywords.FORM_EVENT_HANDLERS_REGION_EN, BSLKeywords.FORM_EVENT_HANDLERS_REGION_EN); + regionNames.put(BSLKeywords.FORM_HEADER_ITEMS_EVENT_HANDLERS_REGION_RU, + BSLKeywords.FORM_HEADER_ITEMS_EVENT_HANDLERS_REGION_EN); + regionNames.put(BSLKeywords.FORM_HEADER_ITEMS_EVENT_HANDLERS_REGION_EN, + BSLKeywords.FORM_HEADER_ITEMS_EVENT_HANDLERS_REGION_EN); + regionNames.put(BSLKeywords.FORM_COMMANDS_EVENT_HANDLERS_REGION_RU, BSLKeywords.FORM_COMMANDS_EVENT_HANDLERS_REGION_EN); + regionNames.put(BSLKeywords.FORM_COMMANDS_EVENT_HANDLERS_REGION_EN, BSLKeywords.FORM_COMMANDS_EVENT_HANDLERS_REGION_EN); + regionNames.put(BSLKeywords.VARIABLES_REGION_RU, BSLKeywords.VARIABLES_REGION_EN); + regionNames.put(BSLKeywords.VARIABLES_REGION_EN, BSLKeywords.VARIABLES_REGION_EN); + regionNames.put(BSLKeywords.INITIALIZE_REGION_RU, BSLKeywords.INITIALIZE_REGION_EN); + regionNames.put(BSLKeywords.INITIALIZE_REGION_EN, BSLKeywords.INITIALIZE_REGION_EN); } @Override diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Keywords.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/BSLKeywords.java similarity index 99% rename from src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Keywords.java rename to src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/BSLKeywords.java index 1abf83e2083..a0aaf9da74c 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Keywords.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/BSLKeywords.java @@ -21,7 +21,7 @@ */ package com.github._1c_syntax.bsl.languageserver.utils; -public final class Keywords { +public final class BSLKeywords { public static final String THEN_RU = "Тогда"; public static final String THEN_UP_RU = "ТОГДА"; public static final String THEN_EN = "Then"; @@ -274,7 +274,7 @@ public final class Keywords { "ОбработчикиСобытийЭлементовТаблицыФормы"; public static final String FORM_TABLE_ITEMS_EVENT_HANDLERS_REGION_START_EN = "FormTableItemsEventHandlers"; - private Keywords() { + private BSLKeywords() { // static utils } } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Regions.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Regions.java index 4c0ed33bbf0..add5a7ba0b1 100644 --- a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Regions.java +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/Regions.java @@ -39,38 +39,38 @@ public class Regions { private final Pattern PUBLIC_REGION_NAME = - createPattern(Keywords.PUBLIC_REGION_RU, Keywords.PUBLIC_REGION_EN); + createPattern(BSLKeywords.PUBLIC_REGION_RU, BSLKeywords.PUBLIC_REGION_EN); private final Pattern INTERNAL_REGION_NAME = - createPattern(Keywords.INTERNAL_REGION_RU, Keywords.INTERNAL_REGION_EN); + createPattern(BSLKeywords.INTERNAL_REGION_RU, BSLKeywords.INTERNAL_REGION_EN); private final Pattern PRIVATE_REGION_NAME = - createPattern(Keywords.PRIVATE_REGION_RU, Keywords.PRIVATE_REGION_EN); + createPattern(BSLKeywords.PRIVATE_REGION_RU, BSLKeywords.PRIVATE_REGION_EN); private final Pattern EVENT_HANDLERS_REGION_NAME = - createPattern(Keywords.EVENT_HANDLERS_REGION_RU, Keywords.EVENT_HANDLERS_REGION_EN); + createPattern(BSLKeywords.EVENT_HANDLERS_REGION_RU, BSLKeywords.EVENT_HANDLERS_REGION_EN); private final Pattern FORM_EVENT_HANDLERS_REGION_NAME = - createPattern(Keywords.FORM_EVENT_HANDLERS_REGION_RU, Keywords.FORM_EVENT_HANDLERS_REGION_EN); + createPattern(BSLKeywords.FORM_EVENT_HANDLERS_REGION_RU, BSLKeywords.FORM_EVENT_HANDLERS_REGION_EN); private final Pattern FORM_HEADER_ITEMS_EVENT_HANDLERS_REGION_NAME = - createPattern(Keywords.FORM_HEADER_ITEMS_EVENT_HANDLERS_REGION_RU, - Keywords.FORM_HEADER_ITEMS_EVENT_HANDLERS_REGION_EN); + createPattern(BSLKeywords.FORM_HEADER_ITEMS_EVENT_HANDLERS_REGION_RU, + BSLKeywords.FORM_HEADER_ITEMS_EVENT_HANDLERS_REGION_EN); private final Pattern FORM_TABLE_ITEMS_EVENT_HANDLERS_REGION_NAME = - createPattern(Keywords.FORM_TABLE_ITEMS_EVENT_HANDLERS_REGION_START_RU, - Keywords.FORM_TABLE_ITEMS_EVENT_HANDLERS_REGION_START_EN, + createPattern(BSLKeywords.FORM_TABLE_ITEMS_EVENT_HANDLERS_REGION_START_RU, + BSLKeywords.FORM_TABLE_ITEMS_EVENT_HANDLERS_REGION_START_EN, "^(?:%s|%s)[\\wа-яёЁ]*$"); private final Pattern FORM_COMMANDS_EVENT_HANDLERS_REGION_NAME = - createPattern(Keywords.FORM_COMMANDS_EVENT_HANDLERS_REGION_RU, Keywords.FORM_COMMANDS_EVENT_HANDLERS_REGION_EN); + createPattern(BSLKeywords.FORM_COMMANDS_EVENT_HANDLERS_REGION_RU, BSLKeywords.FORM_COMMANDS_EVENT_HANDLERS_REGION_EN); private final Pattern VARIABLES_REGION_NAME = - createPattern(Keywords.VARIABLES_REGION_RU, - Keywords.VARIABLES_REGION_EN); + createPattern(BSLKeywords.VARIABLES_REGION_RU, + BSLKeywords.VARIABLES_REGION_EN); private final Pattern INITIALIZE_REGION_NAME = - createPattern(Keywords.INITIALIZE_REGION_RU, Keywords.INITIALIZE_REGION_EN); + createPattern(BSLKeywords.INITIALIZE_REGION_RU, BSLKeywords.INITIALIZE_REGION_EN); /** * Метод возвращает паттерны регулярных выражений @@ -147,17 +147,17 @@ public static Set getOneScriptStandardRegions(ScriptVariant configuratio Set regionsName = new LinkedHashSet<>(); if (configurationLanguage == ScriptVariant.ENGLISH) { - regionsName.add(Keywords.VARIABLES_REGION_EN); - regionsName.add(Keywords.PUBLIC_REGION_EN); - regionsName.add(Keywords.INTERNAL_REGION_EN); - regionsName.add(Keywords.PRIVATE_REGION_EN); + regionsName.add(BSLKeywords.VARIABLES_REGION_EN); + regionsName.add(BSLKeywords.PUBLIC_REGION_EN); + regionsName.add(BSLKeywords.INTERNAL_REGION_EN); + regionsName.add(BSLKeywords.PRIVATE_REGION_EN); return regionsName; } - regionsName.add(Keywords.VARIABLES_REGION_RU); - regionsName.add(Keywords.PUBLIC_REGION_RU); - regionsName.add(Keywords.INTERNAL_REGION_RU); - regionsName.add(Keywords.PRIVATE_REGION_RU); + regionsName.add(BSLKeywords.VARIABLES_REGION_RU); + regionsName.add(BSLKeywords.PUBLIC_REGION_RU); + regionsName.add(BSLKeywords.INTERNAL_REGION_RU); + regionsName.add(BSLKeywords.PRIVATE_REGION_RU); return regionsName; } @@ -211,7 +211,7 @@ private static Set getStandardRegionNames(ModuleType moduleType, ScriptV } // у всех типов модулей есть такая область - regionsName.add(language == ScriptVariant.ENGLISH ? Keywords.PRIVATE_REGION_EN : Keywords.PRIVATE_REGION_RU); + regionsName.add(language == ScriptVariant.ENGLISH ? BSLKeywords.PRIVATE_REGION_EN : BSLKeywords.PRIVATE_REGION_RU); return regionsName; } @@ -219,107 +219,107 @@ private static Set getStandardRegionNames(ModuleType moduleType, ScriptV private static void addManagerModuleRegionsNames(Set regionsName, ScriptVariant language) { if (language == ScriptVariant.ENGLISH) { - regionsName.add(Keywords.PUBLIC_REGION_EN); - regionsName.add(Keywords.EVENT_HANDLERS_REGION_EN); - regionsName.add(Keywords.INTERNAL_REGION_EN); + regionsName.add(BSLKeywords.PUBLIC_REGION_EN); + regionsName.add(BSLKeywords.EVENT_HANDLERS_REGION_EN); + regionsName.add(BSLKeywords.INTERNAL_REGION_EN); return; } - regionsName.add(Keywords.PUBLIC_REGION_RU); - regionsName.add(Keywords.EVENT_HANDLERS_REGION_RU); - regionsName.add(Keywords.INTERNAL_REGION_RU); + regionsName.add(BSLKeywords.PUBLIC_REGION_RU); + regionsName.add(BSLKeywords.EVENT_HANDLERS_REGION_RU); + regionsName.add(BSLKeywords.INTERNAL_REGION_RU); } private static void addExternalConnectionRegionsNames(Set regionsName, ScriptVariant language) { if (language == ScriptVariant.ENGLISH) { - regionsName.add(Keywords.PUBLIC_REGION_EN); - regionsName.add(Keywords.EVENT_HANDLERS_REGION_EN); + regionsName.add(BSLKeywords.PUBLIC_REGION_EN); + regionsName.add(BSLKeywords.EVENT_HANDLERS_REGION_EN); return; } - regionsName.add(Keywords.PUBLIC_REGION_RU); - regionsName.add(Keywords.EVENT_HANDLERS_REGION_RU); + regionsName.add(BSLKeywords.PUBLIC_REGION_RU); + regionsName.add(BSLKeywords.EVENT_HANDLERS_REGION_RU); } private static void addCommandAndSessionModulesRegionsNames(Set regionsName, ScriptVariant language) { - regionsName.add(language == ScriptVariant.ENGLISH ? Keywords.EVENT_HANDLERS_REGION_EN - : Keywords.EVENT_HANDLERS_REGION_RU); + regionsName.add(language == ScriptVariant.ENGLISH ? BSLKeywords.EVENT_HANDLERS_REGION_EN + : BSLKeywords.EVENT_HANDLERS_REGION_RU); } private static void addApplicationModulesRegionsNames(Set regionsName, ScriptVariant language) { if (language == ScriptVariant.ENGLISH) { - regionsName.add(Keywords.VARIABLES_REGION_EN); - regionsName.add(Keywords.PUBLIC_REGION_EN); - regionsName.add(Keywords.EVENT_HANDLERS_REGION_EN); + regionsName.add(BSLKeywords.VARIABLES_REGION_EN); + regionsName.add(BSLKeywords.PUBLIC_REGION_EN); + regionsName.add(BSLKeywords.EVENT_HANDLERS_REGION_EN); return; } - regionsName.add(Keywords.VARIABLES_REGION_RU); - regionsName.add(Keywords.PUBLIC_REGION_RU); - regionsName.add(Keywords.EVENT_HANDLERS_REGION_RU); + regionsName.add(BSLKeywords.VARIABLES_REGION_RU); + regionsName.add(BSLKeywords.PUBLIC_REGION_RU); + regionsName.add(BSLKeywords.EVENT_HANDLERS_REGION_RU); } private static void addCommonModuleRegionNames(Set regionsName, ScriptVariant language) { if (language == ScriptVariant.ENGLISH) { - regionsName.add(Keywords.PUBLIC_REGION_EN); - regionsName.add(Keywords.INTERNAL_REGION_EN); + regionsName.add(BSLKeywords.PUBLIC_REGION_EN); + regionsName.add(BSLKeywords.INTERNAL_REGION_EN); return; } - regionsName.add(Keywords.PUBLIC_REGION_RU); - regionsName.add(Keywords.INTERNAL_REGION_RU); + regionsName.add(BSLKeywords.PUBLIC_REGION_RU); + regionsName.add(BSLKeywords.INTERNAL_REGION_RU); } private static void addValueManageRegionsName(Set regionsName, ScriptVariant language) { if (language == ScriptVariant.ENGLISH) { - regionsName.add(Keywords.VARIABLES_REGION_EN); - regionsName.add(Keywords.PUBLIC_REGION_EN); - regionsName.add(Keywords.EVENT_HANDLERS_REGION_EN); - regionsName.add(Keywords.INTERNAL_REGION_EN); + regionsName.add(BSLKeywords.VARIABLES_REGION_EN); + regionsName.add(BSLKeywords.PUBLIC_REGION_EN); + regionsName.add(BSLKeywords.EVENT_HANDLERS_REGION_EN); + regionsName.add(BSLKeywords.INTERNAL_REGION_EN); return; } - regionsName.add(Keywords.VARIABLES_REGION_RU); - regionsName.add(Keywords.PUBLIC_REGION_RU); - regionsName.add(Keywords.EVENT_HANDLERS_REGION_RU); - regionsName.add(Keywords.INTERNAL_REGION_RU); + regionsName.add(BSLKeywords.VARIABLES_REGION_RU); + regionsName.add(BSLKeywords.PUBLIC_REGION_RU); + regionsName.add(BSLKeywords.EVENT_HANDLERS_REGION_RU); + regionsName.add(BSLKeywords.INTERNAL_REGION_RU); } private static void addObjectAndRecordSetRegionsName(Set regionsName, ScriptVariant language) { if (language == ScriptVariant.ENGLISH) { - regionsName.add(Keywords.VARIABLES_REGION_EN); - regionsName.add(Keywords.PUBLIC_REGION_EN); - regionsName.add(Keywords.EVENT_HANDLERS_REGION_EN); - regionsName.add(Keywords.INTERNAL_REGION_EN); - regionsName.add(Keywords.INITIALIZE_REGION_EN); + regionsName.add(BSLKeywords.VARIABLES_REGION_EN); + regionsName.add(BSLKeywords.PUBLIC_REGION_EN); + regionsName.add(BSLKeywords.EVENT_HANDLERS_REGION_EN); + regionsName.add(BSLKeywords.INTERNAL_REGION_EN); + regionsName.add(BSLKeywords.INITIALIZE_REGION_EN); return; } - regionsName.add(Keywords.VARIABLES_REGION_RU); - regionsName.add(Keywords.PUBLIC_REGION_RU); - regionsName.add(Keywords.EVENT_HANDLERS_REGION_RU); - regionsName.add(Keywords.INTERNAL_REGION_RU); - regionsName.add(Keywords.INITIALIZE_REGION_RU); + regionsName.add(BSLKeywords.VARIABLES_REGION_RU); + regionsName.add(BSLKeywords.PUBLIC_REGION_RU); + regionsName.add(BSLKeywords.EVENT_HANDLERS_REGION_RU); + regionsName.add(BSLKeywords.INTERNAL_REGION_RU); + regionsName.add(BSLKeywords.INITIALIZE_REGION_RU); } private static void addFormModuleRegionsNames(Set regionsName, ScriptVariant language) { if (language == ScriptVariant.ENGLISH) { - regionsName.add(Keywords.VARIABLES_REGION_EN); - regionsName.add(Keywords.FORM_EVENT_HANDLERS_REGION_EN); - regionsName.add(Keywords.FORM_HEADER_ITEMS_EVENT_HANDLERS_REGION_EN); - regionsName.add(Keywords.FORM_TABLE_ITEMS_EVENT_HANDLERS_REGION_START_EN); - regionsName.add(Keywords.FORM_COMMANDS_EVENT_HANDLERS_REGION_EN); - regionsName.add(Keywords.INITIALIZE_REGION_EN); + regionsName.add(BSLKeywords.VARIABLES_REGION_EN); + regionsName.add(BSLKeywords.FORM_EVENT_HANDLERS_REGION_EN); + regionsName.add(BSLKeywords.FORM_HEADER_ITEMS_EVENT_HANDLERS_REGION_EN); + regionsName.add(BSLKeywords.FORM_TABLE_ITEMS_EVENT_HANDLERS_REGION_START_EN); + regionsName.add(BSLKeywords.FORM_COMMANDS_EVENT_HANDLERS_REGION_EN); + regionsName.add(BSLKeywords.INITIALIZE_REGION_EN); return; } - regionsName.add(Keywords.VARIABLES_REGION_RU); - regionsName.add(Keywords.FORM_EVENT_HANDLERS_REGION_RU); - regionsName.add(Keywords.FORM_HEADER_ITEMS_EVENT_HANDLERS_REGION_RU); - regionsName.add(Keywords.FORM_TABLE_ITEMS_EVENT_HANDLERS_REGION_START_RU); - regionsName.add(Keywords.FORM_COMMANDS_EVENT_HANDLERS_REGION_RU); - regionsName.add(Keywords.INITIALIZE_REGION_RU); + regionsName.add(BSLKeywords.VARIABLES_REGION_RU); + regionsName.add(BSLKeywords.FORM_EVENT_HANDLERS_REGION_RU); + regionsName.add(BSLKeywords.FORM_HEADER_ITEMS_EVENT_HANDLERS_REGION_RU); + regionsName.add(BSLKeywords.FORM_TABLE_ITEMS_EVENT_HANDLERS_REGION_START_RU); + regionsName.add(BSLKeywords.FORM_COMMANDS_EVENT_HANDLERS_REGION_RU); + regionsName.add(BSLKeywords.INITIALIZE_REGION_RU); } diff --git a/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/SDBLKeywords.java b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/SDBLKeywords.java new file mode 100644 index 00000000000..43688b687db --- /dev/null +++ b/src/main/java/com/github/_1c_syntax/bsl/languageserver/utils/SDBLKeywords.java @@ -0,0 +1,301 @@ +/* + * This file is a part of BSL Language Server. + * + * Copyright (c) 2018-2021 + * Alexey Sosnoviy , Nikita Gryzlov and contributors + * + * SPDX-License-Identifier: LGPL-3.0-or-later + * + * BSL Language Server is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * BSL Language Server is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with BSL Language Server. + */ +package com.github._1c_syntax.bsl.languageserver.utils; + +import lombok.experimental.UtilityClass; + +@UtilityClass +public class SDBLKeywords { + + + public static final String AUTOORDER_RU = "АВТОУПОРЯДОЧИВАНИЕ"; + public static final String AUTOORDER_EN = "AUTOORDER"; + + public static final String NULL_RU = "NULL"; + public static final String NULL_EN = "NULL"; + + public static final String BOOLEAN_RU = "БУЛЕВО"; + public static final String BOOLEAN_EN = "BOOLEAN"; + + public static final String IN_RU = "В"; + public static final String IN_EN = "IN"; + + public static final String OUTER_RU = "ВНЕШНЕЕ"; + public static final String OUTER_EN = "OUTER"; + + public static final String INNER_RU = "ВНУТРЕННЕЕ"; + public static final String INNER_EN = "INNER"; + + public static final String ASC_RU = "ВОЗР"; + public static final String ASC_EN = "ASC"; + + public static final String ALL_RU = "ВСЕ"; + public static final String ALL_EN = "ALL"; + + public static final String CASE_RU = "ВЫБОР"; + public static final String CASE_EN = "CASE"; + + public static final String SELECT_RU = "ВЫБРАТЬ"; + public static final String SELECT_EN = "SELECT"; + + public static final String CAST_RU = "ВЫРАЗИТЬ"; + public static final String CAST_EN = "CAST"; + + public static final String WHERE_RU = "ГДЕ"; + public static final String WHERE_EN = "WHERE"; + + public static final String YEAR_RU = "ГОД"; + public static final String YEAR_EN = "YEAR"; + + public static final String DATE_RU = "ДАТА"; + public static final String DATE_EN = "DATE"; + + public static final String DATETIME_RU = "ДАТАВРЕМЯ"; + public static final String DATETIME_EN = "DATETIME"; + + public static final String TENDAYS_RU = "ДЕКАДА"; + public static final String TENDAYS_EN = "TENDAYS"; + + public static final String DAY_RU = "ДЕНЬ"; + public static final String DAY_EN = "DAY"; + + public static final String WEEKDAY_RU = "ДЕНЬНЕДЕЛИ"; + public static final String WEEKDAY_EN = "WEEKDAY"; + + public static final String DATEADD_RU = "ДОБАВИТЬКДАТЕ"; + public static final String DATEADD_EN = "DATEADD"; + + public static final String IS_RU = "ЕСТЬ"; + public static final String IS_EN = "IS"; + + public static final String VALUE_RU = "ЗНАЧЕНИЕ"; + public static final String VALUE_EN = "VALUE"; + + public static final String AND_RU = "И"; + public static final String AND_EN = "AND"; + + public static final String IN_HIERARCHY_RU = "ИЕРАРХИИ"; + public static final String HIERARCHY_RU = "ИЕРАРХИЯ"; + public static final String HIERARCHY_EN = "HIERARCHY"; + + public static final String FROM_RU = "ИЗ"; + public static final String FROM_EN = "FROM"; + + public static final String OR_RU = "ИЛИ"; + public static final String OR_EN = "OR"; + + public static final String HAVING_RU = "ИМЕЮЩИЕ"; + public static final String HAVING_EN = "HAVING"; + + public static final String ELSE_RU = "ИНАЧЕ"; + public static final String ELSE_EN = "ELSE"; + + public static final String TRUE_RU = "ИСТИНА"; + public static final String TRUE_EN = "TRUE"; + + public static final String AS_RU = "КАК"; + public static final String AS_EN = "AS"; + + public static final String QUARTER_RU = "КВАРТАЛ"; + public static final String QUARTER_EN = "QUARTER"; + + public static final String WHEN_RU = "КОГДА"; + public static final String WHEN_EN = "WHEN"; + + public static final String COUNT_RU = "КОЛИЧЕСТВО"; + public static final String COUNT_EN = "COUNT"; + + public static final String ENDOFPERIOD_RU = "КОНЕЦПЕРИОДА"; + public static final String ENDOFPERIOD_EN = "ENDOFPERIOD"; + + public static final String END_RU = "КОНЕЦ"; + public static final String END_EN = "END"; + + public static final String LEFT_RU = "ЛЕВОЕ"; + public static final String LEFT_EN = "LEFT"; + + public static final String FALSE_RU = "ЛОЖЬ"; + public static final String FALSE_EN = "FALSE"; + + public static final String MAX_RU = "МАКСИМУМ"; + public static final String MAX_EN = "MAX"; + + public static final String BETWEEN_RU = "МЕЖДУ"; + public static final String BETWEEN_EN = "BETWEEN"; + + public static final String MONTH_RU = "МЕСЯЦ"; + public static final String MONTH_EN = "MONTH"; + + public static final String MIN_RU = "МИНИМУМ"; + public static final String MIN_EN = "MIN"; + + public static final String MINUTE_RU = "МИНУТА"; + public static final String MINUTE_EN = "MINUTE"; + + public static final String BEGINOFPERIOD_RU = "НАЧАЛОПЕРИОДА"; + public static final String BEGINOFPERIOD_EN = "BEGINOFPERIOD"; + + public static final String NOT_RU = "НЕ"; + public static final String NOT_EN = "NOT"; + + public static final String WEEK_RU = "НЕДЕЛЯ"; + public static final String WEEK_EN = "WEEK"; + + public static final String DAYOFYEAR_RU = "ДЕНЬГОДА"; + public static final String DAYOFYEAR_EN = "DAYOFYEAR"; + + public static final String FOR_RU = "ДЛЯ"; + public static final String FOR_EN = "EN"; + + public static final String UPDATE_RU = "ИЗМЕНЕНИЯ"; + public static final String UPDATE_EN = "UPDATE"; + + public static final String OF_EN = "OF"; + + public static final String ISNULL_RU = "ЕСТЬNULL"; + public static final String ISNULL_EN = "ISNULL"; + + public static final String TOTALS_RU = "ИТОГИ"; + public static final String TOTALS_EN = "TOTALS"; + + public static final String INDEX_RU = "ИНДЕКСИРОВАТЬ"; + public static final String INDEX_EN = "INDEX"; + + public static final String UNDEFINED_RU = "НЕОПРЕДЕЛЕНО"; + public static final String UNDEFINED_EN = "UNDEFINED"; + + public static final String OVERALL_RU = "ОБЩИЕ"; + public static final String OVERALL_EN = "OVERALL"; + + public static final String UNION_RU = "ОБЪЕДИНИТЬ"; + public static final String UNION_EN = "UNION"; + + public static final String TOP_RU = "ПЕРВЫЕ"; + public static final String TOP_EN = "TOP"; + + public static final String PERIODS_RU = "ПЕРИОДАМИ"; + public static final String PERIODS_EN = "PERIODS"; + + public static final String LIKE_RU = "ПОДОБНО"; + public static final String LIKE_EN = "LIKE"; + + public static final String FULL_RU = "ПОЛНОЕ"; + public static final String FULL_EN = "FULL"; + + public static final String HALFYEAR_RU = "ПОЛУГОДИЕ"; + public static final String HALFYEAR_EN = "HALFYEAR"; + + public static final String RECORDAUTONUMBER_RU = "АВТОНОМЕРЗАПИСИ"; + public static final String RECORDAUTONUMBER_EN = "RECORDAUTONUMBER"; + + public static final String INTO_RU = "ПОМЕСТИТЬ"; + public static final String INTO_EN = "INTO"; + + public static final String RIGHT_RU = "ПРАВОЕ"; + public static final String RIGHT_EN = "RIGHT"; + + public static final String PRESENTATION_RU = "ПРЕДСТАВЛЕНИЕ"; + public static final String PRESENTATION_EN = "PRESENTATION"; + + public static final String EMPTYTABLE_RU = "ПУСТАЯТАБЛИЦА"; + public static final String EMPTYTABLE_EN = "EMPTYTABLE"; + + public static final String REFPRESENTATION_RU = "ПРЕДСТАВЛЕНИЕССЫЛКИ"; + public static final String REFPRESENTATION_EN = "REFPRESENTATION"; + + public static final String DISTINCT_RU = "РАЗЛИЧНЫЕ"; + public static final String DISTINCT_EN = "DISTINCT"; + + public static final String DATEDIFF_RU = "РАЗНОСТЬДАТ"; + public static final String DATEDIFF_EN = "DATEDIFF"; + + public static final String ALLOWED_RU = "РАЗРЕШЕННЫЕ"; + public static final String ALLOWED_EN = "ALLOWED"; + + public static final String GROUP_RU = "СГРУППИРОВАТЬ"; + public static final String GROUP_EN = "GROUP"; + + public static final String GROUPEDBY_RU = "СГРУППИРОВАНОПО"; + public static final String GROUPEDBY_EN = "GROUPEDBY"; + + public static final String SECOND_RU = "СЕКУНДА"; + public static final String SECOND_EN = "SECOND"; + + public static final String ON_RU = "ПО"; + public static final String ON_EN = "ON"; + + public static final String JOIN_RU = "СОЕДИНЕНИЕ"; + public static final String JOIN_EN = "JOIN"; + + public static final String ESCAPE_RU = "СПЕЦСИМВОЛ"; + public static final String ESCAPE_EN = "ESCAPE"; + + public static final String SUBSTRING_RU = "ПОДСТРОКА"; + public static final String SUBSTRING_EN = "SUBSTRING"; + + public static final String AVG_RU = "СРЕДНЕЕ"; + public static final String AVG_EN = "AVG"; + + public static final String REFS_RU = "ССЫЛКА"; + public static final String REFS_EN = "REFS"; + + public static final String STRING_RU = "СТРОКА"; + public static final String STRING_EN = "STRING"; + + public static final String SUM_RU = "СУММА"; + public static final String SUM_EN = "SUM"; + + public static final String TYPE_RU = "ТИП"; + public static final String TYPE_EN = "TYPE"; + + public static final String VALUETYPE_RU = "ТИПЗНАЧЕНИЯ"; + public static final String VALUETYPE_EN = "VALUETYPE"; + + public static final String THEN_RU = "ТОГДА"; + public static final String THEN_EN = "THEN"; + + public static final String ONLY_RU = "ТОЛЬКО"; + public static final String ONLY_EN = "ONLY"; + + public static final String DESC_RU = "УБЫВ"; + public static final String DESC_EN = "DESC"; + + public static final String ORDER_RU = "УПОРЯДОЧИТЬ"; + public static final String ORDER_EN = "ORDER"; + + public static final String HOUR_RU = "ЧАС"; + public static final String HOUR_EN = "HOUR"; + + public static final String NUMBER_RU = "ЧИСЛО"; + public static final String NUMBER_EN = "NUMBER"; + + public static final String DROP_RU = "УНИЧТОЖИТЬ"; + public static final String DROP_EN = "DROP"; + + public static final String GROUPING_RU = "ГРУППИРУЮЩИМ"; + public static final String GROUPING_EN = "GROUPING"; + + public static final String SET_RU = "НАБОРАМ"; + public static final String SET_EN = "SETS"; + + +} diff --git a/src/main/resources/com/github/_1c_syntax/bsl/languageserver/configuration/parameters-schema.json b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/configuration/parameters-schema.json index 2935ffe44cf..69c2aac6396 100644 --- a/src/main/resources/com/github/_1c_syntax/bsl/languageserver/configuration/parameters-schema.json +++ b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/configuration/parameters-schema.json @@ -86,6 +86,16 @@ "title": "Canonical keyword writing", "$id": "#/definitions/CanonicalSpellingKeywords" }, + "CanonicalSpellingKeywordsInQuery": { + "description": "Checking the canonical spelling of keywords in a query", + "default": true, + "type": [ + "boolean", + "object" + ], + "title": "Checking the canonical spelling of keywords in a query", + "$id": "#/definitions/CanonicalSpellingKeywordsInQuery" + }, "CodeAfterAsyncCall": { "description": "Lines of code after the asynchronous method call", "default": false, diff --git a/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/CanonicalSpellingKeywordsInQueryDiagnostic_en.properties b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/CanonicalSpellingKeywordsInQueryDiagnostic_en.properties new file mode 100644 index 00000000000..4fd3816c84c --- /dev/null +++ b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/CanonicalSpellingKeywordsInQueryDiagnostic_en.properties @@ -0,0 +1,3 @@ +diagnosticMessage=Keyword "%s" is written non-canonically +diagnosticName=Checking the canonical spelling of keywords in a query +quickFixMessage=Change keyword to canonical spelling diff --git a/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/CanonicalSpellingKeywordsInQueryDiagnostic_ru.properties b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/CanonicalSpellingKeywordsInQueryDiagnostic_ru.properties new file mode 100644 index 00000000000..fc3b9f933b3 --- /dev/null +++ b/src/main/resources/com/github/_1c_syntax/bsl/languageserver/diagnostics/CanonicalSpellingKeywordsInQueryDiagnostic_ru.properties @@ -0,0 +1,3 @@ +diagnosticMessage=Ключевое слово "%s" написано не канонически +diagnosticName=Проверка канонического написания ключевых слов в запросе +quickFixMessage=Привести ключевое слово к каноническому написанию diff --git a/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CanonicalSpellingKeywordsInQueryDiagnosticTest.java b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CanonicalSpellingKeywordsInQueryDiagnosticTest.java new file mode 100644 index 00000000000..02f179a935d --- /dev/null +++ b/src/test/java/com/github/_1c_syntax/bsl/languageserver/diagnostics/CanonicalSpellingKeywordsInQueryDiagnosticTest.java @@ -0,0 +1,118 @@ +/* + * This file is a part of BSL Language Server. + * + * Copyright (c) 2018-2021 + * Alexey Sosnoviy , Nikita Gryzlov and contributors + * + * SPDX-License-Identifier: LGPL-3.0-or-later + * + * BSL Language Server is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3.0 of the License, or (at your option) any later version. + * + * BSL Language Server is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with BSL Language Server. + */ +package com.github._1c_syntax.bsl.languageserver.diagnostics; + +import org.eclipse.lsp4j.CodeAction; +import org.eclipse.lsp4j.Diagnostic; +import org.junit.jupiter.api.Test; + +import java.util.List; + +import static com.github._1c_syntax.bsl.languageserver.util.Assertions.assertThat; + +class CanonicalSpellingKeywordsInQueryDiagnosticTest extends AbstractDiagnosticTest { + CanonicalSpellingKeywordsInQueryDiagnosticTest() { + super(CanonicalSpellingKeywordsInQueryDiagnostic.class); + } + + @Test + void test() { + + List diagnostics = getDiagnostics(); + + assertThat(diagnostics).hasSize(50); + assertThat(diagnostics, true) + .hasRange(6, 38, 6, 45) // выбрать + .hasRange(6, 46, 6, 57) // РаЗРЕШЕННЫЕ + .hasRange(6, 58, 6, 67) // рАЗЛИЧНЫЕ + .hasRange(6, 68, 6, 74) // пЕРВЫЕ + .hasRange(9, 39, 9, 44) // сумма + .hasRange(9, 59, 9, 62) // как + .hasRange(13, 39, 13, 49) // КОЛИЧЕсТВО + .hasRange(17, 38, 17, 40) // из + .hasRange(19, 40, 19, 45) // левое + .hasRange(19, 46, 19, 56) // СОЕДИНЕНИе + .hasRange(20, 41, 20, 47) // ПрАВОЕ + .hasRange(21, 41, 21, 43) // По + .hasRange(24, 38, 24, 41) // Где + .hasRange(26, 39, 26, 40) // и + .hasRange(27, 60, 27, 61) // в + .hasRange(28, 62, 28, 70) // ИЕРАРХИи + .hasRange(30, 38, 30, 51) // СГРУППИрОВАТЬ + .hasRange(30, 52, 30, 54) // пО + .hasRange(30, 55, 30, 67) // гРУППИРУЮЩИМ + .hasRange(30, 68, 30, 75) // нАБОРАМ + .hasRange(44, 38, 44, 48) // ОБЪЕДиНИТЬ + .hasRange(44, 49, 44, 52) // ВСе + .hasRange(47, 39, 47, 43) // null + .hasRange(60, 38, 60, 49) // уПОРЯДОЧИТЬ + .hasRange(60, 50, 60, 52) // пО + .hasRange(61, 48, 61, 52) // вОЗР + .hasRange(62, 52, 62, 56) // уБЫВ + .hasRange(63, 38, 63, 43) // иТОГИ + .hasRange(65, 38, 65, 40) // пО + .hasRange(66, 39, 66, 44) // оБЩИЕ + .hasRange(76, 40, 76, 47) // выбрать + .hasRange(76, 48, 76, 59) // РаЗРЕШЕННЫЕ + .hasRange(79, 47, 79, 52) // сумма + .hasRange(87, 46, 87, 48) // из + .hasRange(94, 46, 94, 49) // Где + .hasRange(97, 68, 97, 69) // в + .hasRange(98, 70, 98, 78) // ИЕРАРХИи + .hasRange(100, 76, 100, 83) // нАБОРАМ + .hasRange(100, 46, 100, 59) // СГРУППИрОВАТЬ + .hasRange(100, 60, 100, 62) // пО + .hasRange(100, 63, 100, 75) // гРУППИРУЮЩИМ + .hasRange(117, 47, 117, 51) // null + .hasRange(130, 46, 130, 57) // уПОРЯДОЧИТЬ + .hasRange(130, 58, 130, 60) // пО + .hasRange(131, 56, 131, 60) // вОЗР + .hasRange(132, 60, 132, 64) // уБЫВ + .hasRange(133, 46, 133, 51) // иТОГИ + .hasRange(135, 46, 135, 48) // пО + .hasRange(136, 47, 136, 52) // оБЩИЕ + .hasRange(146, 76, 146, 82); // первые + + } + + @Test + void testQuickFix() { + + final var documentContext = getDocumentContext(); + List diagnostics = getDiagnostics(); + final Diagnostic firstDiagnostic = diagnostics.get(0); + + List quickFixes = getQuickFixes(firstDiagnostic); + + assertThat(quickFixes).hasSize(1); + + final CodeAction quickFix = quickFixes.get(0); + + assertThat(quickFix).of(diagnosticInstance).in(documentContext) + .fixes(firstDiagnostic); + + assertThat(quickFix).in(documentContext) + .hasChanges(1); + + } + +} diff --git a/src/test/resources/diagnostics/CanonicalSpellingKeywordsInQueryDiagnostic.bsl b/src/test/resources/diagnostics/CanonicalSpellingKeywordsInQueryDiagnostic.bsl new file mode 100644 index 00000000000..a65654e6557 --- /dev/null +++ b/src/test/resources/diagnostics/CanonicalSpellingKeywordsInQueryDiagnostic.bsl @@ -0,0 +1,161 @@ +Процедура ОбработкаЗаполнения(ДанныеЗаполнения, СтандартнаяОбработка) + + // FP на этой строке Литерал = "Выбрать первые 10 полей и засеять пшеницей"; + + Если ТипЗнч(ДанныеЗаполнения) = Тип("СправочникСсылка.Контрагенты") Тогда + + ЗапросПоКонтрагенту = Новый Запрос("выбрать РаЗРЕШЕННЫЕ рАЗЛИЧНЫЕ пЕРВЫЕ 10 //4 ошибки + | Контрагенты.ЭтоГруппа КАК НеГруппа, + | Оплата.Ссылка, + | сумма(Оплата.Сумма) как СуммаК, // 2 ошибки + | Оплата.Организация КАК ОрганизацияД, + | Оплата.Представление, + | ПриходТовара.Организация КАК Организация1, + | КОЛИЧЕсТВО(РасходТовара.ВерсияДанных) КАК ВерсияДанных, // 1 ошибка + | РасходТовара.Проведен КАК Проведен, + | РасходТовара.Склад, + | NULL КАК Поле1 + |из // 1 ошибка + | Документ.ПриходТовара КАК ПриходТовара + | левое СОЕДИНЕНИе Справочник.Контрагенты КАК Контрагенты // 2 ошибки + | ПрАВОЕ СОЕДИНЕНИЕ Документ.РасходТовара КАК РасходТовара // 1 ошибки + | По РасходТовара.Организация = Контрагенты.Ссылка + | ПО ПриходТовара.Поставщик = Контрагенты.Ссылка, + | Документ.Оплата КАК Оплата + |Где // 1 ошибка + | Контрагенты.Ссылка = &КонтрагентСсылка + | и Контрагенты.Дом = &Дом + | И Контрагенты.ВидЦен в(&ВидЦен) // 1 ошибка + | И Контрагенты.Регион В ИЕРАРХИи(&Регион) // 1 ошибка + | + |СГРУППИрОВАТЬ пО гРУППИРУЮЩИМ нАБОРАМ // 4 ошибки + |( + |( ПриходТовара.Организация, + | Оплата.Организация, + | Контрагенты.ЭтоГруппа, + | РасходТовара.Проведен, + | РасходТовара.Склад), + |( Оплата.Организация, + | Оплата.Представление, + | Оплата.Ссылка) + | + |) + | + | + |ОБЪЕДиНИТЬ ВСе // 2 ошибки + | + |ВЫБРАТЬ + | null, // 1 ошибка + | Заказ.Ссылка, + | NULL, + | NULL, + | NULL, + | NULL, + | NULL, + | NULL, + | NULL, + | NULL + |ИЗ + | Документ.Заказ КАК Заказ + | + |уПОРЯДОЧИТЬ пО // 2 ошибки + | НеГруппа вОЗР, // 1 ошибка + | ВерсияДанных уБЫВ // 1 ошибка + |иТОГИ // 1 ошибка + | СУММА(СуммаК) + |пО // 1 ошибка + | оБЩИЕ, // 1 ошибка + | Проведен"); + ЗапросПоКонтрагенту.УстановитьПараметр("КонтрагентСсылка", ДанныеЗаполнения); + Выборка = ЗапросПоКонтрагенту.Выполнить().Выбрать(); + Если Выборка.Следующий() И Выборка.ЭтоГруппа Тогда + Возврат; + КонецЕсли; + + Поставщик = ДанныеЗаполнения.Ссылка; + ИначеЕсли Ложь // точно такой же запрос + ЗапросПоКонтрагенту = Новый Запрос("выбрать РаЗРЕШЕННЫЕ РАЗЛИЧНЫЕ ПЕРВЫЕ 10 + | Контрагенты.ЭтоГруппа КАК НеГруппа, + | Оплата.Ссылка, + | сумма(Оплата.Сумма) КАК СуммаК, + | Оплата.Организация КАК ОрганизацияД, + | Оплата.Представление, + | ПриходТовара.Организация КАК Организация1, + | КОЛИЧЕСТВО(РасходТовара.ВерсияДанных) КАК ВерсияДанных, + | РасходТовара.Проведен КАК Проведен, + | РасходТовара.Склад, + | NULL КАК Поле1 + |из + | Документ.ПриходТовара КАК ПриходТовара + | ЛЕВОЕ СОЕДИНЕНИЕ Справочник.Контрагенты КАК Контрагенты + | ПРАВОЕ СОЕДИНЕНИЕ Документ.РасходТовара КАК РасходТовара + | ПО РасходТовара.Организация = Контрагенты.Ссылка + | ПО ПриходТовара.Поставщик = Контрагенты.Ссылка, + | Документ.Оплата КАК Оплата + |Где + | Контрагенты.Ссылка = &КонтрагентСсылка + | И Контрагенты.Дом = &Дом + | И Контрагенты.ВидЦен в(&ВидЦен) + | И Контрагенты.Регион В ИЕРАРХИи(&Регион) + | + |СГРУППИрОВАТЬ пО гРУППИРУЮЩИМ нАБОРАМ + |( + |( ПриходТовара.Организация, + | Оплата.Организация, + | Контрагенты.ЭтоГруппа, + | РасходТовара.Проведен, + | РасходТовара.Склад), + |( Оплата.Организация, + | Оплата.Представление, + | Оплата.Ссылка) + | + |) + | + | + |ОБЪЕДИНИТЬ ВСЕ + | + |ВЫБРАТЬ + | null, + | Заказ.Ссылка, + | NULL, + | NULL, + | NULL, + | NULL, + | NULL, + | NULL, + | NULL, + | NULL + |ИЗ + | Документ.Заказ КАК Заказ + | + |уПОРЯДОЧИТЬ пО + | НеГруппа вОЗР, + | ВерсияДанных уБЫВ + |иТОГИ + | СУММА(СуммаК) + |пО + | оБЩИЕ, + | Проведен"); + ЗапросПоКонтрагенту.УстановитьПараметр("КонтрагентСсылка", ДанныеЗаполнения); + Выборка = ЗапросПоКонтрагенту.Выполнить().Выбрать(); + Если Выборка.Следующий() И Выборка.ЭтоГруппа Тогда + Возврат; + КонецЕсли; + + Поставщик = ДанныеЗаполнения.Ссылка; + Иначе + ЗапросПоКонтрагенту = Новый Запрос("ВЫБРАТЬ РАЗРЕШЕННЫЕ РАЗЛИЧНЫЕ первые 10 + | Контрагенты.ЭтоГруппа КАК НеГруппа, + | Оплата.Ссылка, + | СУММА(Оплата.Сумма) КАК СуммаК, + | Оплата.Организация КАК ОрганизацияД, + | Оплата.Представление, + | ПриходТовара.Организация КАК Организация1, + | КОЛИЧЕСТВО(РасходТовара.ВерсияДанных) КАК ВерсияДанных, + | РасходТовара.Проведен КАК Проведен, + | РасходТовара.Склад, + | NULL КАК Поле1"); + + КонецЕсли; + +КонецПроцедуры