Skip to main content

renamed_unit_name

Function renamed_unit_name 

Source
pub fn renamed_unit_name(
    old_rel: &Path,
    old_name: &str,
    new_rel: &Path,
) -> Option<String>
Expand description

#302: the qualified name a file moved from old_rel to new_rel should now declare, preserving whichever unit_path_matches arrangement old_rel used to satisfy against old_name — the dotted stem for a single-file unit, or the dotted parent-directory for one file of a multi-file unit. Returns None if old_rel/old_name don’t actually satisfy either arrangement (a pre-existing inconsistency the caller should not guess at).

old_name is matched as a suffix of old_rel’s stem/parent, not the whole thing: the LSP’s caller passes project-relative paths, which (unlike the source_path unit_path_matches itself is checked against) still carry a leading include-root segment (e.g. src/) that the qualified name never mentions. Whatever prefix length that suffix match implies for old_rel is applied unchanged to new_rel — correct as long as the file stays under the same include root, which a rename/move normally does.