Thread file id through descension API for semantic highlighting

This commit is contained in:
Lukas Wirth 2024-08-22 16:45:37 +02:00
parent 354ab7a9e8
commit c2a07e21f5
3 changed files with 115 additions and 73 deletions

View file

@ -461,3 +461,12 @@ impl<N: AstNode> InFile<N> {
Some(InRealFile::new(file_id, value))
}
}
impl<T> InFile<T> {
pub fn into_real_file(self) -> Result<InRealFile<T>, InFile<T>> {
match self.file_id.repr() {
HirFileIdRepr::FileId(file_id) => Ok(InRealFile { file_id, value: self.value }),
HirFileIdRepr::MacroFile(_) => Err(self),
}
}
}