I'm working on https://github.com/rust-analyzer/rust-analyzer/issues/6168
If the doc comment has multiple link, we need to determine which link is pointed from position.offset. In basic source code, it can be easily done by file.token_at_offset method but comment has only non-structured &str. What is the best way to get position from doc comment?
/// Blah, .. [`foo`]<|> is [`bar`] ...
@sasurau4 couldn't you do
or hmm I don't know if
offset is a number or a range
Yeah, I could do
doc_comment[start..end] if I knew where infra link the FilePosition indicates. But FilePosition has only the offset of the file, so I have to determine where the offset is included by intra link range.
I tried parsing doc comment by pulldown_cmark, it emit only Event that doesn't contain any position infos.
The change of intra link to ast seems very difficult.
Pulldown_cmark will give you the span if you call into_offset_iter
It seems great! Thanks