From 09a39055ba849ae5208df6776577a9f06e5dedd7 Mon Sep 17 00:00:00 2001 From: Casey Rodarmor Date: Wed, 22 Nov 2023 10:33:55 -0800 Subject: [PATCH] =?UTF-8?q?Rename=20Justfile::first=20=E2=86=92=20Justfile?= =?UTF-8?q?::default=20(#1741)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/analyzer.rs | 2 +- src/compiler.rs | 9 ++------- src/justfile.rs | 6 +++--- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/analyzer.rs b/src/analyzer.rs index 24710f8..e4cef06 100644 --- a/src/analyzer.rs +++ b/src/analyzer.rs @@ -88,7 +88,7 @@ impl<'src> Analyzer<'src> { let root = paths.get(root).unwrap(); Ok(Justfile { - first: recipes + default: recipes .values() .filter(|recipe| recipe.name.path == root) .fold(None, |accumulator, next| match accumulator { diff --git a/src/compiler.rs b/src/compiler.rs index e7fb7cc..070748e 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -8,20 +8,19 @@ impl Compiler { loader: &'src Loader, root: &Path, ) -> RunResult<'src, Compilation<'src>> { - let mut srcs: HashMap = HashMap::new(); let mut asts: HashMap = HashMap::new(); let mut paths: HashMap = HashMap::new(); + let mut srcs: HashMap = HashMap::new(); let mut stack: Vec = Vec::new(); stack.push(root.into()); while let Some(current) = stack.pop() { let (relative, src) = loader.load(root, ¤t)?; - paths.insert(current.clone(), relative.into()); - let tokens = Lexer::lex(relative, src)?; let mut ast = Parser::parse(&tokens)?; + paths.insert(current.clone(), relative.into()); srcs.insert(current.clone(), src); for item in &mut ast.items { @@ -31,15 +30,11 @@ impl Compiler { message: "The !include directive is currently unstable.".into(), }); } - let include = current.parent().unwrap().join(relative).lexiclean(); - if srcs.contains_key(&include) { return Err(Error::CircularInclude { current, include }); } - *absolute = Some(include.clone()); - stack.push(include); } } diff --git a/src/justfile.rs b/src/justfile.rs index a4bbcc9..b08d431 100644 --- a/src/justfile.rs +++ b/src/justfile.rs @@ -4,8 +4,8 @@ use {super::*, serde::Serialize}; pub(crate) struct Justfile<'src> { pub(crate) aliases: Table<'src, Alias<'src>>, pub(crate) assignments: Table<'src, Assignment<'src>>, - #[serde(serialize_with = "keyed::serialize_option")] - pub(crate) first: Option>>, + #[serde(rename = "first", serialize_with = "keyed::serialize_option")] + pub(crate) default: Option>>, pub(crate) recipes: Table<'src, Rc>>, pub(crate) settings: Settings<'src>, pub(crate) warnings: Vec, @@ -190,7 +190,7 @@ impl<'src> Justfile<'src> { let argvec: Vec<&str> = if !arguments.is_empty() { arguments.iter().map(String::as_str).collect() - } else if let Some(recipe) = &self.first { + } else if let Some(recipe) = &self.default { let min_arguments = recipe.min_arguments(); if min_arguments > 0 { return Err(Error::DefaultRecipeRequiresArguments {