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: Lookup grammars with "langpck." scope name prefix if not found #602

Merged
merged 1 commit into from
Nov 1, 2023
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
2 changes: 1 addition & 1 deletion org.eclipse.tm4e.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Bundle-SymbolicName: org.eclipse.tm4e.core
Bundle-Version: 0.6.1.qualifier
Bundle-Version: 0.6.2.qualifier
Require-Bundle: com.google.gson;bundle-version="[2.10.1,3.0.0)",
com.google.guava;bundle-version="[32.1.0,33.0.0)",
org.apache.batik.css;bundle-version="[1.16.0,2.0.0)";resolution:=optional,
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.tm4e.core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<artifactId>org.eclipse.tm4e.core</artifactId>
<packaging>eclipse-plugin</packaging>
<version>0.6.1-SNAPSHOT</version>
<version>0.6.2-SNAPSHOT</version>

<profiles>
<profile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
public final class SyncRegistry implements IGrammarRepository, IThemeProvider {

private final Map<String, Grammar> _grammars = new HashMap<>();
private final Map<String, IRawGrammar> _rawGrammars = new HashMap<>();
private final Map<String, @Nullable IRawGrammar> _rawGrammars = new HashMap<>();
private final Map<String, Collection<String>> _injectionGrammars = new HashMap<>();
private Theme _theme;

Expand Down Expand Up @@ -68,7 +68,14 @@ public void addGrammar(final IRawGrammar grammar, @Nullable final Collection<Str
@Override
@Nullable
public IRawGrammar lookup(final String scopeName) {
return this._rawGrammars.get(scopeName);
var grammar = this._rawGrammars.get(scopeName);

// check if tm4e language pack is installed, e.g. "source.python" -> "lngpck.source.python"
if (grammar == null && !scopeName.startsWith("lngpck.")) {
grammar = this._rawGrammars.get("lngpck." + scopeName);
}

return grammar;
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.tm4e.registry/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.tm4e.registry;singleton:=true
Bundle-Version: 0.6.5.qualifier
Bundle-Version: 0.6.6.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-17
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.equinox.preferences,
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.tm4e.registry/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@

<artifactId>org.eclipse.tm4e.registry</artifactId>
<packaging>eclipse-plugin</packaging>
<version>0.6.5-SNAPSHOT</version>
<version>0.6.6-SNAPSHOT</version>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
*/
package org.eclipse.tm4e.registry.internal;

import static org.eclipse.tm4e.core.internal.utils.NullSafetyHelper.castNullable;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -61,7 +63,14 @@ Collection<IGrammarDefinition> getDefinitions() {
*/
@Nullable
IGrammarDefinition getDefinition(final String scopeName) {
return definitions.get(scopeName);
var grammar = castNullable(definitions.get(scopeName));

// check if tm4e language pack is installed, e.g. "source.python" -> "lngpck.source.python"
if (grammar == null && !scopeName.startsWith("lngpck.")) {
grammar = definitions.get("lngpck." + scopeName);
}

return grammar;
}

/**
Expand Down