Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-ssr/src/replacing.rs')
-rw-r--r--crates/ide-ssr/src/replacing.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/crates/ide-ssr/src/replacing.rs b/crates/ide-ssr/src/replacing.rs
index b4b83f62da..65756601f6 100644
--- a/crates/ide-ssr/src/replacing.rs
+++ b/crates/ide-ssr/src/replacing.rs
@@ -2,6 +2,7 @@
use ide_db::{FxHashMap, FxHashSet};
use itertools::Itertools;
+use parser::Edition;
use syntax::{
ast::{self, AstNode, AstToken},
SyntaxElement, SyntaxKind, SyntaxNode, SyntaxToken, TextRange, TextSize,
@@ -33,7 +34,7 @@ fn matches_to_edit_at_offset(
for m in &matches.matches {
edit_builder.replace(
m.range.range.checked_sub(relative_start).unwrap(),
- render_replace(db, m, file_src, rules),
+ render_replace(db, m, file_src, rules, m.range.file_id.edition()),
);
}
edit_builder.finish()
@@ -54,6 +55,7 @@ struct ReplacementRenderer<'a> {
// is parsed, placeholders don't get split. e.g. if a template of `$a.to_string()` results in `1
// + 2.to_string()` then the placeholder value `1 + 2` was split and needs parenthesis.
placeholder_tokens_requiring_parenthesis: FxHashSet<SyntaxToken>,
+ edition: Edition,
}
fn render_replace(
@@ -61,6 +63,7 @@ fn render_replace(
match_info: &Match,
file_src: &str,
rules: &[ResolvedRule],
+ edition: Edition,
) -> String {
let rule = &rules[match_info.rule_index];
let template = rule
@@ -76,6 +79,7 @@ fn render_replace(
out: String::new(),
placeholder_tokens_requiring_parenthesis: FxHashSet::default(),
placeholder_tokens_by_range: FxHashMap::default(),
+ edition,
};
renderer.render_node(&template.node);
renderer.maybe_rerender_with_extra_parenthesis(&template.node);
@@ -105,7 +109,7 @@ impl ReplacementRenderer<'_> {
fn render_node(&mut self, node: &SyntaxNode) {
if let Some(mod_path) = self.match_info.rendered_template_paths.get(node) {
- self.out.push_str(&mod_path.display(self.db).to_string());
+ self.out.push_str(&mod_path.display(self.db, self.edition).to_string());
// Emit everything except for the segment's name-ref, since we already effectively
// emitted that as part of `mod_path`.
if let Some(path) = ast::Path::cast(node.clone()) {