diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 22 | ||||
-rw-r--r-- | crates/ra_ide/src/hover.rs | 11 | ||||
-rw-r--r-- | crates/ra_ide_db/src/defs.rs | 11 | ||||
-rw-r--r-- | crates/ra_syntax/src/lib.rs | 2 | ||||
-rw-r--r-- | crates/rust-analyzer/src/handlers.rs | 2 |
5 files changed, 27 insertions, 21 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 5766cc3b8..839eb475e 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -192,11 +192,11 @@ impl ModuleDef { | |||
192 | ModuleDef::Function(m) => Some(m.name(db)), | 192 | ModuleDef::Function(m) => Some(m.name(db)), |
193 | ModuleDef::Adt(m) => Some(m.name(db)), | 193 | ModuleDef::Adt(m) => Some(m.name(db)), |
194 | ModuleDef::EnumVariant(m) => Some(m.name(db)), | 194 | ModuleDef::EnumVariant(m) => Some(m.name(db)), |
195 | ModuleDef::Const(m) => {m.name(db)}, | 195 | ModuleDef::Const(m) => m.name(db), |
196 | ModuleDef::Static(m) => {m.name(db)}, | 196 | ModuleDef::Static(m) => m.name(db), |
197 | ModuleDef::Trait(m) => {Some(m.name(db))}, | 197 | ModuleDef::Trait(m) => Some(m.name(db)), |
198 | ModuleDef::TypeAlias(m) => {Some(m.name(db))}, | 198 | ModuleDef::TypeAlias(m) => Some(m.name(db)), |
199 | ModuleDef::BuiltinType(m) => {Some(m.as_name())} | 199 | ModuleDef::BuiltinType(m) => Some(m.as_name()), |
200 | } | 200 | } |
201 | } | 201 | } |
202 | 202 | ||
@@ -205,13 +205,17 @@ impl ModuleDef { | |||
205 | ModuleDef::Module(m) => Into::<ModuleId>::into(m.clone()).resolver(db), | 205 | ModuleDef::Module(m) => Into::<ModuleId>::into(m.clone()).resolver(db), |
206 | ModuleDef::Function(f) => Into::<FunctionId>::into(f.clone()).resolver(db), | 206 | ModuleDef::Function(f) => Into::<FunctionId>::into(f.clone()).resolver(db), |
207 | ModuleDef::Adt(adt) => Into::<AdtId>::into(adt.clone()).resolver(db), | 207 | ModuleDef::Adt(adt) => Into::<AdtId>::into(adt.clone()).resolver(db), |
208 | ModuleDef::EnumVariant(ev) => Into::<GenericDefId>::into(Into::<GenericDef>::into(ev.clone())).resolver(db), | 208 | ModuleDef::EnumVariant(ev) => { |
209 | ModuleDef::Const(c) => Into::<GenericDefId>::into(Into::<GenericDef>::into(c.clone())).resolver(db), | 209 | Into::<GenericDefId>::into(Into::<GenericDef>::into(ev.clone())).resolver(db) |
210 | } | ||
211 | ModuleDef::Const(c) => { | ||
212 | Into::<GenericDefId>::into(Into::<GenericDef>::into(c.clone())).resolver(db) | ||
213 | } | ||
210 | ModuleDef::Static(s) => Into::<StaticId>::into(s.clone()).resolver(db), | 214 | ModuleDef::Static(s) => Into::<StaticId>::into(s.clone()).resolver(db), |
211 | ModuleDef::Trait(t) => Into::<TraitId>::into(t.clone()).resolver(db), | 215 | ModuleDef::Trait(t) => Into::<TraitId>::into(t.clone()).resolver(db), |
212 | ModuleDef::TypeAlias(t) => Into::<ModuleId>::into(t.module(db)).resolver(db), | 216 | ModuleDef::TypeAlias(t) => Into::<ModuleId>::into(t.module(db)).resolver(db), |
213 | // TODO: This should be a resolver relative to `std` | 217 | // FIXME: This should be a resolver relative to `std/core` |
214 | ModuleDef::BuiltinType(_t) => None? | 218 | ModuleDef::BuiltinType(_t) => None?, |
215 | }) | 219 | }) |
216 | } | 220 | } |
217 | } | 221 | } |
diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs index 9f8ab4795..185139250 100644 --- a/crates/ra_ide/src/hover.rs +++ b/crates/ra_ide/src/hover.rs | |||
@@ -540,14 +540,14 @@ fn try_resolve_intra( | |||
540 | 540 | ||
541 | let resolved = resolver.resolve_module_path_in_items(db, &modpath); | 541 | let resolved = resolver.resolve_module_path_in_items(db, &modpath); |
542 | let (defid, namespace) = match namespace { | 542 | let (defid, namespace) = match namespace { |
543 | // TODO: .or(resolved.macros) | 543 | // FIXME: .or(resolved.macros) |
544 | None => resolved | 544 | None => resolved |
545 | .types | 545 | .types |
546 | .map(|t| (t.0, Namespace::Types)) | 546 | .map(|t| (t.0, Namespace::Types)) |
547 | .or(resolved.values.map(|t| (t.0, Namespace::Values)))?, | 547 | .or(resolved.values.map(|t| (t.0, Namespace::Values)))?, |
548 | Some(ns @ Namespace::Types) => (resolved.types?.0, ns), | 548 | Some(ns @ Namespace::Types) => (resolved.types?.0, ns), |
549 | Some(ns @ Namespace::Values) => (resolved.values?.0, ns), | 549 | Some(ns @ Namespace::Values) => (resolved.values?.0, ns), |
550 | // TODO: | 550 | // FIXME: |
551 | Some(Namespace::Macros) => None?, | 551 | Some(Namespace::Macros) => None?, |
552 | }; | 552 | }; |
553 | 553 | ||
@@ -558,7 +558,7 @@ fn try_resolve_intra( | |||
558 | let ns = match namespace { | 558 | let ns = match namespace { |
559 | Namespace::Types => ItemInNs::Types(defid), | 559 | Namespace::Types => ItemInNs::Types(defid), |
560 | Namespace::Values => ItemInNs::Values(defid), | 560 | Namespace::Values => ItemInNs::Values(defid), |
561 | // TODO: | 561 | // FIXME: |
562 | Namespace::Macros => None?, | 562 | Namespace::Macros => None?, |
563 | }; | 563 | }; |
564 | let import_map = db.import_map(krate.into()); | 564 | let import_map = db.import_map(krate.into()); |
@@ -603,7 +603,7 @@ fn try_resolve_path(db: &RootDatabase, definition: &Definition, link: &str) -> O | |||
603 | } | 603 | } |
604 | 604 | ||
605 | /// Try to get the root URL of the documentation of a crate. | 605 | /// Try to get the root URL of the documentation of a crate. |
606 | // TODO: Special case standard, core, alloc libraries | 606 | // FIXME: Special case standard, core, alloc libraries |
607 | fn get_doc_url(db: &RootDatabase, krate: &Crate) -> Option<Url> { | 607 | fn get_doc_url(db: &RootDatabase, krate: &Crate) -> Option<Url> { |
608 | // Look for #![doc(html_root_url = "...")] | 608 | // Look for #![doc(html_root_url = "...")] |
609 | let attrs = db.attrs(AttrDef::from(krate.root_module(db)?).into()); | 609 | let attrs = db.attrs(AttrDef::from(krate.root_module(db)?).into()); |
@@ -621,7 +621,7 @@ fn get_doc_url(db: &RootDatabase, krate: &Crate) -> Option<Url> { | |||
621 | }).next() | 621 | }).next() |
622 | } else { | 622 | } else { |
623 | // Fallback to docs.rs | 623 | // Fallback to docs.rs |
624 | // TODO: Specify an exact version here (from Cargo.lock) | 624 | // FIXME: Specify an exact version here (from Cargo.lock) |
625 | Some(format!("https://docs.rs/{}/*", krate.display_name(db)?)) | 625 | Some(format!("https://docs.rs/{}/*", krate.display_name(db)?)) |
626 | }; | 626 | }; |
627 | 627 | ||
@@ -648,7 +648,6 @@ fn get_symbol_filename(db: &RootDatabase, definition: &Definition) -> Option<Str | |||
648 | format!("enum.{}.html#variant.{}", ev.parent_enum(db).name(db), ev.name(db)) | 648 | format!("enum.{}.html#variant.{}", ev.parent_enum(db).name(db), ev.name(db)) |
649 | } | 649 | } |
650 | ModuleDef::Const(c) => format!("const.{}.html", c.name(db)?), | 650 | ModuleDef::Const(c) => format!("const.{}.html", c.name(db)?), |
651 | // TODO: Check this is the right prefix | ||
652 | ModuleDef::Static(s) => format!("static.{}.html", s.name(db)?), | 651 | ModuleDef::Static(s) => format!("static.{}.html", s.name(db)?), |
653 | }, | 652 | }, |
654 | Definition::Macro(m) => format!("macro.{}.html", m.name(db)?), | 653 | Definition::Macro(m) => format!("macro.{}.html", m.name(db)?), |
diff --git a/crates/ra_ide_db/src/defs.rs b/crates/ra_ide_db/src/defs.rs index a158169e3..b07395a64 100644 --- a/crates/ra_ide_db/src/defs.rs +++ b/crates/ra_ide_db/src/defs.rs | |||
@@ -6,8 +6,9 @@ | |||
6 | // FIXME: this badly needs rename/rewrite (matklad, 2020-02-06). | 6 | // FIXME: this badly needs rename/rewrite (matklad, 2020-02-06). |
7 | 7 | ||
8 | use hir::{ | 8 | use hir::{ |
9 | db::{DefDatabase, HirDatabase}, | ||
9 | Field, HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, Name, PathResolution, | 10 | Field, HasVisibility, ImplDef, Local, MacroDef, Module, ModuleDef, Name, PathResolution, |
10 | Semantics, TypeParam, Visibility, db::{DefDatabase, HirDatabase}, | 11 | Semantics, TypeParam, Visibility, |
11 | }; | 12 | }; |
12 | use ra_prof::profile; | 13 | use ra_prof::profile; |
13 | use ra_syntax::{ | 14 | use ra_syntax::{ |
@@ -16,7 +17,7 @@ use ra_syntax::{ | |||
16 | }; | 17 | }; |
17 | 18 | ||
18 | use crate::RootDatabase; | 19 | use crate::RootDatabase; |
19 | use ra_hir_def::resolver::{Resolver, HasResolver}; | 20 | use ra_hir_def::resolver::{HasResolver, Resolver}; |
20 | 21 | ||
21 | // FIXME: a more precise name would probably be `Symbol`? | 22 | // FIXME: a more precise name would probably be `Symbol`? |
22 | #[derive(Debug, PartialEq, Eq, Copy, Clone)] | 23 | #[derive(Debug, PartialEq, Eq, Copy, Clone)] |
@@ -83,12 +84,14 @@ impl Definition { | |||
83 | use ra_hir_def::*; | 84 | use ra_hir_def::*; |
84 | Some(match self { | 85 | Some(match self { |
85 | Definition::ModuleDef(def) => def.resolver(db)?, | 86 | Definition::ModuleDef(def) => def.resolver(db)?, |
86 | Definition::Field(field) => Into::<VariantId>::into(Into::<VariantDef>::into(field.parent_def(db))).resolver(db), | 87 | Definition::Field(field) => { |
88 | Into::<VariantId>::into(Into::<VariantDef>::into(field.parent_def(db))).resolver(db) | ||
89 | } | ||
87 | Definition::Macro(m) => Into::<ModuleId>::into(m.module(db)?).resolver(db), | 90 | Definition::Macro(m) => Into::<ModuleId>::into(m.module(db)?).resolver(db), |
88 | Definition::SelfType(imp) => Into::<ImplId>::into(imp.clone()).resolver(db), | 91 | Definition::SelfType(imp) => Into::<ImplId>::into(imp.clone()).resolver(db), |
89 | // it's possible, read probable, that other arms of this are also unreachable | 92 | // it's possible, read probable, that other arms of this are also unreachable |
90 | Definition::Local(_local) => unreachable!(), | 93 | Definition::Local(_local) => unreachable!(), |
91 | Definition::TypeParam(tp) => Into::<ModuleId>::into(tp.module(db)).resolver(db) | 94 | Definition::TypeParam(tp) => Into::<ModuleId>::into(tp.module(db)).resolver(db), |
92 | }) | 95 | }) |
93 | } | 96 | } |
94 | } | 97 | } |
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs index 7a2c44cd2..bd83eb2d2 100644 --- a/crates/ra_syntax/src/lib.rs +++ b/crates/ra_syntax/src/lib.rs | |||
@@ -47,7 +47,7 @@ use crate::syntax_node::GreenNode; | |||
47 | pub use crate::{ | 47 | pub use crate::{ |
48 | algo::InsertPosition, | 48 | algo::InsertPosition, |
49 | ast::{AstNode, AstToken}, | 49 | ast::{AstNode, AstToken}, |
50 | parsing::{lex_single_syntax_kind, lex_single_valid_syntax_kind, tokenize, Token, parse_text}, | 50 | parsing::{lex_single_syntax_kind, lex_single_valid_syntax_kind, parse_text, tokenize, Token}, |
51 | ptr::{AstPtr, SyntaxNodePtr}, | 51 | ptr::{AstPtr, SyntaxNodePtr}, |
52 | syntax_error::SyntaxError, | 52 | syntax_error::SyntaxError, |
53 | syntax_node::{ | 53 | syntax_node::{ |
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index c8c8b886d..e35a5e846 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs | |||
@@ -4,7 +4,7 @@ | |||
4 | 4 | ||
5 | use std::{ | 5 | use std::{ |
6 | io::Write as _, | 6 | io::Write as _, |
7 | process::{self, Stdio} | 7 | process::{self, Stdio}, |
8 | }; | 8 | }; |
9 | 9 | ||
10 | use lsp_server::ErrorCode; | 10 | use lsp_server::ErrorCode; |