Skip to content

Commit 23add4d

Browse files
committed
Reuse oak_core's is_r_file()
1 parent c013d13 commit 23add4d

5 files changed

Lines changed: 12 additions & 7 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/oak_core/src/file.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
use std::path::Path;
22
use std::path::PathBuf;
33

4+
/// Does this path's name look like an R file (`.R` / `.r` extension)?
5+
///
6+
/// Pure name test, no I/O. It doesn't touch the filesystem, so it says
7+
/// nothing about whether the path exists or is a regular file. A
8+
/// directory named `foo.R` passes, and so does a path that isn't on disk
9+
/// at all. Callers that walk a real directory and want to skip such cases
10+
/// must check `path.is_file()` themselves.
411
pub fn is_r_file(path: &Path) -> bool {
512
path.extension()
613
.and_then(|e| e.to_str())

crates/oak_core/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@ pub mod file;
33
pub mod identifier;
44
pub mod range;
55
pub mod syntax_ext;
6+
7+
pub use file::is_r_file;

crates/oak_scan/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ workspace = true
1818
[dependencies]
1919
aether_url.workspace = true
2020
log.workspace = true
21+
oak_core.workspace = true
2122
oak_db.workspace = true
2223
oak_package_metadata.workspace = true
2324
salsa.workspace = true

crates/oak_scan/src/packages.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,5 @@ fn scan_r_files(r_dir: &Path) -> Vec<FileEntry> {
107107
}
108108

109109
fn is_r_file(path: &Path) -> bool {
110-
if !path.is_file() {
111-
return false;
112-
}
113-
let Some(ext) = path.extension() else {
114-
return false;
115-
};
116-
ext.eq_ignore_ascii_case("r")
110+
path.is_file() && oak_core::is_r_file(path)
117111
}

0 commit comments

Comments
 (0)