#[cfg(test)]
mod tests;
-use hir::{InFile, Name, Semantics};
+use hir::{Name, Semantics};
use ide_db::{FxHashMap, RootDatabase};
use syntax::{
ast, AstNode, AstToken, NodeOrToken, SyntaxKind::*, SyntaxNode, TextRange, WalkEvent, T,
// builtinType:: Emitted for builtin types like `u32`, `str` and `f32`.
// comment:: Emitted for comments.
// constParameter:: Emitted for const parameters.
+// deriveHelper:: Emitted for derive helper attributes.
// enumMember:: Emitted for enum variants.
// generic:: Emitted for generic tokens that have no mapping.
// keyword:: Emitted for keywords.
Leave(NodeOrToken::Node(node)) => {
// Doc comment highlighting injection, we do this when leaving the node
// so that we overwrite the highlighting of the doc comment itself.
- inject::doc_comment(hl, sema, InFile::new(file_id.into(), &node));
+ inject::doc_comment(hl, sema, file_id, &node);
continue;
}
};
// let the editor do its highlighting for these tokens instead
continue;
}
+ if highlight.tag == HlTag::UnresolvedReference
+ && matches!(attr_or_derive_item, Some(AttrOrDerive::Derive(_)) if inside_attribute)
+ {
+ // do not emit unresolved references in derive helpers if the token mapping maps to
+ // something unresolvable. FIXME: There should be a way to prevent that
+ continue;
+ }
if inside_attribute {
highlight |= HlMod::Attribute
}