Skip to content

Commit b79af53

Browse files
committed
feat: add IGrammarRegistryManager#getInjections(ITMScope)
1 parent 7f9962a commit b79af53

3 files changed

Lines changed: 21 additions & 5 deletions

File tree

org.eclipse.tm4e.registry/src/main/java/org/eclipse/tm4e/registry/IGrammarRegistryManager.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,16 @@ default IGrammarRegistryManager.EditSession newEditSession() {
9898
Collection<IContentType> getContentTypesForScope(ITMScope scope);
9999

100100
/**
101+
* @param scopeName an unqualified (sources.batchfile) or qualified (sources.batchfile@plugin) scope name
102+
*
101103
* @return list of scope names to inject for the given <code>scopeName</code> and null otherwise.
102104
*/
103105
@Nullable
104106
Collection<String> getInjections(String scopeName);
107+
108+
/**
109+
* @return list of scope names to inject for the given scope name and null otherwise.
110+
*/
111+
@Nullable
112+
Collection<String> getInjections(ITMScope scope);
105113
}

org.eclipse.tm4e.registry/src/main/java/org/eclipse/tm4e/registry/internal/AbstractGrammarRegistryManager.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,8 @@ public long getLastModified() {
156156
@Override
157157
public @Nullable IGrammar getGrammarFor(final IContentType... contentTypes) {
158158
// -> used by TMPresentationReconciler
159-
for (@Nullable IContentType contentType : contentTypes) {
159+
for (@Nullable
160+
IContentType contentType : contentTypes) {
160161
while (contentType != null) {
161162
final ContentTypeToScopeBinding binding = contentTypeToScopeBindings.get(contentType);
162163
if (binding == null) {
@@ -249,13 +250,15 @@ public IGrammarDefinition[] getDefinitions() {
249250
.toArray(IGrammarDefinition[]::new);
250251
}
251252

252-
/**
253-
* @param scopeName an unqualified (sources.batchfile) or qualified (sources.batchfile@plugin) scope name
254-
*/
255253
@Override
256254
public @Nullable Collection<String> getInjections(final String scopeName) {
257255
// -> indirectly used by org.eclipse.tm4e.core.registry.Registry._doLoadSingleGrammar(String)
258-
return injections.get(TMScope.parse(scopeName).getName());
256+
return getInjections(TMScope.parse(scopeName));
257+
}
258+
259+
@Override
260+
public @Nullable Collection<String> getInjections(final ITMScope scope) {
261+
return injections.get(scope.getName());
259262
}
260263

261264
/**

org.eclipse.tm4e.registry/src/main/java/org/eclipse/tm4e/registry/internal/WorkingCopyGrammarRegistryManager.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ public void reset() {
6464
return manager.getInjections(scopeName);
6565
}
6666

67+
@Override
68+
public @Nullable Collection<String> getInjections(final ITMScope scope) {
69+
return manager.getInjections(scope);
70+
}
71+
6772
@Override
6873
public void registerGrammarDefinition(final IGrammarDefinition definition) {
6974
super.registerGrammarDefinition(definition);

0 commit comments

Comments
 (0)