Skip to content

Commit 48ce3ad

Browse files
committed
wip
1 parent d0d5213 commit 48ce3ad

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

crates/ra_ide/src/syntax_highlighting.rs

+10-12
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! FIXME: write short doc here
22
3-
use hir::{InFile, Name, Semantics};
3+
use hir::{Name, Semantics};
44
use ra_db::SourceDatabase;
55
use ra_ide_db::{
66
defs::{classify_name2, NameDefinition},
@@ -81,17 +81,15 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa
8181
WalkEvent::Enter(node) => match node.kind() {
8282
MACRO_CALL => {
8383
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) {
8585
res.push(HighlightedRange { range, tag: tags::MACRO, binding_hash: None });
8686
}
8787
}
8888
_ if in_macro_call.is_some() => {
8989
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+
{
9593
res.push(HighlightedRange {
9694
range: node.text_range(),
9795
tag,
@@ -121,8 +119,8 @@ pub(crate) fn highlight(db: &RootDatabase, file_id: FileId) -> Vec<HighlightedRa
121119
res
122120
}
123121

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())?;
126124
let path = macro_call.path()?;
127125
let name_ref = path.segment()?.name_ref()?;
128126

@@ -141,12 +139,12 @@ fn highlight_macro(node: InFile<SyntaxElement>) -> Option<TextRange> {
141139
fn highlight_token_tree(
142140
sema: &Semantics<RootDatabase>,
143141
bindings_shadow_count: &mut FxHashMap<Name, u32>,
144-
token: InFile<SyntaxToken>,
142+
token: SyntaxToken,
145143
) -> Option<(&'static str, Option<u64>)> {
146-
if token.value.parent().kind() != TOKEN_TREE {
144+
if token.parent().kind() != TOKEN_TREE {
147145
return None;
148146
}
149-
let token = sema.descend_into_macros(token.clone().value);
147+
let token = sema.descend_into_macros(token.clone());
150148
let expanded = {
151149
let parent = token.parent();
152150
// We only care Name and Name_ref

0 commit comments

Comments
 (0)