Skip to content

Commit

Permalink
Add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Schottkyc137 committed Aug 8, 2024
1 parent 8c83469 commit 81377ab
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions vhdl_lang/src/data/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ impl SrcPos {
file_name.to_string_lossy(),
lineno + 1
)
.unwrap();
.unwrap();
for _ in 0..lineno_len {
result.push(' ');
}
Expand Down Expand Up @@ -524,7 +524,7 @@ impl<T: HasSrcPos> HasSource for T {

/// A wrapper around a PathBuf that ensures the path is absolute and simplified.
///
/// Related GitHub issues: #115, #327
/// This struct can be used similar to a [PathBuf], i.e., dereferencing it will return a [Path]
#[derive(PartialEq, Eq, Hash, Clone, Debug)]
pub(crate) struct FilePath(PathBuf);

Expand All @@ -537,12 +537,18 @@ impl std::ops::Deref for FilePath {

impl FilePath {
pub fn new(path: &Path) -> Self {
// In tests, when using inline files, paths are used that do not point to an existing file.
// In this case, we simply want to preserve the name without changing it.
if cfg!(test) && !path.exists() {
return Self(path.to_owned());
}
// Note: dunce::canonicalize instead of path::absolute together with
// dunce::simplified causes issues in #327
// It would also be possible to use dunce::canonicalize here instead of path::absolute
// and dunce::simplify, but dunce::canonicalize resolves symlinks
// which we don't want (see issue #327)
let path = match std::path::absolute(path) {
// dunce::simplified converts UNC paths to regular paths.
// UNC paths have caused issues when a file was mounted on a network drive.
// Related issue: #115
Ok(path) => dunce::simplified(&path).to_owned(),
Err(err) => {
eprintln!(
Expand Down

0 comments on commit 81377ab

Please sign in to comment.