Make hover work for intra doc links in macro invocations

This commit is contained in:
Lukas Wirth 2021-09-23 17:32:39 +02:00
parent 42eb4efb5b
commit d99adc5738
3 changed files with 139 additions and 24 deletions

View file

@ -149,7 +149,18 @@ fn convert_tokens<C: TokenConvertor>(conv: &mut C) -> tt::Subtree {
let k: SyntaxKind = token.kind();
if k == COMMENT {
if let Some(tokens) = conv.convert_doc_comment(&token) {
result.extend(tokens);
// FIXME: There has to be a better way to do this
// Add the comments token id to the converted doc string
let id = conv.id_alloc().alloc(range);
result.extend(tokens.into_iter().map(|mut tt| {
if let tt::TokenTree::Subtree(sub) = &mut tt {
if let tt::TokenTree::Leaf(tt::Leaf::Literal(lit)) = &mut sub.token_trees[2]
{
lit.id = id
}
}
tt
}));
}
continue;
}