Skip to content

Commit 5d0eeb3

Browse files
nixel2007Copilot
andauthored
fix: SonarQube 26.2 compatibility (Jackson 3 / BSL LS 0.29.0-rc.1) (#417)
* fix: SonarQube 26.2 compatibility (Jackson 3 / BSL LS 0.29.0-rc.1) - Update bsl-language-server dependency from 0.28.5 to 0.29.0-rc.1 - Fix shadow JAR merging of AutoConfiguration.imports to include JacksonAutoConfiguration (required for JsonMapper bean) - Update SDBLLexer token references for bsl-parser 0.31.0 API changes - Add new tokens ADD (keyword) and UNIQUE (function) to highlighter Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: handle tokens with trailing line terminators in highlighter Tokens from bsl-parser 0.31.0 may include trailing CR/LF characters in their text. When computing the highlight range end offset, this caused the offset to exceed the line length, resulting in IllegalArgumentException from SonarQube. Truncate token text at the first newline/CR to compute correct single-line highlight ranges. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * fix: merge LanguageTool language-module.properties in shadow JAR DuplicatesStrategy.INCLUDE caused multiple language-module.properties entries in the shadow JAR. Java classloader picked only the last one (Russian), so TypoDiagnostic failed with 'en-US is not a language code known to LanguageTool'. Add PropertiesFileTransformer with Append merge strategy to properly combine all LanguageTool language classes into a single properties file. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent f117178 commit 5d0eeb3

3 files changed

Lines changed: 58 additions & 44 deletions

File tree

build.gradle.kts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ val commonmarkVersion = "0.27.1"
2727
dependencies {
2828
compileOnly("org.sonarsource.api.plugin", "sonar-plugin-api", "11.3.0.2824")
2929

30-
implementation("io.github.1c-syntax", "bsl-language-server", "0.28.5") {
30+
implementation("io.github.1c-syntax", "bsl-language-server", "0.29.0-rc.1") {
3131
exclude("com.contrastsecurity", "java-sarif")
3232
exclude("io.sentry", "sentry-logback")
3333
exclude("info.picocli", "picocli-spring-boot-starter")
@@ -142,7 +142,17 @@ tasks.jar {
142142
}
143143

144144
tasks.shadowJar {
145-
mergeServiceFiles() // Критично для плагинов Sonar
145+
duplicatesStrategy = DuplicatesStrategy.INCLUDE
146+
mergeServiceFiles()
147+
transform(com.github.jengelman.gradle.plugins.shadow.transformers.AppendingTransformer::class.java) {
148+
resource.set("META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports")
149+
separator.set("\n")
150+
}
151+
transform(com.github.jengelman.gradle.plugins.shadow.transformers.PropertiesFileTransformer::class.java) {
152+
paths.set(setOf("META-INF/org/languagetool/language-module.properties"))
153+
mergeStrategy.set(com.github.jengelman.gradle.plugins.shadow.transformers.PropertiesFileTransformer.MergeStrategy.Append)
154+
mergeSeparator.set(",")
155+
}
146156
configurations = listOf(project.configurations["runtimeClasspath"])
147157
archiveClassifier.set("")
148158
}

src/main/java/com/github/_1c_syntax/bsl/sonar/BSLHighlighter.java

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public void highlightToken(
182182

183183
var line = token.getLine();
184184
var charPositionInLine = token.getCharPositionInLine();
185-
String tokenText = token.getText();
185+
var tokenText = token.getText().stripTrailing();
186186

187187
var range = Ranges.create(
188188
line,
@@ -533,20 +533,21 @@ private static Set<Integer> createSdblFunctions() {
533533
SDBLLexer.STOREDDATASIZE,
534534
SDBLLexer.UUID,
535535
SDBLLexer.STRFIND,
536-
SDBLLexer.STRREPLACE
536+
SDBLLexer.STRREPLACE,
537+
SDBLLexer.UNIQUE
537538
);
538539
}
539540

540541
private static Set<Integer> createSdblKeywords() {
541542
return Set.of(
542-
SDBLLexer.ALL,
543+
SDBLLexer.ADD,
543544
SDBLLexer.ALLOWED,
544545
SDBLLexer.AND,
545546
SDBLLexer.AS,
546547
SDBLLexer.ASC,
547548
SDBLLexer.AUTOORDER,
548549
SDBLLexer.BETWEEN,
549-
SDBLLexer.BY_EN,
550+
SDBLLexer.BY,
550551
SDBLLexer.CASE,
551552
SDBLLexer.CAST,
552553
SDBLLexer.DESC,
@@ -556,46 +557,48 @@ private static Set<Integer> createSdblKeywords() {
556557
SDBLLexer.END,
557558
SDBLLexer.ESCAPE,
558559
SDBLLexer.FALSE,
559-
SDBLLexer.FOR,
560+
SDBLLexer.FOR_UPDATE,
560561
SDBLLexer.FROM,
561-
SDBLLexer.FULL,
562-
SDBLLexer.GROUP,
562+
SDBLLexer.FULL_JOIN,
563+
SDBLLexer.FULL_OUTER_JOIN,
564+
SDBLLexer.GROUP_BY,
565+
SDBLLexer.GROUP_BY_GROUPING_SETS,
563566
SDBLLexer.HAVING,
564567
SDBLLexer.HIERARCHY,
565-
SDBLLexer.HIERARCHY_FOR_IN,
568+
SDBLLexer.IN_HIERARCHY,
566569
SDBLLexer.IN,
567-
SDBLLexer.INDEX,
568-
SDBLLexer.INNER,
570+
SDBLLexer.INDEX_BY,
571+
SDBLLexer.INDEX_BY_SETS,
572+
SDBLLexer.INNER_JOIN,
569573
SDBLLexer.INTO,
570574
SDBLLexer.IS,
571575
SDBLLexer.ISNULL,
572576
SDBLLexer.JOIN,
573577
SDBLLexer.LEFT,
578+
SDBLLexer.LEFT_JOIN,
579+
SDBLLexer.LEFT_OUTER_JOIN,
574580
SDBLLexer.LIKE,
575581
SDBLLexer.NOT,
576582
SDBLLexer.OF,
577-
SDBLLexer.ONLY,
578-
SDBLLexer.ON_EN,
583+
SDBLLexer.ONLY_HIERARCHY,
579584
SDBLLexer.OR,
580-
SDBLLexer.ORDER,
585+
SDBLLexer.ORDER_BY,
581586
SDBLLexer.OVERALL,
582-
SDBLLexer.OUTER,
583587
SDBLLexer.PERIODS,
584-
SDBLLexer.PO_RU,
585588
SDBLLexer.REFS,
586589
SDBLLexer.RIGHT,
590+
SDBLLexer.RIGHT_JOIN,
591+
SDBLLexer.RIGHT_OUTER_JOIN,
587592
SDBLLexer.SELECT,
588-
SDBLLexer.SET,
589593
SDBLLexer.THEN,
590594
SDBLLexer.TOP,
591595
SDBLLexer.TOTALS,
592596
SDBLLexer.UNION,
593-
SDBLLexer.UPDATE,
597+
SDBLLexer.UNION_ALL,
594598
SDBLLexer.WHEN,
595599
SDBLLexer.WHERE,
596600
SDBLLexer.EMPTYREF,
597-
SDBLLexer.GROUPEDBY,
598-
SDBLLexer.GROUPING
601+
SDBLLexer.GROUPEDBY
599602
);
600603
}
601604

src/test/java/com/github/_1c_syntax/bsl/sonar/BSLHighlighterTest.java

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -289,14 +289,14 @@ private Map<String, TypeOfText> getHighlightingMapBSL(Vocabulary vocabulary) {
289289
private Map<String, TypeOfText> getHighlightingMapSDBL(Vocabulary vocabulary) {
290290

291291
Set<String> keywords = Set.of(
292-
"ALL",
292+
"ADD",
293293
"ALLOWED",
294294
"AND",
295295
"AS",
296296
"ASC",
297297
"AUTOORDER",
298298
"BETWEEN",
299-
"BY_EN",
299+
"BY",
300300
"CASE",
301301
"CAST",
302302
"DESC",
@@ -307,45 +307,47 @@ private Map<String, TypeOfText> getHighlightingMapSDBL(Vocabulary vocabulary) {
307307
"ESCAPE",
308308
"EMPTYREF",
309309
"FALSE",
310-
"FOR",
310+
"FOR_UPDATE",
311311
"FROM",
312-
"FULL",
313-
"GROUP",
312+
"FULL_JOIN",
313+
"FULL_OUTER_JOIN",
314+
"GROUP_BY",
315+
"GROUP_BY_GROUPING_SETS",
314316
"GROUPEDBY",
315-
"GROUPING",
316317
"HAVING",
317318
"HIERARCHY",
318-
"HIERARCHY_FOR_IN",
319+
"IN_HIERARCHY",
319320
"IN",
320-
"INDEX",
321-
"INNER",
321+
"INDEX_BY",
322+
"INDEX_BY_SETS",
323+
"INNER_JOIN",
322324
"INTO",
323325
"IS",
324326
"ISNULL",
325327
"JOIN",
326328
"LEFT",
329+
"LEFT_JOIN",
330+
"LEFT_OUTER_JOIN",
327331
"LIKE",
328332
"NOT",
329333
"OF",
330-
"ON_EN",
334+
"ONLY_HIERARCHY",
331335
"OR",
332-
"ORDER",
336+
"ORDER_BY",
333337
"OVERALL",
334-
"OUTER",
335-
"PO_RU",
338+
"PERIODS",
339+
"REFS",
336340
"RIGHT",
341+
"RIGHT_JOIN",
342+
"RIGHT_OUTER_JOIN",
337343
"SELECT",
338-
"SET",
339344
"THEN",
340345
"TOP",
341346
"TOTALS",
342347
"UNION",
348+
"UNION_ALL",
343349
"WHEN",
344-
"WHERE",
345-
"ONLY",
346-
"PERIODS",
347-
"REFS",
348-
"UPDATE"
350+
"WHERE"
349351
);
350352

351353
Set<String> functions = Set.of(
@@ -405,7 +407,8 @@ private Map<String, TypeOfText> getHighlightingMapSDBL(Vocabulary vocabulary) {
405407
"STOREDDATASIZE",
406408
"UUID",
407409
"STRFIND",
408-
"STRREPLACE"
410+
"STRREPLACE",
411+
"UNIQUE"
409412
);
410413

411414
Set<String> metadataTypes = Set.of(
@@ -479,9 +482,7 @@ private Map<String, TypeOfText> getHighlightingMapSDBL(Vocabulary vocabulary) {
479482
"ROUTEPOINT_FIELD",
480483
"IDENTIFIER",
481484
"INCORRECT_IDENTIFIER",
482-
"BRACE_IDENTIFIER",
483-
"UNKNOWN",
484-
"BAR" // TODO: Убрать из лексера
485+
"UNKNOWN"
485486
);
486487

487488
Set<String> eds = Set.of(

0 commit comments

Comments
 (0)