Skip to content

Commit

Permalink
Do not crash for unknown grammar/let fallback apply
Browse files Browse the repository at this point in the history
Fixes #654
  • Loading branch information
mickaelistria committed Jan 8, 2024
1 parent 5fdd7de commit 7b313a9
Showing 1 changed file with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tm4e.core.TMException;
import org.eclipse.tm4e.core.grammar.IGrammar;
import org.eclipse.tm4e.core.registry.IGrammarSource;
import org.eclipse.tm4e.core.registry.IRegistryOptions;
Expand Down Expand Up @@ -164,16 +165,24 @@ protected AbstractGrammarRegistryManager(final IRegistryOptions options) {
continue;
}

try {
// look for a grammar provided by the same plugin as the content-type
var grammar = getGrammarForScope(binding.scope.getQualifiedName());
if (grammar != null) {
return grammar;
var grammar = getGrammarForScope(binding.scope.getQualifiedName());
if (grammar != null) {
return grammar;
}
} catch (TMException ex) {
// most likely not grammar found, continue
}

try {
// look for a grammar provided by any plugin
grammar = getGrammarForScope(binding.scope.getName());
if (grammar != null) {
return grammar;
var grammar = getGrammarForScope(binding.scope.getName());
if (grammar != null) {
return grammar;
}
} catch (TMException ex) {
// most likely not grammar found, continue
}
}
}
Expand Down

0 comments on commit 7b313a9

Please sign in to comment.