Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename Justfile::first → Justfile::default #1741

Merged
merged 1 commit into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
9 changes: 2 additions & 7 deletions src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,19 @@ impl Compiler {
loader: &'src Loader,
root: &Path,
) -> RunResult<'src, Compilation<'src>> {
let mut srcs: HashMap<PathBuf, &str> = HashMap::new();
let mut asts: HashMap<PathBuf, Ast> = HashMap::new();
let mut paths: HashMap<PathBuf, PathBuf> = HashMap::new();
let mut srcs: HashMap<PathBuf, &str> = HashMap::new();

let mut stack: Vec<PathBuf> = Vec::new();
stack.push(root.into());

while let Some(current) = stack.pop() {
let (relative, src) = loader.load(root, &current)?;
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 {
Expand All @@ -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);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/justfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Rc<Recipe<'src>>>,
#[serde(rename = "first", serialize_with = "keyed::serialize_option")]
pub(crate) default: Option<Rc<Recipe<'src>>>,
pub(crate) recipes: Table<'src, Rc<Recipe<'src>>>,
pub(crate) settings: Settings<'src>,
pub(crate) warnings: Vec<Warning>,
Expand Down Expand Up @@ -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 {
Expand Down
Loading