Clean up RelPath API (#38912)
Consolidate constructors and accessors. Release Notes: - N/A --------- Co-authored-by: Cole Miller <cole@zed.dev>
This commit is contained in:
co-authored by
Cole Miller
parent
301e976465
commit
495a7b0a84
@@ -55,8 +55,8 @@ impl ContextProvider for JsonTaskProvider {
|
||||
let Some(file) = project::File::from_dyn(file.as_ref()).cloned() else {
|
||||
return Task::ready(None);
|
||||
};
|
||||
let is_package_json = file.path.ends_with(RelPath::new("package.json").unwrap());
|
||||
let is_composer_json = file.path.ends_with(RelPath::new("composer.json").unwrap());
|
||||
let is_package_json = file.path.ends_with(RelPath::unix("package.json").unwrap());
|
||||
let is_composer_json = file.path.ends_with(RelPath::unix("composer.json").unwrap());
|
||||
if !is_package_json && !is_composer_json {
|
||||
return Task::ready(None);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ impl ManifestProvider for PyprojectTomlManifestProvider {
|
||||
}: ManifestQuery,
|
||||
) -> Option<Arc<RelPath>> {
|
||||
for path in path.ancestors().take(depth) {
|
||||
let p = path.join(RelPath::new("pyproject.toml").unwrap());
|
||||
let p = path.join(RelPath::unix("pyproject.toml").unwrap());
|
||||
if delegate.exists(&p, Some(false)) {
|
||||
return Some(path.into());
|
||||
}
|
||||
@@ -1030,7 +1030,7 @@ impl ToolchainLister for PythonToolchainProvider {
|
||||
config.workspace_directories = Some(
|
||||
subroot_relative_path
|
||||
.ancestors()
|
||||
.map(|ancestor| worktree_root.join(ancestor))
|
||||
.map(|ancestor| worktree_root.join(ancestor.as_std_path()))
|
||||
.collect(),
|
||||
);
|
||||
for locator in locators.iter() {
|
||||
|
||||
@@ -92,7 +92,7 @@ impl ManifestProvider for CargoManifestProvider {
|
||||
) -> Option<Arc<RelPath>> {
|
||||
let mut outermost_cargo_toml = None;
|
||||
for path in path.ancestors().take(depth) {
|
||||
let p = path.join(RelPath::new("Cargo.toml").unwrap());
|
||||
let p = path.join(RelPath::unix("Cargo.toml").unwrap());
|
||||
if delegate.exists(&p, Some(false)) {
|
||||
outermost_cargo_toml = Some(Arc::from(path));
|
||||
}
|
||||
|
||||
@@ -269,7 +269,7 @@ impl TypeScriptContextProvider {
|
||||
) -> Task<anyhow::Result<PackageJsonData>> {
|
||||
let new_json_data = file_relative_path
|
||||
.ancestors()
|
||||
.map(|path| worktree_root.join(path))
|
||||
.map(|path| worktree_root.join(path.as_std_path()))
|
||||
.map(|parent_path| {
|
||||
self.package_json_data(&parent_path, self.last_package_json.clone(), fs.clone(), cx)
|
||||
})
|
||||
@@ -533,7 +533,7 @@ impl TypeScriptLspAdapter {
|
||||
}
|
||||
async fn tsdk_path(&self, adapter: &Arc<dyn LspAdapterDelegate>) -> Option<&'static str> {
|
||||
let is_yarn = adapter
|
||||
.read_text_file(RelPath::new(".yarn/sdks/typescript/lib/typescript.js").unwrap())
|
||||
.read_text_file(RelPath::unix(".yarn/sdks/typescript/lib/typescript.js").unwrap())
|
||||
.await
|
||||
.is_ok();
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ impl VtslsLspAdapter {
|
||||
|
||||
async fn tsdk_path(&self, adapter: &Arc<dyn LspAdapterDelegate>) -> Option<&'static str> {
|
||||
let is_yarn = adapter
|
||||
.read_text_file(RelPath::new(".yarn/sdks/typescript/lib/typescript.js").unwrap())
|
||||
.read_text_file(RelPath::unix(".yarn/sdks/typescript/lib/typescript.js").unwrap())
|
||||
.await
|
||||
.is_ok();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user