summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Nordholts <enselic@gmail.com>2021-09-20 20:35:30 +0200
committerMartin Nordholts <enselic@gmail.com>2021-09-22 09:14:19 +0200
commita6dc25a2169432245edf2d62472a34e2193a55ae (patch)
tree26d6fc63f740634841cbee88217640b2c57e5c68
parentf04d2a9d6a45739861168074d6f3dd84544c318c (diff)
build_assets.rs: Make OtherSyntaxLookup come before SyntaxToDependencies
It makes more sense structurally when we later introduce SyntaxToDependents.
-rw-r--r--src/assets/build_assets.rs20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/assets/build_assets.rs b/src/assets/build_assets.rs
index 3583f55b..1c7b0fc4 100644
--- a/src/assets/build_assets.rs
+++ b/src/assets/build_assets.rs
@@ -10,12 +10,12 @@ use crate::assets::*;
type SyntaxName = String;
-/// Used to look up what dependencies a given [SyntaxDefinition] has
-type SyntaxToDependencies = HashMap<SyntaxName, Vec<OtherSyntax>>;
-
/// Used to look up which [SyntaxDefinition] corresponds to a given [OtherSyntax]
type OtherSyntaxLookup<'a> = HashMap<OtherSyntax, &'a SyntaxDefinition>;
+/// Used to look up what dependencies a given [SyntaxDefinition] has
+type SyntaxToDependencies = HashMap<SyntaxName, Vec<OtherSyntax>>;
+
/// Represents some other `*.sublime-syntax` file, i.e. another [SyntaxDefinition].
#[derive(Debug, Eq, PartialEq, Clone, Hash)]
enum OtherSyntax {
@@ -215,7 +215,7 @@ fn build_minimal_syntax_sets(
let syntaxes = syntax_set_builder.syntaxes();
// Build the data structures we need for dependency resolution
- let (syntax_to_dependencies, other_syntax_lookup) = generate_maps(syntaxes);
+ let (other_syntax_lookup, syntax_to_dependencies) = generate_maps(syntaxes);
// Create one minimal SyntaxSet from each (non-hidden) SyntaxDefinition
syntaxes.iter().filter_map(move |syntax| {
@@ -224,7 +224,7 @@ fn build_minimal_syntax_sets(
}
let mut builder = SyntaxSetDependencyBuilder::new();
- builder.add_with_dependencies(syntax, &syntax_to_dependencies, &other_syntax_lookup);
+ builder.add_with_dependencies(syntax, &other_syntax_lookup, &syntax_to_dependencies);
let syntax_set = builder.build();
if std::env::var("BAT_PRINT_SYNTAX_DEPENDENCIES").is_ok() {
@@ -241,9 +241,9 @@ fn build_minimal_syntax_sets(
/// First, when we have a [OtherSyntax], we need to know what [SyntaxDefinition] that
/// corresponds to. Second, when we have a [SyntaxDefinition], we need to know
/// what dependencies it has. This functions generates that data for each syntax.
-fn generate_maps(syntaxes: &[SyntaxDefinition]) -> (SyntaxToDependencies, OtherSyntaxLookup) {
- let mut syntax_to_dependencies = HashMap::new();
+fn generate_maps(syntaxes: &[SyntaxDefinition]) -> (OtherSyntaxLookup, SyntaxToDependencies) {
let mut other_syntax_lookup = HashMap::new();
+ let mut syntax_to_dependencies = HashMap::new();
for syntax in syntaxes {
syntax_to_dependencies.insert(syntax.name.clone(), dependencies_for_syntax(syntax));
@@ -252,7 +252,7 @@ fn generate_maps(syntaxes: &[SyntaxDefinition]) -> (SyntaxToDependencies, OtherS
other_syntax_lookup.insert(OtherSyntax::ByScope(syntax.scope), syntax);
}
- (syntax_to_dependencies, other_syntax_lookup)
+ (other_syntax_lookup, syntax_to_dependencies)
}
/// Gets what external dependencies a given [SyntaxDefinition] has.
@@ -320,8 +320,8 @@ impl SyntaxSetDependencyBuilder {
fn add_with_dependencies(
&mut self,
syntax: &SyntaxDefinition,
- syntax_to_dependencies: &SyntaxToDependencies,
other_syntax_lookup: &OtherSyntaxLookup,
+ syntax_to_dependencies: &SyntaxToDependencies,
) {
let name = &syntax.name;
if self.is_syntax_already_added(name) {
@@ -340,8 +340,8 @@ impl SyntaxSetDependencyBuilder {
if let Some(syntax_definition_dependency) = other_syntax_lookup.get(dependency) {
self.add_with_dependencies(
syntax_definition_dependency,
- syntax_to_dependencies,
other_syntax_lookup,
+ syntax_to_dependencies,
)
}
}