From 3b5138fa373945ffd15c0c8dcb3ef323699929b0 Mon Sep 17 00:00:00 2001 From: "a.sosnoviy" Date: Wed, 7 Oct 2020 12:29:27 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A2=D0=B5=D1=81=D1=82=D1=8B=20=D0=BD=D0=B0?= =?UTF-8?q?=20crazy=20=D1=81=D1=82=D1=80=D0=B8=D0=BD=D0=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bsl/sonar/BSLHighlighterTest.java | 67 +++++++++++++++++-- src/test/resources/src/test.bsl | 2 +- 2 files changed, 61 insertions(+), 8 deletions(-) diff --git a/src/test/java/com/github/_1c_syntax/bsl/sonar/BSLHighlighterTest.java b/src/test/java/com/github/_1c_syntax/bsl/sonar/BSLHighlighterTest.java index fc34fe72..2a3ab3ab 100644 --- a/src/test/java/com/github/_1c_syntax/bsl/sonar/BSLHighlighterTest.java +++ b/src/test/java/com/github/_1c_syntax/bsl/sonar/BSLHighlighterTest.java @@ -85,7 +85,7 @@ void testMergeHighlightingTokens() { // given context = SensorContextTester.create(Path.of(".")); highlighter = new BSLHighlighter(context); - String content = "А = \"ВЫБРАТЬ РАЗРЕШЕННЫЕ Поле.Один \n" + + String content = "А = \"\" \"ВЫБРАТЬ РАЗРЕШЕННЫЕ Поле.Один \n" + "|КАК \n" + "| Один, 2 \n" + " | КАК Два ИЗ Справочник.Поле\n" + @@ -101,12 +101,65 @@ void testMergeHighlightingTokens() { // then String componentKey = "moduleKey:" + FILE_NAME; - checkTokenTypeAtPosition(componentKey, 1, 4, TypeOfText.STRING); - checkTokenTypeAtPosition(componentKey, 1, 5, TypeOfText.KEYWORD); - checkTokenTypeAtPosition(componentKey, 1, 6, TypeOfText.KEYWORD); - checkTokenTypeAtPosition(componentKey, 1, 12, TypeOfText.STRING); - checkTokenTypeAtPosition(componentKey, 1, 13, TypeOfText.KEYWORD); - checkTokenTypeAtPosition(componentKey, 1, 25, TypeOfText.STRING); + checkTokenTypeAtPosition(componentKey, 1, 7, TypeOfText.STRING); + checkTokenTypeAtPosition(componentKey, 1, 8, TypeOfText.KEYWORD); + checkTokenTypeAtPosition(componentKey, 1, 9, TypeOfText.KEYWORD); + checkTokenTypeAtPosition(componentKey, 1, 15, TypeOfText.STRING); + checkTokenTypeAtPosition(componentKey, 1, 16, TypeOfText.KEYWORD); + checkTokenTypeAtPosition(componentKey, 1, 28, TypeOfText.STRING); + + checkTokenTypeAtPosition(componentKey, 2, 0, TypeOfText.STRING); + checkTokenTypeAtPosition(componentKey, 2, 1, TypeOfText.KEYWORD); + checkTokenTypeAtPosition(componentKey, 2, 2, TypeOfText.KEYWORD); + + checkTokenTypeAtPosition(componentKey, 3, 0, TypeOfText.STRING); + checkTokenTypeAtPosition(componentKey, 3, 1, TypeOfText.STRING); + checkTokenTypeAtPosition(componentKey, 3, 5, TypeOfText.STRING); + checkTokenTypeAtPosition(componentKey, 3, 9, TypeOfText.CONSTANT); + + checkTokenTypeAtPosition(componentKey, 4, 1, TypeOfText.STRING); + checkTokenTypeAtPosition(componentKey, 4, 2, TypeOfText.STRING); + checkTokenTypeAtPosition(componentKey, 4, 6, TypeOfText.KEYWORD); + checkTokenTypeAtPosition(componentKey, 4, 10, TypeOfText.STRING); + checkTokenTypeAtPosition(componentKey, 4, 13, TypeOfText.KEYWORD); + checkTokenTypeAtPosition(componentKey, 4, 16, TypeOfText.KEYWORD_LIGHT); + + checkTokenTypeAtPosition(componentKey, 5, 0, TypeOfText.STRING); + checkTokenTypeAtPosition(componentKey, 5, 1, TypeOfText.KEYWORD); + checkTokenTypeAtPosition(componentKey, 5, 18, TypeOfText.KEYWORD); + checkTokenTypeAtPosition(componentKey, 5, 19, TypeOfText.KEYWORD_LIGHT); + checkTokenTypeAtPosition(componentKey, 5, 20, TypeOfText.STRING); + checkTokenTypeAtPosition(componentKey, 5, 21, TypeOfText.KEYWORD_LIGHT); + + } + + @Test + void testCrazyStrings() { + // given + context = SensorContextTester.create(Path.of(".")); + highlighter = new BSLHighlighter(context); + String content = "ТекстПредупреждения = " + + "\"выбрать пункт меню \"" + + "\" и следовать подсказкам мастера обновления\';uk=\'Увага, використовується застаріла версія FREDO Звіт!\"" + + "\" і слідувати підказкам майстра оновлення\'"; + + documentContext = new DocumentContext(URI.create("file:///fake.bsl"), content, null, null); + documentContext.rebuild(content); + + inputFile = Tools.inputFileBSL(FILE_NAME, BASE_DIR, content); + + // when + highlighter.saveHighlighting(inputFile, documentContext); + + // then + String componentKey = "moduleKey:" + FILE_NAME; + + checkTokenTypeAtPosition(componentKey, 1, 7, TypeOfText.STRING); + checkTokenTypeAtPosition(componentKey, 1, 8, TypeOfText.KEYWORD); + checkTokenTypeAtPosition(componentKey, 1, 9, TypeOfText.KEYWORD); + checkTokenTypeAtPosition(componentKey, 1, 15, TypeOfText.STRING); + checkTokenTypeAtPosition(componentKey, 1, 16, TypeOfText.KEYWORD); + checkTokenTypeAtPosition(componentKey, 1, 28, TypeOfText.STRING); checkTokenTypeAtPosition(componentKey, 2, 0, TypeOfText.STRING); checkTokenTypeAtPosition(componentKey, 2, 1, TypeOfText.KEYWORD); diff --git a/src/test/resources/src/test.bsl b/src/test/resources/src/test.bsl index c81def5d..4d6fb789 100644 --- a/src/test/resources/src/test.bsl +++ b/src/test/resources/src/test.bsl @@ -12,5 +12,5 @@ Проверка = Истина; Число = 0.01; // Комментарий? - +F = "F" "f"; #КонецОбласти \ No newline at end of file