aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-06-05 13:55:23 +0100
committerAleksey Kladov <[email protected]>2020-06-05 13:58:30 +0100
commite63c00f100e960f7b72997026b4b2cd3cd29774b (patch)
treef789502d1e45282980e1eb8bfa1f5e96f45636b9 /crates
parentf98d057218ca30d052da2a119fa0b3108ba3a091 (diff)
Rename resolve_relative_path -> resolve_path
For things like `concant!(env!("OUT_DIR"))`, we need to support abs paths
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_db/src/lib.rs9
-rw-r--r--crates/ra_hir_def/src/nameres/mod_resolution.rs2
-rw-r--r--crates/ra_hir_def/src/test_db.rs8
-rw-r--r--crates/ra_hir_expand/src/builtin_macro.rs2
-rw-r--r--crates/ra_hir_expand/src/test_db.rs8
-rw-r--r--crates/ra_hir_ty/src/test_db.rs8
-rw-r--r--crates/ra_ide_db/src/lib.rs8
7 files changed, 12 insertions, 33 deletions
diff --git a/crates/ra_db/src/lib.rs b/crates/ra_db/src/lib.rs
index fd4280de2..07e1b8aba 100644
--- a/crates/ra_db/src/lib.rs
+++ b/crates/ra_db/src/lib.rs
@@ -89,8 +89,7 @@ pub const DEFAULT_LRU_CAP: usize = 128;
89pub trait FileLoader { 89pub trait FileLoader {
90 /// Text of the file. 90 /// Text of the file.
91 fn file_text(&self, file_id: FileId) -> Arc<String>; 91 fn file_text(&self, file_id: FileId) -> Arc<String>;
92 fn resolve_relative_path(&self, anchor: FileId, relative_path: &RelativePath) 92 fn resolve_path(&self, anchor: FileId, relative_path: &RelativePath) -> Option<FileId>;
93 -> Option<FileId>;
94 fn relevant_crates(&self, file_id: FileId) -> Arc<Vec<CrateId>>; 93 fn relevant_crates(&self, file_id: FileId) -> Arc<Vec<CrateId>>;
95 94
96 fn resolve_extern_path( 95 fn resolve_extern_path(
@@ -155,11 +154,7 @@ impl<T: SourceDatabaseExt> FileLoader for FileLoaderDelegate<&'_ T> {
155 fn file_text(&self, file_id: FileId) -> Arc<String> { 154 fn file_text(&self, file_id: FileId) -> Arc<String> {
156 SourceDatabaseExt::file_text(self.0, file_id) 155 SourceDatabaseExt::file_text(self.0, file_id)
157 } 156 }
158 fn resolve_relative_path( 157 fn resolve_path(&self, anchor: FileId, relative_path: &RelativePath) -> Option<FileId> {
159 &self,
160 anchor: FileId,
161 relative_path: &RelativePath,
162 ) -> Option<FileId> {
163 let path = { 158 let path = {
164 let mut path = self.0.file_relative_path(anchor); 159 let mut path = self.0.file_relative_path(anchor);
165 assert!(path.pop()); 160 assert!(path.pop());
diff --git a/crates/ra_hir_def/src/nameres/mod_resolution.rs b/crates/ra_hir_def/src/nameres/mod_resolution.rs
index 386c5cade..7af922c21 100644
--- a/crates/ra_hir_def/src/nameres/mod_resolution.rs
+++ b/crates/ra_hir_def/src/nameres/mod_resolution.rs
@@ -61,7 +61,7 @@ impl ModDir {
61 }; 61 };
62 62
63 for candidate in candidate_files.iter() { 63 for candidate in candidate_files.iter() {
64 if let Some(file_id) = db.resolve_relative_path(file_id, candidate) { 64 if let Some(file_id) = db.resolve_path(file_id, candidate) {
65 let mut root_non_dir_owner = false; 65 let mut root_non_dir_owner = false;
66 let mut mod_path = RelativePathBuf::new(); 66 let mut mod_path = RelativePathBuf::new();
67 if !(candidate.ends_with("mod.rs") || attr_path.is_some()) { 67 if !(candidate.ends_with("mod.rs") || attr_path.is_some()) {
diff --git a/crates/ra_hir_def/src/test_db.rs b/crates/ra_hir_def/src/test_db.rs
index eb83dee79..d33b57c93 100644
--- a/crates/ra_hir_def/src/test_db.rs
+++ b/crates/ra_hir_def/src/test_db.rs
@@ -58,12 +58,8 @@ impl FileLoader for TestDB {
58 fn file_text(&self, file_id: FileId) -> Arc<String> { 58 fn file_text(&self, file_id: FileId) -> Arc<String> {
59 FileLoaderDelegate(self).file_text(file_id) 59 FileLoaderDelegate(self).file_text(file_id)
60 } 60 }
61 fn resolve_relative_path( 61 fn resolve_path(&self, anchor: FileId, relative_path: &RelativePath) -> Option<FileId> {
62 &self, 62 FileLoaderDelegate(self).resolve_path(anchor, relative_path)
63 anchor: FileId,
64 relative_path: &RelativePath,
65 ) -> Option<FileId> {
66 FileLoaderDelegate(self).resolve_relative_path(anchor, relative_path)
67 } 63 }
68 fn relevant_crates(&self, file_id: FileId) -> Arc<Vec<CrateId>> { 64 fn relevant_crates(&self, file_id: FileId) -> Arc<Vec<CrateId>> {
69 FileLoaderDelegate(self).relevant_crates(file_id) 65 FileLoaderDelegate(self).relevant_crates(file_id)
diff --git a/crates/ra_hir_expand/src/builtin_macro.rs b/crates/ra_hir_expand/src/builtin_macro.rs
index 3bce8f673..4374d9eda 100644
--- a/crates/ra_hir_expand/src/builtin_macro.rs
+++ b/crates/ra_hir_expand/src/builtin_macro.rs
@@ -297,7 +297,7 @@ fn relative_file(db: &dyn AstDatabase, call_id: MacroCallId, path: &str) -> Opti
297 let call_site = call_id.as_file().original_file(db); 297 let call_site = call_id.as_file().original_file(db);
298 298
299 // Handle trivial case 299 // Handle trivial case
300 if let Some(res) = db.resolve_relative_path(call_site, &RelativePath::new(&path)) { 300 if let Some(res) = db.resolve_path(call_site, &RelativePath::new(&path)) {
301 // Prevent include itself 301 // Prevent include itself
302 return if res == call_site { None } else { Some(res) }; 302 return if res == call_site { None } else { Some(res) };
303 } 303 }
diff --git a/crates/ra_hir_expand/src/test_db.rs b/crates/ra_hir_expand/src/test_db.rs
index c1fb762de..60321fa0a 100644
--- a/crates/ra_hir_expand/src/test_db.rs
+++ b/crates/ra_hir_expand/src/test_db.rs
@@ -41,12 +41,8 @@ impl FileLoader for TestDB {
41 fn file_text(&self, file_id: FileId) -> Arc<String> { 41 fn file_text(&self, file_id: FileId) -> Arc<String> {
42 FileLoaderDelegate(self).file_text(file_id) 42 FileLoaderDelegate(self).file_text(file_id)
43 } 43 }
44 fn resolve_relative_path( 44 fn resolve_path(&self, anchor: FileId, relative_path: &RelativePath) -> Option<FileId> {
45 &self, 45 FileLoaderDelegate(self).resolve_path(anchor, relative_path)
46 anchor: FileId,
47 relative_path: &RelativePath,
48 ) -> Option<FileId> {
49 FileLoaderDelegate(self).resolve_relative_path(anchor, relative_path)
50 } 46 }
51 fn relevant_crates(&self, file_id: FileId) -> Arc<Vec<CrateId>> { 47 fn relevant_crates(&self, file_id: FileId) -> Arc<Vec<CrateId>> {
52 FileLoaderDelegate(self).relevant_crates(file_id) 48 FileLoaderDelegate(self).relevant_crates(file_id)
diff --git a/crates/ra_hir_ty/src/test_db.rs b/crates/ra_hir_ty/src/test_db.rs
index 8498d3d96..43927c991 100644
--- a/crates/ra_hir_ty/src/test_db.rs
+++ b/crates/ra_hir_ty/src/test_db.rs
@@ -72,12 +72,8 @@ impl FileLoader for TestDB {
72 fn file_text(&self, file_id: FileId) -> Arc<String> { 72 fn file_text(&self, file_id: FileId) -> Arc<String> {
73 FileLoaderDelegate(self).file_text(file_id) 73 FileLoaderDelegate(self).file_text(file_id)
74 } 74 }
75 fn resolve_relative_path( 75 fn resolve_path(&self, anchor: FileId, relative_path: &RelativePath) -> Option<FileId> {
76 &self, 76 FileLoaderDelegate(self).resolve_path(anchor, relative_path)
77 anchor: FileId,
78 relative_path: &RelativePath,
79 ) -> Option<FileId> {
80 FileLoaderDelegate(self).resolve_relative_path(anchor, relative_path)
81 } 77 }
82 fn relevant_crates(&self, file_id: FileId) -> Arc<Vec<CrateId>> { 78 fn relevant_crates(&self, file_id: FileId) -> Arc<Vec<CrateId>> {
83 FileLoaderDelegate(self).relevant_crates(file_id) 79 FileLoaderDelegate(self).relevant_crates(file_id)
diff --git a/crates/ra_ide_db/src/lib.rs b/crates/ra_ide_db/src/lib.rs
index 1b74e6558..72793d63d 100644
--- a/crates/ra_ide_db/src/lib.rs
+++ b/crates/ra_ide_db/src/lib.rs
@@ -57,12 +57,8 @@ impl FileLoader for RootDatabase {
57 fn file_text(&self, file_id: FileId) -> Arc<String> { 57 fn file_text(&self, file_id: FileId) -> Arc<String> {
58 FileLoaderDelegate(self).file_text(file_id) 58 FileLoaderDelegate(self).file_text(file_id)
59 } 59 }
60 fn resolve_relative_path( 60 fn resolve_path(&self, anchor: FileId, relative_path: &RelativePath) -> Option<FileId> {
61 &self, 61 FileLoaderDelegate(self).resolve_path(anchor, relative_path)
62 anchor: FileId,
63 relative_path: &RelativePath,
64 ) -> Option<FileId> {
65 FileLoaderDelegate(self).resolve_relative_path(anchor, relative_path)
66 } 62 }
67 fn relevant_crates(&self, file_id: FileId) -> Arc<Vec<CrateId>> { 63 fn relevant_crates(&self, file_id: FileId) -> Arc<Vec<CrateId>> {
68 FileLoaderDelegate(self).relevant_crates(file_id) 64 FileLoaderDelegate(self).relevant_crates(file_id)