diff --git a/org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/internal/grammar/raw/RawGrammar.java b/org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/internal/grammar/raw/RawGrammar.java index f57c360f4..c05f36efb 100644 --- a/org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/internal/grammar/raw/RawGrammar.java +++ b/org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/internal/grammar/raw/RawGrammar.java @@ -29,7 +29,7 @@ public final class RawGrammar extends PropertySettable.HashMap<@Nullable Object> private static final String INJECTION_SELECTOR = "injectionSelector"; private static final String NAME = "name"; private static final String PATTERNS = "patterns"; - private static final String SCOPE_NAME = "scopeName"; + public static final String SCOPE_NAME = "scopeName"; private static final long serialVersionUID = 1L; diff --git a/org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/internal/grammar/raw/RawGrammarReader.java b/org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/internal/grammar/raw/RawGrammarReader.java index d99b9f0f3..03c7c6b37 100644 --- a/org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/internal/grammar/raw/RawGrammarReader.java +++ b/org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/internal/grammar/raw/RawGrammarReader.java @@ -49,7 +49,7 @@ public PropertySettable createChild(final TMParser.PropertyPath path, final C } }; - public static IRawGrammar readGrammar(final IGrammarSource source) throws Exception { + public static RawGrammar readGrammar(final IGrammarSource source) throws Exception { try (var reader = source.getReader()) { return switch (source.getContentType()) { case JSON -> TMParserJSON.INSTANCE.parse(reader, OBJECT_FACTORY); diff --git a/org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/registry/Registry.java b/org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/registry/Registry.java index 3b23dc759..0b180cba2 100644 --- a/org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/registry/Registry.java +++ b/org.eclipse.tm4e.core/src/main/java/org/eclipse/tm4e/core/registry/Registry.java @@ -30,6 +30,7 @@ import org.eclipse.tm4e.core.grammar.IGrammar; import org.eclipse.tm4e.core.internal.grammar.BalancedBracketSelectors; import org.eclipse.tm4e.core.internal.grammar.dependencies.ScopeDependencyProcessor; +import org.eclipse.tm4e.core.internal.grammar.raw.RawGrammar; import org.eclipse.tm4e.core.internal.grammar.raw.RawGrammarReader; import org.eclipse.tm4e.core.internal.registry.SyncRegistry; import org.eclipse.tm4e.core.internal.theme.Theme; @@ -158,6 +159,12 @@ private boolean _doLoadSingleGrammar(final String scopeName) { } try { final var grammar = RawGrammarReader.readGrammar(grammarSource); + + // this code is specific to the tm4e project and not from upstream: + // adjust the scopeName in case the name as defined inside the TextMate grammar file + // diverges from the scopeName with which it is registered in the plugin.xml. + grammar.put(RawGrammar.SCOPE_NAME, scopeName); + this._syncRegistry.addGrammar(grammar, this._options.getInjections(scopeName)); } catch (final Exception ex) { throw new TMException("Loading grammar for scope [" + scopeName + "] from [" +