Skip to main content

path_to_module_path

Function path_to_module_path 

Source
pub fn path_to_module_path(file: &Path, workspace_root: &Path) -> Option<String>
Expand description

W2.7 willRenameFiles helper — derive the canonical Shape from module path (a::b::c) for a .shape file relative to the workspace root.

Returns None when the file is outside the workspace root, has no .shape extension, or contains a path segment that is not a valid Shape identifier (e.g. starts with a digit, contains -). The latter is conservative — files that cannot be imported by any Shape from clause produce no rewrite edits.

Examples (workspace root = /ws):

  • /ws/foo.shape → Some("foo")
  • /ws/lib/util.shape → Some("lib::util")
  • /ws/src/sub/mod.shape → Some("src::sub::mod")
  • /ws/2bad.shape → None (leading digit)
  • /other/foo.shape → None (outside workspace)