diff options
Diffstat (limited to 'crates/ra_hir/src/source_binder.rs')
-rw-r--r-- | crates/ra_hir/src/source_binder.rs | 30 |
1 files changed, 6 insertions, 24 deletions
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index 6a5799622..410064d45 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs | |||
@@ -10,7 +10,7 @@ use std::sync::Arc; | |||
10 | use rustc_hash::{FxHashSet, FxHashMap}; | 10 | use rustc_hash::{FxHashSet, FxHashMap}; |
11 | use ra_db::{FileId, FilePosition}; | 11 | use ra_db::{FileId, FilePosition}; |
12 | use ra_syntax::{ | 12 | use ra_syntax::{ |
13 | SyntaxNode, AstPtr, TextUnit, SyntaxNodePtr, TextRange,TreeArc, | 13 | SyntaxNode, AstPtr, TextUnit, SyntaxNodePtr, TextRange, |
14 | ast::{self, AstNode, NameOwner}, | 14 | ast::{self, AstNode, NameOwner}, |
15 | algo::find_node_at_offset, | 15 | algo::find_node_at_offset, |
16 | SyntaxKind::*, | 16 | SyntaxKind::*, |
@@ -18,10 +18,9 @@ use ra_syntax::{ | |||
18 | 18 | ||
19 | use crate::{ | 19 | use crate::{ |
20 | HirDatabase, Function, Struct, Enum, Const, Static, Either, DefWithBody, PerNs, Name, | 20 | HirDatabase, Function, Struct, Enum, Const, Static, Either, DefWithBody, PerNs, Name, |
21 | AsName, Module, HirFileId, Crate, Trait, Resolver, Ty,Path, | 21 | AsName, Module, HirFileId, Crate, Trait, Resolver, Ty, Path, MacroDef, |
22 | expr::{BodySourceMap, scope::{ScopeId, ExprScopes}}, | 22 | expr::{BodySourceMap, scope::{ScopeId, ExprScopes}}, |
23 | ids::{LocationCtx, MacroDefId}, | 23 | ids::LocationCtx, |
24 | docs::{docs_from_ast,Documentation}, | ||
25 | expr, AstId, | 24 | expr, AstId, |
26 | }; | 25 | }; |
27 | 26 | ||
@@ -182,27 +181,10 @@ pub enum PathResolution { | |||
182 | /// A generic parameter | 181 | /// A generic parameter |
183 | GenericParam(u32), | 182 | GenericParam(u32), |
184 | SelfType(crate::ImplBlock), | 183 | SelfType(crate::ImplBlock), |
185 | Macro(MacroByExampleDef), | 184 | Macro(MacroDef), |
186 | AssocItem(crate::ImplItem), | 185 | AssocItem(crate::ImplItem), |
187 | } | 186 | } |
188 | 187 | ||
189 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
190 | pub struct MacroByExampleDef { | ||
191 | pub(crate) id: MacroDefId, | ||
192 | } | ||
193 | |||
194 | impl MacroByExampleDef { | ||
195 | pub fn source(&self, db: &impl HirDatabase) -> (HirFileId, TreeArc<ast::MacroCall>) { | ||
196 | (self.id.0.file_id(), self.id.0.to_node(db)) | ||
197 | } | ||
198 | } | ||
199 | |||
200 | impl crate::Docs for MacroByExampleDef { | ||
201 | fn docs(&self, db: &impl HirDatabase) -> Option<Documentation> { | ||
202 | docs_from_ast(&*self.source(db).1) | ||
203 | } | ||
204 | } | ||
205 | |||
206 | #[derive(Debug, Clone, PartialEq, Eq)] | 188 | #[derive(Debug, Clone, PartialEq, Eq)] |
207 | pub struct ScopeEntryWithSyntax { | 189 | pub struct ScopeEntryWithSyntax { |
208 | pub(crate) name: Name, | 190 | pub(crate) name: Name, |
@@ -284,10 +266,10 @@ impl SourceAnalyzer { | |||
284 | &self, | 266 | &self, |
285 | db: &impl HirDatabase, | 267 | db: &impl HirDatabase, |
286 | macro_call: &ast::MacroCall, | 268 | macro_call: &ast::MacroCall, |
287 | ) -> Option<MacroByExampleDef> { | 269 | ) -> Option<MacroDef> { |
288 | let id = | 270 | let id = |
289 | self.resolver.resolve_macro_call(db, macro_call.path().and_then(Path::from_ast))?; | 271 | self.resolver.resolve_macro_call(db, macro_call.path().and_then(Path::from_ast))?; |
290 | Some(MacroByExampleDef { id }) | 272 | Some(MacroDef { id }) |
291 | } | 273 | } |
292 | 274 | ||
293 | pub fn resolve_hir_path( | 275 | pub fn resolve_hir_path( |