diff options
Diffstat (limited to 'crates/ra_hir/src/code_model_api.rs')
-rw-r--r-- | crates/ra_hir/src/code_model_api.rs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/crates/ra_hir/src/code_model_api.rs b/crates/ra_hir/src/code_model_api.rs index 94a08aa63..fb7ad0867 100644 --- a/crates/ra_hir/src/code_model_api.rs +++ b/crates/ra_hir/src/code_model_api.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | use std::sync::Arc; | 1 | use std::sync::Arc; |
2 | 2 | ||
3 | use relative_path::RelativePathBuf; | 3 | use relative_path::RelativePathBuf; |
4 | use ra_db::{CrateId, FileId, SourceRootId}; | 4 | use ra_db::{CrateId, FileId, SourceRootId, Edition}; |
5 | use ra_syntax::{ast::self, TreeArc, SyntaxNode}; | 5 | use ra_syntax::{ast::self, TreeArc, SyntaxNode}; |
6 | 6 | ||
7 | use crate::{ | 7 | use crate::{ |
@@ -38,13 +38,20 @@ impl Crate { | |||
38 | pub fn crate_id(&self) -> CrateId { | 38 | pub fn crate_id(&self) -> CrateId { |
39 | self.crate_id | 39 | self.crate_id |
40 | } | 40 | } |
41 | |||
41 | pub fn dependencies(&self, db: &impl PersistentHirDatabase) -> Vec<CrateDependency> { | 42 | pub fn dependencies(&self, db: &impl PersistentHirDatabase) -> Vec<CrateDependency> { |
42 | self.dependencies_impl(db) | 43 | self.dependencies_impl(db) |
43 | } | 44 | } |
45 | |||
44 | pub fn root_module(&self, db: &impl PersistentHirDatabase) -> Option<Module> { | 46 | pub fn root_module(&self, db: &impl PersistentHirDatabase) -> Option<Module> { |
45 | self.root_module_impl(db) | 47 | self.root_module_impl(db) |
46 | } | 48 | } |
47 | 49 | ||
50 | pub fn edition(&self, db: &impl PersistentHirDatabase) -> Edition { | ||
51 | let crate_graph = db.crate_graph(); | ||
52 | crate_graph.edition(self.crate_id) | ||
53 | } | ||
54 | |||
48 | // TODO: should this be in source_binder? | 55 | // TODO: should this be in source_binder? |
49 | pub fn source_root_crates( | 56 | pub fn source_root_crates( |
50 | db: &impl PersistentHirDatabase, | 57 | db: &impl PersistentHirDatabase, |
@@ -134,7 +141,7 @@ impl Module { | |||
134 | 141 | ||
135 | /// Topmost parent of this module. Every module has a `crate_root`, but some | 142 | /// Topmost parent of this module. Every module has a `crate_root`, but some |
136 | /// might be missing `krate`. This can happen if a module's file is not included | 143 | /// might be missing `krate`. This can happen if a module's file is not included |
137 | /// in the module tree of any target in Cargo.toml. | 144 | /// in the module tree of any target in `Cargo.toml`. |
138 | pub fn crate_root(&self, db: &impl PersistentHirDatabase) -> Module { | 145 | pub fn crate_root(&self, db: &impl PersistentHirDatabase) -> Module { |
139 | self.crate_root_impl(db) | 146 | self.crate_root_impl(db) |
140 | } | 147 | } |
@@ -351,7 +358,7 @@ impl Enum { | |||
351 | db.type_for_def((*self).into()) | 358 | db.type_for_def((*self).into()) |
352 | } | 359 | } |
353 | 360 | ||
354 | // TODO move to a more general type | 361 | // TODO: move to a more general type |
355 | /// Builds a resolver for type references inside this struct. | 362 | /// Builds a resolver for type references inside this struct. |
356 | pub fn resolver(&self, db: &impl HirDatabase) -> Resolver { | 363 | pub fn resolver(&self, db: &impl HirDatabase) -> Resolver { |
357 | // take the outer scope... | 364 | // take the outer scope... |
@@ -495,7 +502,7 @@ impl Function { | |||
495 | db.generic_params((*self).into()) | 502 | db.generic_params((*self).into()) |
496 | } | 503 | } |
497 | 504 | ||
498 | // TODO move to a more general type for 'body-having' items | 505 | // TODO: move to a more general type for 'body-having' items |
499 | /// Builds a resolver for code inside this item. | 506 | /// Builds a resolver for code inside this item. |
500 | pub fn resolver(&self, db: &impl HirDatabase) -> Resolver { | 507 | pub fn resolver(&self, db: &impl HirDatabase) -> Resolver { |
501 | // take the outer scope... | 508 | // take the outer scope... |