Skip to content

Commit

Permalink
Add function to store HeaderLine info
Browse files Browse the repository at this point in the history
Signed-off-by: Muhammad Mahad <mahadtxt@gmail.com>
  • Loading branch information
MahadMuhammad committed Aug 17, 2024
1 parent 4366f65 commit 558865a
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,25 @@ pub struct HeaderLine<'ln> {
}


fn add_additional_options(code: &str, line_number: usize) -> Option<HeaderLine> {
//TODO: If we know the file extension, then update this to
// let comment = if testfile.extension().is_some_and(|e| e == "rs") { "//@" } else { "#" };
let comment = "//@";

if let Some((_header_revision, non_revisioned_directive_line)) = line_directive(comment, code) {
// The non_revisioned_directive_line is the directive without the "//@" prefix
let edition = parse_edition(non_revisioned_directive_line);
edition.as_ref()?;
Some(HeaderLine {
line_number: line_number + 1, // 1 based-indexed instead of zero based
_directive: "edition",
dejagnu_header: to_dejagnu_edition(edition.unwrap().as_str()),
})
} else {
None
}
}

fn line_directive<'line>(
comment: &str,
original_line: &'line str,
Expand Down

0 comments on commit 558865a

Please sign in to comment.