Language.fromJson constructor
Language.fromJson(})
Creates a language from a decoded *.tmLanguage.json.
Throws ArgumentError if the grammar has no scopeName.
Implementation
factory Language.fromJson(
Map<String, Object?> grammar, {
required String name,
List<String> aliases = const [],
List<String> injectTo = const [],
}) {
final scopeName = grammar['scopeName'];
if (scopeName is! String) {
throw ArgumentError.value(
grammar['name'] ?? grammar.keys.take(3).toList(),
'grammar',
'The grammar for "$name" has no "scopeName" string',
);
}
return Language(
name: name,
scopeName: scopeName,
grammar: grammar,
aliases: aliases,
injectTo: injectTo,
);
}