Skip to content

Commit

Permalink
Merge pull request #349 from 1c-syntax/fix/cpd-codepoints
Browse files Browse the repository at this point in the history
Fix #348. Исправлен расчет длины токена.
  • Loading branch information
nixel2007 authored Dec 29, 2024
2 parents 5435c7f + 07be91a commit f6d523c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ private void saveCpd(InputFile inputFile, DocumentContext documentContext) {
line,
charPositionInLine,
line,
charPositionInLine + tokenText.length(),
charPositionInLine + (int) tokenText.codePoints().count(),
tokenText
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public void highlightToken(
line,
charPositionInLine,
line,
charPositionInLine + tokenText.length()
charPositionInLine + (int) tokenText.codePoints().count()
);

var data = new HighlightingData(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ void testComplexity() {
// todo надо как-то нормально ключ компонента определить
var componentKey = "moduleKey:" + FILE_NAME;
assertThat(context.measures(componentKey)).isNotEmpty();
assertThat(context.measure(componentKey, CoreMetrics.COMPLEXITY).value()).isEqualTo(3);
assertThat(context.measure(componentKey, CoreMetrics.COMPLEXITY).value()).isEqualTo(5);
assertThat(context.measure(componentKey, CoreMetrics.COGNITIVE_COMPLEXITY).value()).isEqualTo(1);

}
Expand All @@ -225,7 +225,7 @@ void testCPD() {
var componentKey = "moduleKey:" + FILE_NAME;
assertThat(context.cpdTokens(componentKey))
.isNotNull()
.hasSize(13);
.hasSize(19);
assertThat(context.cpdTokens(componentKey))
.filteredOn(tok -> tok.getValue().startsWith("ОставшийсяТокен"))
.hasSize(1);
Expand Down
8 changes: 8 additions & 0 deletions src/test/resources/examples/src/test.bsl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@
#КонецВставки
КонецПроцедуры

Функция ФункцияКотораяДолжнаНеУпасть()
Возврат "🟡";
КонецФункции

Функция ФункцияКотораяНеУпадет()
Возврат "✅";
КонецФункции

#Область Тест

Проверка = Истина;
Expand Down

0 comments on commit f6d523c

Please sign in to comment.