Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve language configuration validation in langpack updater #765

Merged
merged 2 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions org.eclipse.tm4e.language_pack/updater/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@
<!-- for JSON/YAML file support -->
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<version>2.16.0</version>
<version>2.16.1</version>
</dependency>
<dependency>
<!-- for *.ico image support -->
<groupId>com.twelvemonkeys.imageio</groupId>
<artifactId>imageio-bmp</artifactId>
<version>3.10.1</version>
<version>3.11.0</version>
</dependency>
<dependency>
<!-- for *.svg image support -->
<groupId>com.twelvemonkeys.imageio</groupId>
<artifactId>imageio-batik</artifactId>
<version>3.10.1</version>
<version>3.11.0</version>
</dependency>
<dependency>
<!-- for *.svg image support -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ void handle() throws IOException {
assertArgNotEmpty("package.json/contributes/languages", pkgJson.contributes().languages());

final var pkgJsonLangs = new TreeMap<String /*langId*/, Contributions.Language>();
for (final var lang : pkgJson.contributes().languages()) {
for (final Contributions.Language lang : pkgJson.contributes().languages()) {
pkgJsonLangs.put(lang.id(), lang);
}
final var pkgJsonLangGrammars = new TreeMap<String /*langId*/, Contributions.Grammar>();
final var pkgJsonInlineGrammars = new TreeMap<String /*scopeName*/, Contributions.Grammar>();
for (final var grammar : pkgJson.contributes().grammars()) {
for (final Contributions.Grammar grammar : pkgJson.contributes().grammars()) {
if (grammar.language() != null) {
if (pkgJsonLangs.containsKey(grammar.language())) {
pkgJsonLangGrammars.put(grammar.language(), grammar);
Expand All @@ -75,9 +75,18 @@ void handle() throws IOException {
for (final Entry<String, Config.LanguageIgnoreable> langOverrides : source.languages.entrySet()) {
final var langId = langOverrides.getKey();
if (!pkgJsonLangs.containsKey(langId)) {
logInfo("FAILED", true, false);
throw new IllegalArgumentException(
"No language with id [" + langId + "] found at [package.json/contributes/languages]");
final Config.LanguageIgnoreable langOverride = langOverrides.getValue();
if (isBlank(langOverride.grammar)) {
logInfo("FAILED", true, false);
throw new IllegalArgumentException(
"No language with id [" + langId + "] found at [package.json/contributes/languages]");
}
if (isBlank(langOverride.scopeName)) {
logInfo("FAILED", true, false);
throw new IllegalArgumentException("Language with id [" + langId
+ "] found at [package.json/contributes/languages] is missing scopeName");
}
pkgJsonLangs.put(langId, new Contributions.Language(langId, null, null, null, null, null, langOverride.langcfg));
}
}
logInfo("OK", true, false);
Expand Down
Loading