@@ -328,29 +328,15 @@ fn read_query(language: &str, filename: &str) -> String {
328328
329329 let query = load_runtime_file(language, filename).unwrap_or_default();
330330
331− // TODO: the collect() is not ideal
332− let inherits = INHERITS_REGEX
333− .captures_iter(&query)
334− .flat_map(|captures| {
331+ // replaces all "; inherits <language>(,<language>)*" with the queries of the given language(s)
332+ INHERITS_REGEX
333+ .replace_all(&query, |captures: ®ex::Captures| {
335334 captures[1]
336335 .split(',')
337− .map(str::to_owned)
338− .collect::<Vec<_>>()
336+ .map(|language| format!("\n{}\n", read_query(language, filename)))
337+ .collect::<String>()
339338 })
340− .collect::<Vec<_>>();
341−
342− if inherits.is_empty() {
343− return query;
344− }
345−
346− let mut queries = inherits
347− .iter()
348− .map(|language| read_query(language, filename))
349− .collect::<Vec<_>>();
350−
351− queries.push(query);
352−
353− queries.concat()
339+ .to_string()
354340}
355341
356342impl LanguageConfiguration {