1
1
//! FIXME: write short doc here
2
2
3
- use hir:: { InFile , Name , Semantics } ;
3
+ use hir:: { Name , Semantics } ;
4
4
use ra_db:: SourceDatabase ;
5
5
use ra_ide_db:: {
6
6
defs:: { classify_name2, NameDefinition } ,
@@ -81,17 +81,15 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa
81
81
WalkEvent :: Enter ( node) => match node. kind ( ) {
82
82
MACRO_CALL => {
83
83
in_macro_call = Some ( node. clone ( ) ) ;
84
- if let Some ( range) = highlight_macro ( InFile :: new ( file_id . into ( ) , node) ) {
84
+ if let Some ( range) = highlight_macro ( node) {
85
85
res. push ( HighlightedRange { range, tag : tags:: MACRO , binding_hash : None } ) ;
86
86
}
87
87
}
88
88
_ if in_macro_call. is_some ( ) => {
89
89
if let Some ( token) = node. as_token ( ) {
90
- if let Some ( ( tag, binding_hash) ) = highlight_token_tree (
91
- & sema,
92
- & mut bindings_shadow_count,
93
- InFile :: new ( file_id. into ( ) , token. clone ( ) ) ,
94
- ) {
90
+ if let Some ( ( tag, binding_hash) ) =
91
+ highlight_token_tree ( & sema, & mut bindings_shadow_count, token. clone ( ) )
92
+ {
95
93
res. push ( HighlightedRange {
96
94
range : node. text_range ( ) ,
97
95
tag,
@@ -121,8 +119,8 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa
121
119
res
122
120
}
123
121
124
- fn highlight_macro ( node : InFile < SyntaxElement > ) -> Option < TextRange > {
125
- let macro_call = ast:: MacroCall :: cast ( node. value . as_node ( ) ?. clone ( ) ) ?;
122
+ fn highlight_macro ( node : SyntaxElement ) -> Option < TextRange > {
123
+ let macro_call = ast:: MacroCall :: cast ( node. as_node ( ) ?. clone ( ) ) ?;
126
124
let path = macro_call. path ( ) ?;
127
125
let name_ref = path. segment ( ) ?. name_ref ( ) ?;
128
126
@@ -141,12 +139,12 @@ fn highlight_macro(node: InFile<SyntaxElement>) -> Option<TextRange> {
141
139
fn highlight_token_tree (
142
140
sema : & Semantics < RootDatabase > ,
143
141
bindings_shadow_count : & mut FxHashMap < Name , u32 > ,
144
- token : InFile < SyntaxToken > ,
142
+ token : SyntaxToken ,
145
143
) -> Option < ( & ' static str , Option < u64 > ) > {
146
- if token. value . parent ( ) . kind ( ) != TOKEN_TREE {
144
+ if token. parent ( ) . kind ( ) != TOKEN_TREE {
147
145
return None ;
148
146
}
149
- let token = sema. descend_into_macros ( token. clone ( ) . value ) ;
147
+ let token = sema. descend_into_macros ( token. clone ( ) ) ;
150
148
let expanded = {
151
149
let parent = token. parent ( ) ;
152
150
// We only care Name and Name_ref
0 commit comments