Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide/src/syntax_highlighting/html.rs')
-rw-r--r--crates/ide/src/syntax_highlighting/html.rs15
1 files changed, 10 insertions, 5 deletions
diff --git a/crates/ide/src/syntax_highlighting/html.rs b/crates/ide/src/syntax_highlighting/html.rs
index e754b702de..47ad54759a 100644
--- a/crates/ide/src/syntax_highlighting/html.rs
+++ b/crates/ide/src/syntax_highlighting/html.rs
@@ -1,7 +1,8 @@
//! Renders a bit of code as HTML.
-use ide_db::base_db::SourceDatabase;
+use hir::Semantics;
use oorandom::Rand32;
+use span::EditionedFileId;
use stdx::format_to;
use syntax::AstNode;
@@ -11,8 +12,12 @@ use crate::{
};
pub(crate) fn highlight_as_html(db: &RootDatabase, file_id: FileId, rainbow: bool) -> String {
- let parse = db.parse(file_id);
-
+ let sema = Semantics::new(db);
+ let file_id = sema
+ .attach_first_edition(file_id)
+ .unwrap_or_else(|| EditionedFileId::current_edition(file_id));
+ let file = sema.parse(file_id);
+ let file = file.syntax();
fn rainbowify(seed: u64) -> String {
let mut rng = Rand32::new(seed);
format!(
@@ -35,10 +40,10 @@ pub(crate) fn highlight_as_html(db: &RootDatabase, file_id: FileId, rainbow: boo
macro_bang: true,
syntactic_name_ref_highlighting: false,
},
- file_id,
+ file_id.into(),
None,
);
- let text = parse.tree().syntax().to_string();
+ let text = file.to_string();
let mut buf = String::new();
buf.push_str(STYLE);
buf.push_str("<pre><code>");