aboutsummaryrefslogtreecommitdiff
path: root/crates/hir
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-10-12 08:38:24 +0100
committerGitHub <[email protected]>2020-10-12 08:38:24 +0100
commit518f6d772482c7c58e59081f340947087a9b4800 (patch)
treed904f1b98cad63944b4c405238d8b3938a9debb9 /crates/hir
parentd5fcedb38eec33e2eb12ed550a9b90f6950855fe (diff)
parent3bd4fe96dce17eb2bff380389b24ea325bf54803 (diff)
Merge #5917
5917: Add a command to open docs for the symbol under the cursor r=matklad a=zacps #### Todo - [ ] Decide if there should be a default keybind or context menu entry - [x] Figure out how to get the documentation path for methods and other non-top-level defs - [x] Design the protocol extension. In future we'll probably want parameters for local/remote documentation URLs, so that should maybe be done in this PR? - [x] Code organisation - [x] Tests Co-authored-by: Zac Pullar-Strecker <[email protected]>
Diffstat (limited to 'crates/hir')
-rw-r--r--crates/hir/src/code_model.rs17
1 files changed, 17 insertions, 0 deletions
diff --git a/crates/hir/src/code_model.rs b/crates/hir/src/code_model.rs
index 031c91ccf..650b4fa40 100644
--- a/crates/hir/src/code_model.rs
+++ b/crates/hir/src/code_model.rs
@@ -186,6 +186,16 @@ impl_from!(
186 for ModuleDef 186 for ModuleDef
187); 187);
188 188
189impl From<VariantDef> for ModuleDef {
190 fn from(var: VariantDef) -> Self {
191 match var {
192 VariantDef::Struct(t) => Adt::from(t).into(),
193 VariantDef::Union(t) => Adt::from(t).into(),
194 VariantDef::EnumVariant(t) => t.into(),
195 }
196 }
197}
198
189impl ModuleDef { 199impl ModuleDef {
190 pub fn module(self, db: &dyn HirDatabase) -> Option<Module> { 200 pub fn module(self, db: &dyn HirDatabase) -> Option<Module> {
191 match self { 201 match self {
@@ -752,6 +762,13 @@ impl Function {
752 pub fn diagnostics(self, db: &dyn HirDatabase, sink: &mut DiagnosticSink) { 762 pub fn diagnostics(self, db: &dyn HirDatabase, sink: &mut DiagnosticSink) {
753 hir_ty::diagnostics::validate_body(db, self.id.into(), sink) 763 hir_ty::diagnostics::validate_body(db, self.id.into(), sink)
754 } 764 }
765
766 /// Whether this function declaration has a definition.
767 ///
768 /// This is false in the case of required (not provided) trait methods.
769 pub fn has_body(self, db: &dyn HirDatabase) -> bool {
770 db.function_data(self.id).has_body
771 }
755} 772}
756 773
757// Note: logically, this belongs to `hir_ty`, but we are not using it there yet. 774// Note: logically, this belongs to `hir_ty`, but we are not using it there yet.