mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-11-10 15:14:32 +00:00
Rename resolve_relative_path -> resolve_path
For things like `concant!(env!("OUT_DIR"))`, we need to support abs paths
This commit is contained in:
parent
f98d057218
commit
e63c00f100
7 changed files with 12 additions and 33 deletions
|
@ -89,8 +89,7 @@ pub const DEFAULT_LRU_CAP: usize = 128;
|
|||
pub trait FileLoader {
|
||||
/// Text of the file.
|
||||
fn file_text(&self, file_id: FileId) -> Arc<String>;
|
||||
fn resolve_relative_path(&self, anchor: FileId, relative_path: &RelativePath)
|
||||
-> Option<FileId>;
|
||||
fn resolve_path(&self, anchor: FileId, relative_path: &RelativePath) -> Option<FileId>;
|
||||
fn relevant_crates(&self, file_id: FileId) -> Arc<Vec<CrateId>>;
|
||||
|
||||
fn resolve_extern_path(
|
||||
|
@ -155,11 +154,7 @@ impl<T: SourceDatabaseExt> FileLoader for FileLoaderDelegate<&'_ T> {
|
|||
fn file_text(&self, file_id: FileId) -> Arc<String> {
|
||||
SourceDatabaseExt::file_text(self.0, file_id)
|
||||
}
|
||||
fn resolve_relative_path(
|
||||
&self,
|
||||
anchor: FileId,
|
||||
relative_path: &RelativePath,
|
||||
) -> Option<FileId> {
|
||||
fn resolve_path(&self, anchor: FileId, relative_path: &RelativePath) -> Option<FileId> {
|
||||
let path = {
|
||||
let mut path = self.0.file_relative_path(anchor);
|
||||
assert!(path.pop());
|
||||
|
|
|
@ -61,7 +61,7 @@ impl ModDir {
|
|||
};
|
||||
|
||||
for candidate in candidate_files.iter() {
|
||||
if let Some(file_id) = db.resolve_relative_path(file_id, candidate) {
|
||||
if let Some(file_id) = db.resolve_path(file_id, candidate) {
|
||||
let mut root_non_dir_owner = false;
|
||||
let mut mod_path = RelativePathBuf::new();
|
||||
if !(candidate.ends_with("mod.rs") || attr_path.is_some()) {
|
||||
|
|
|
@ -58,12 +58,8 @@ impl FileLoader for TestDB {
|
|||
fn file_text(&self, file_id: FileId) -> Arc<String> {
|
||||
FileLoaderDelegate(self).file_text(file_id)
|
||||
}
|
||||
fn resolve_relative_path(
|
||||
&self,
|
||||
anchor: FileId,
|
||||
relative_path: &RelativePath,
|
||||
) -> Option<FileId> {
|
||||
FileLoaderDelegate(self).resolve_relative_path(anchor, relative_path)
|
||||
fn resolve_path(&self, anchor: FileId, relative_path: &RelativePath) -> Option<FileId> {
|
||||
FileLoaderDelegate(self).resolve_path(anchor, relative_path)
|
||||
}
|
||||
fn relevant_crates(&self, file_id: FileId) -> Arc<Vec<CrateId>> {
|
||||
FileLoaderDelegate(self).relevant_crates(file_id)
|
||||
|
|
|
@ -297,7 +297,7 @@ fn relative_file(db: &dyn AstDatabase, call_id: MacroCallId, path: &str) -> Opti
|
|||
let call_site = call_id.as_file().original_file(db);
|
||||
|
||||
// Handle trivial case
|
||||
if let Some(res) = db.resolve_relative_path(call_site, &RelativePath::new(&path)) {
|
||||
if let Some(res) = db.resolve_path(call_site, &RelativePath::new(&path)) {
|
||||
// Prevent include itself
|
||||
return if res == call_site { None } else { Some(res) };
|
||||
}
|
||||
|
|
|
@ -41,12 +41,8 @@ impl FileLoader for TestDB {
|
|||
fn file_text(&self, file_id: FileId) -> Arc<String> {
|
||||
FileLoaderDelegate(self).file_text(file_id)
|
||||
}
|
||||
fn resolve_relative_path(
|
||||
&self,
|
||||
anchor: FileId,
|
||||
relative_path: &RelativePath,
|
||||
) -> Option<FileId> {
|
||||
FileLoaderDelegate(self).resolve_relative_path(anchor, relative_path)
|
||||
fn resolve_path(&self, anchor: FileId, relative_path: &RelativePath) -> Option<FileId> {
|
||||
FileLoaderDelegate(self).resolve_path(anchor, relative_path)
|
||||
}
|
||||
fn relevant_crates(&self, file_id: FileId) -> Arc<Vec<CrateId>> {
|
||||
FileLoaderDelegate(self).relevant_crates(file_id)
|
||||
|
|
|
@ -72,12 +72,8 @@ impl FileLoader for TestDB {
|
|||
fn file_text(&self, file_id: FileId) -> Arc<String> {
|
||||
FileLoaderDelegate(self).file_text(file_id)
|
||||
}
|
||||
fn resolve_relative_path(
|
||||
&self,
|
||||
anchor: FileId,
|
||||
relative_path: &RelativePath,
|
||||
) -> Option<FileId> {
|
||||
FileLoaderDelegate(self).resolve_relative_path(anchor, relative_path)
|
||||
fn resolve_path(&self, anchor: FileId, relative_path: &RelativePath) -> Option<FileId> {
|
||||
FileLoaderDelegate(self).resolve_path(anchor, relative_path)
|
||||
}
|
||||
fn relevant_crates(&self, file_id: FileId) -> Arc<Vec<CrateId>> {
|
||||
FileLoaderDelegate(self).relevant_crates(file_id)
|
||||
|
|
|
@ -57,12 +57,8 @@ impl FileLoader for RootDatabase {
|
|||
fn file_text(&self, file_id: FileId) -> Arc<String> {
|
||||
FileLoaderDelegate(self).file_text(file_id)
|
||||
}
|
||||
fn resolve_relative_path(
|
||||
&self,
|
||||
anchor: FileId,
|
||||
relative_path: &RelativePath,
|
||||
) -> Option<FileId> {
|
||||
FileLoaderDelegate(self).resolve_relative_path(anchor, relative_path)
|
||||
fn resolve_path(&self, anchor: FileId, relative_path: &RelativePath) -> Option<FileId> {
|
||||
FileLoaderDelegate(self).resolve_path(anchor, relative_path)
|
||||
}
|
||||
fn relevant_crates(&self, file_id: FileId) -> Arc<Vec<CrateId>> {
|
||||
FileLoaderDelegate(self).relevant_crates(file_id)
|
||||
|
|
Loading…
Reference in a new issue