fix: Fix ast-id up when merging raw attributes

This commit is contained in:
Lukas Wirth 2022-07-30 09:43:30 +02:00
parent ec3586eab9
commit 618cfd792c
6 changed files with 167 additions and 10 deletions

View file

@ -5,7 +5,8 @@ use std::mem;
use either::Either;
use hir::{InFile, Semantics};
use ide_db::{
active_parameter::ActiveParameter, defs::Definition, rust_doc::is_rust_fence, SymbolKind,
active_parameter::ActiveParameter, base_db::FileId, defs::Definition, rust_doc::is_rust_fence,
SymbolKind,
};
use syntax::{
ast::{self, AstNode, IsString, QuoteOffsets},
@ -81,16 +82,18 @@ pub(super) fn ra_fixture(
const RUSTDOC_FENCE_LENGTH: usize = 3;
const RUSTDOC_FENCES: [&str; 2] = ["```", "~~~"];
/// Injection of syntax highlighting of doctests.
/// Injection of syntax highlighting of doctests and intra doc links.
pub(super) fn doc_comment(
hl: &mut Highlights,
sema: &Semantics<'_, RootDatabase>,
InFile { file_id: src_file_id, value: node }: InFile<&SyntaxNode>,
src_file_id: FileId,
node: &SyntaxNode,
) {
let (attributes, def) = match doc_attributes(sema, node) {
Some(it) => it,
None => return,
};
let src_file_id = src_file_id.into();
// Extract intra-doc links and emit highlights for them.
if let Some((docs, doc_mapping)) = attributes.docs_with_rangemap(sema.db) {