Skip to content

Commit bcec4da

Browse files
authored
Include module_path field in JSON (#3288)
1 parent 3f923e2 commit bcec4da

6 files changed

Lines changed: 16 additions & 14 deletions

File tree

src/analyzer.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -196,16 +196,16 @@ impl<'run, 'src> Analyzer<'run, 'src> {
196196
let mut unknown_overrides = Vec::new();
197197

198198
for ((path, name), value) in &config.overrides {
199-
if *path == ast.modulepath {
199+
if *path == ast.module_path {
200200
if let Some(assignment) = assignments.get(name) {
201201
overrides.insert(assignment.number, value.clone());
202202
} else {
203203
unknown_overrides.push(path.join(name));
204204
}
205-
} else if path.starts_with(&ast.modulepath)
205+
} else if path.starts_with(&ast.module_path)
206206
&& !self
207207
.modules
208-
.contains_key(&path.components[ast.modulepath.components.len()])
208+
.contains_key(&path.components[ast.module_path.components.len()])
209209
{
210210
unknown_overrides.push(format!("{path}::{name}"));
211211
}
@@ -257,7 +257,7 @@ impl<'run, 'src> Analyzer<'run, 'src> {
257257
let recipes = RecipeResolver::resolve_recipes(
258258
&assignments,
259259
&functions,
260-
&ast.modulepath,
260+
&ast.module_path,
261261
&self.modules,
262262
&settings,
263263
deduplicated_recipes,
@@ -311,7 +311,7 @@ impl<'run, 'src> Analyzer<'run, 'src> {
311311
functions,
312312
groups: groups.into(),
313313
loaded: loaded.into(),
314-
modulepath: ast.modulepath.clone(),
314+
module_path: ast.module_path.clone(),
315315
modules: self.modules,
316316
name,
317317
private,

src/ast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use super::*;
66
#[derive(Debug, Clone)]
77
pub(crate) struct Ast<'src> {
88
pub(crate) items: Vec<Item<'src>>,
9-
pub(crate) modulepath: Modulepath,
9+
pub(crate) module_path: Modulepath,
1010
pub(crate) unstable_features: BTreeSet<UnstableFeature>,
1111
pub(crate) warnings: Vec<Warning>,
1212
pub(crate) working_directory: PathBuf,

src/function.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ fn module_file(context: Context) -> FunctionResult {
465465
}
466466

467467
fn module_path(context: Context) -> FunctionResult {
468-
Ok(context.execution_context.module.modulepath.to_string())
468+
Ok(context.execution_context.module.module_path.to_string())
469469
}
470470

471471
fn num_cpus(_context: Context) -> FunctionResult {

src/justfile.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ pub(crate) struct Justfile<'src> {
2121
pub(crate) groups: Vec<StringLiteral<'src>>,
2222
#[serde(skip)]
2323
pub(crate) loaded: Vec<PathBuf>,
24-
#[serde(skip)]
25-
pub(crate) modulepath: Modulepath,
24+
pub(crate) module_path: Modulepath,
2625
pub(crate) modules: Table<'src, Self>,
2726
#[serde(skip)]
2827
pub(crate) name: Option<Name<'src>>,
@@ -142,7 +141,7 @@ impl<'src> Justfile<'src> {
142141
)?;
143142

144143
let scope = scope_arena.alloc(scope);
145-
scopes.insert(self.modulepath.clone(), (self, scope, dotenv));
144+
scopes.insert(self.module_path.clone(), (self, scope, dotenv));
146145

147146
for module in self.modules.values() {
148147
module.evaluate_scopes(
@@ -260,7 +259,7 @@ impl<'src> Justfile<'src> {
260259
Some(HashSet::new()).as_ref(),
261260
)?;
262261

263-
let (_module, scope, dotenv) = scopes.get(&self.modulepath).unwrap();
262+
let (_module, scope, dotenv) = scopes.get(&self.module_path).unwrap();
264263
let scope = scope.child();
265264

266265
command.export(&self.settings, dotenv, &scope, &self.unexports);
@@ -302,7 +301,7 @@ impl<'src> Justfile<'src> {
302301
Some(&variable_references),
303302
)?;
304303

305-
let scope = scopes.get(&module.modulepath).unwrap().1;
304+
let scope = scopes.get(&module.module_path).unwrap().1;
306305

307306
if let Some(variable) = variable {
308307
print!("{}", scope.value(variable).unwrap());
@@ -601,7 +600,7 @@ impl<'src> Justfile<'src> {
601600
while let Some(current) = stack.pop() {
602601
for alias in current.aliases.values() {
603602
if alias.is_public() {
604-
aliases.push((alias, &current.modulepath));
603+
aliases.push((alias, &current.module_path));
605604
}
606605
}
607606

src/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ impl<'run, 'src> Parser<'run, 'src> {
444444

445445
Ok(Ast {
446446
items: self.items,
447-
modulepath: self.module_namepath.map(Into::into).unwrap_or_default(),
447+
module_path: self.module_namepath.map(Into::into).unwrap_or_default(),
448448
unstable_features: self.unstable_features,
449449
warnings: Vec::new(),
450450
working_directory: self.working_directory.into(),

tests/json.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ struct Module<'a> {
4040
doc: Option<&'a str>,
4141
first: Option<&'a str>,
4242
groups: Vec<&'a str>,
43+
module_path: &'a str,
4344
modules: BTreeMap<&'a str, Module<'a>>,
4445
recipes: BTreeMap<&'a str, Recipe<'a>>,
4546
settings: Settings<'a>,
@@ -887,6 +888,7 @@ fn module() {
887888
Module {
888889
doc: Some("hello"),
889890
first: Some("bar"),
891+
module_path: "foo",
890892
source: "foo.just".into(),
891893
recipes: [(
892894
"bar",
@@ -920,6 +922,7 @@ fn module_group() {
920922
Module {
921923
first: Some("bar"),
922924
groups: ["alpha"].into(),
925+
module_path: "foo",
923926
source: "foo.just".into(),
924927
recipes: [(
925928
"bar",

0 commit comments

Comments
 (0)