Skip to content

Commit

Permalink
More removal
Browse files Browse the repository at this point in the history
  • Loading branch information
neunenak committed Jun 20, 2023
1 parent dfb35ae commit 6f77cc1
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 95 deletions.
72 changes: 0 additions & 72 deletions src/analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,78 +150,6 @@ impl<'src> Analyzer<'src> {
Ok(recipes)
}

fn justfile(mut self, ast: &Ast<'src>) -> CompileResult<'src, Justfile<'src>> {
let mut recipes = Vec::new();

for item in &ast.items {
match item {
Item::Alias(alias) => {
self.analyze_alias(alias)?;
self.aliases.insert(alias.clone());
}
Item::Assignment(assignment) => {
self.analyze_assignment(assignment)?;
self.assignments.insert(assignment.clone());
}
Item::Comment(_) | Item::Include { .. } => (),
Item::Recipe(recipe) => {
if recipe.enabled() {
Self::analyze_recipe(recipe)?;
recipes.push(recipe);
}
}
Item::Set(set) => {
self.analyze_set(set)?;
self.sets.insert(set.clone());
}
}
}

let settings = Settings::from_setting_iter(self.sets.into_iter().map(|(_, set)| set.value));

let mut recipe_table: Table<'src, UnresolvedRecipe<'src>> = Table::default();

AssignmentResolver::resolve_assignments(&self.assignments)?;

for recipe in recipes {
if let Some(original) = recipe_table.get(recipe.name.lexeme()) {
if !settings.allow_duplicate_recipes {
return Err(recipe.name.token().error(DuplicateRecipe {
recipe: original.name(),
first: original.line_number(),
}));
}
}
recipe_table.insert(recipe.clone());
}

let recipes = RecipeResolver::resolve_recipes(recipe_table, &self.assignments)?;

let mut aliases = Table::new();
while let Some(alias) = self.aliases.pop() {
aliases.insert(Self::resolve_alias(&recipes, alias)?);
}

Ok(Justfile {
warnings: ast.warnings.clone(),
//TODO make sure this still works in a multi-justfile world
first: recipes
.values()
.fold(None, |accumulator, next| match accumulator {
None => Some(Rc::clone(next)),
Some(previous) => Some(if previous.line_number() < next.line_number() {
previous
} else {
Rc::clone(next)
}),
}),
aliases,
assignments: self.assignments,
recipes,
settings,
})
}

fn analyze_recipe(recipe: &UnresolvedRecipe<'src>) -> CompileResult<'src, ()> {
let mut parameters = BTreeSet::new();
let mut passed_default = false;
Expand Down
23 changes: 0 additions & 23 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,20 +88,12 @@ pub(crate) enum Error<'src> {
function: Name<'src>,
message: String,
},
IncludeMissingPath {
file: PathBuf,
line: usize,
},
InitExists {
justfile: PathBuf,
},
Internal {
message: String,
},
//TODO remove this, it's replaced by a compiler error
InvalidDirective {
line: String,
},
Io {
recipe: &'src str,
io_error: io::Error,
Expand Down Expand Up @@ -469,18 +461,6 @@ impl<'src> ColorDisplay for Error<'src> {
function.lexeme()
)?;
}
IncludeMissingPath {
file: justfile, line
} => {

write!(
f,
"!include directive on line {} of `{}` has no argument",
line.ordinal(),
justfile.display(),
)?;

},
InitExists { justfile } => {
write!(f, "Justfile `{}` already exists", justfile.display())?;
}
Expand All @@ -491,9 +471,6 @@ impl<'src> ColorDisplay for Error<'src> {
consider filing an issue: https://github.com/casey/just/issues/new"
)?;
}
InvalidDirective { line } => {
write!(f, "Invalid directive: {line}")?;
}
Io { recipe, io_error } => {
match io_error.kind() {
io::ErrorKind::NotFound => write!(
Expand Down

0 comments on commit 6f77cc1

Please sign in to comment.