Skip to content
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
4 changes: 2 additions & 2 deletions src/analyzer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ impl<'run, 'src> Analyzer<'run, 'src> {
pub(crate) fn analyze(
asts: &'run HashMap<PathBuf, Ast<'src>>,
doc: Option<String>,
groups: &[String],
groups: &[StringLiteral<'src>],
loaded: &[PathBuf],
name: Option<Name<'src>>,
paths: &HashMap<PathBuf, PathBuf>,
Expand All @@ -28,7 +28,7 @@ impl<'run, 'src> Analyzer<'run, 'src> {
mut self,
asts: &'run HashMap<PathBuf, Ast<'src>>,
doc: Option<String>,
groups: &[String],
groups: &[StringLiteral<'src>],
loaded: &[PathBuf],
name: Option<Name<'src>>,
paths: &HashMap<PathBuf, PathBuf>,
Expand Down
9 changes: 7 additions & 2 deletions src/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub(crate) enum Item<'src> {
Module {
absolute: Option<PathBuf>,
doc: Option<String>,
groups: Vec<String>,
groups: Vec<StringLiteral<'src>>,
name: Name<'src>,
optional: bool,
relative: Option<StringLiteral<'src>>,
Expand Down Expand Up @@ -45,11 +45,16 @@ impl Display for Item<'_> {
write!(f, " {relative}")
}
Self::Module {
groups,
name,
relative,
optional,
relative,
..
} => {
for group in groups {
writeln!(f, "[group: {group}]")?;
}

write!(f, "mod")?;

if *optional {
Expand Down
10 changes: 7 additions & 3 deletions src/justfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub(crate) struct Justfile<'src> {
#[serde(rename = "first", serialize_with = "keyed::serialize_option")]
pub(crate) default: Option<Arc<Recipe<'src>>>,
pub(crate) doc: Option<String>,
pub(crate) groups: Vec<String>,
pub(crate) groups: Vec<StringLiteral<'src>>,
#[serde(skip)]
pub(crate) loaded: Vec<PathBuf>,
#[serde(skip)]
Expand Down Expand Up @@ -468,8 +468,12 @@ impl<'src> Justfile<'src> {
recipes
}

pub(crate) fn groups(&self) -> &[String] {
&self.groups
pub(crate) fn groups(&self) -> Vec<&str> {
self
.groups
.iter()
.map(|group| group.cooked.as_str())
.collect()
}

pub(crate) fn public_groups(&self, config: &Config) -> Vec<String> {
Expand Down
2 changes: 1 addition & 1 deletion src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ impl<'run, 'src> Parser<'run, 'src> {
let mut groups = Vec::new();
for attribute in attributes {
if let Attribute::Group(group) = attribute {
groups.push(group.cooked);
groups.push(group);
}
}

Expand Down
22 changes: 22 additions & 0 deletions tests/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1589,3 +1589,25 @@ fn private_variable() {
)
.run();
}

#[test]
fn module_groups_are_preserved() {
Test::new()
.justfile(
r#"
[group('bar')]
[group("baz")]
mod foo
"#,
)
.write("foo.just", "")
.arg("--dump")
.stdout(
r#"
[group: 'bar']
[group: "baz"]
mod foo
"#,
)
.run();
}