Skip to content

Commit bfbafa9

Browse files
nixel2007Copilot
andcommitted
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>
1 parent b5963ff commit bfbafa9

File tree

2 files changed

+8
-15
lines changed

2 files changed

+8
-15
lines changed

build.gradle.kts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,16 @@ tasks.jar {
143143

144144
tasks.shadowJar {
145145
duplicatesStrategy = DuplicatesStrategy.INCLUDE
146-
mergeServiceFiles() // Критично для плагинов Sonar
146+
mergeServiceFiles()
147147
transform(com.github.jengelman.gradle.plugins.shadow.transformers.AppendingTransformer::class.java) {
148148
resource.set("META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports")
149149
separator.set("\n")
150150
}
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+
}
151156
configurations = listOf(project.configurations["runtimeClasspath"])
152157
archiveClassifier.set("")
153158
}

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

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -182,24 +182,12 @@ public void highlightToken(
182182

183183
var line = token.getLine();
184184
var charPositionInLine = token.getCharPositionInLine();
185-
String tokenText = token.getText();
186-
187-
var firstNewLine = tokenText.indexOf('\n');
188-
var firstCR = tokenText.indexOf('\r');
189-
int effectiveLength;
190-
if (firstNewLine >= 0 || firstCR >= 0) {
191-
var boundary = (firstNewLine >= 0 && firstCR >= 0)
192-
? Math.min(firstNewLine, firstCR)
193-
: Math.max(firstNewLine, firstCR);
194-
effectiveLength = boundary;
195-
} else {
196-
effectiveLength = (int) tokenText.codePoints().count();
197-
}
185+
var tokenText = token.getText().stripTrailing();
198186

199187
var range = Ranges.create(
200188
line,
201189
charPositionInLine,
202-
charPositionInLine + effectiveLength
190+
charPositionInLine + (int) tokenText.codePoints().count()
203191
);
204192

205193
highlightingData.add(new HighlightingData(range, typeOfText));

0 commit comments

Comments
 (0)