change from krate to Option<krate> in syntax highlighting to incorporate modules which are not part of any crate

This commit is contained in:
bit-aloo 2025-03-21 20:56:53 +05:30
parent 31e412c290
commit 02cd8c5c90
No known key found for this signature in database
GPG key ID: 02911B24FDAE81DA
3 changed files with 16 additions and 18 deletions

View file

@ -222,10 +222,7 @@ pub(crate) fn highlight(
};
let mut hl = highlights::Highlights::new(root.text_range());
let krate = match sema.scope(&root) {
Some(it) => it.krate(),
None => return hl.to_vec(),
};
let krate = sema.scope(&root).map(|it| it.krate());
traverse(&mut hl, &sema, config, InRealFile::new(file_id, &root), krate, range_to_highlight);
hl.to_vec()
}
@ -235,7 +232,7 @@ fn traverse(
sema: &Semantics<'_, RootDatabase>,
config: HighlightConfig,
InRealFile { file_id, value: root }: InRealFile<&SyntaxNode>,
krate: hir::Crate,
krate: Option<hir::Crate>,
range_to_highlight: TextRange,
) {
let is_unlinked = sema.file_to_module_def(file_id).is_none();
@ -498,7 +495,7 @@ fn string_injections(
sema: &Semantics<'_, RootDatabase>,
config: HighlightConfig,
file_id: EditionedFileId,
krate: hir::Crate,
krate: Option<hir::Crate>,
token: SyntaxToken,
descended_token: &SyntaxToken,
) -> ControlFlow<()> {