addLanguage method
Registers language, replacing any language with the same scope name.
Compiled grammars that this language affects are rebuilt on next use: one it replaces, one that includes or embeds it, or one it injects into. A StateStack from such a grammar is no longer accepted.
Implementation
void addLanguage(Language language) {
_revision++;
final replaced = _byScope[language.scopeName];
if (replaced != null) {
_byName.removeWhere((_, l) => identical(l, replaced));
}
_byName[language.name] = language;
for (final alias in language.aliases) {
// File extensions and secondary aliases must not shadow canonical IDs.
if (_byName[alias]?.name != alias) _byName[alias] = language;
}
_byScope[language.scopeName] = language;
_grammars.removeWhere((_, g) => g.isAffectedBy(language));
}