self.imp.original_range(node)
}
- pub fn diagnostics_presentation_range(&self, diagnostics: &dyn Diagnostic) -> FileRange {
- self.imp.diagnostics_presentation_range(diagnostics)
+ pub fn diagnostics_display_range(&self, diagnostics: &dyn Diagnostic) -> FileRange {
+ self.imp.diagnostics_display_range(diagnostics)
}
pub fn ancestors_with_macros(&self, node: SyntaxNode) -> impl Iterator<Item = SyntaxNode> + '_ {
original_range(self.db, node.as_ref())
}
- fn diagnostics_presentation_range(&self, diagnostics: &dyn Diagnostic) -> FileRange {
- let src = diagnostics.presentation();
+ fn diagnostics_display_range(&self, diagnostics: &dyn Diagnostic) -> FileRange {
+ let src = diagnostics.display_source();
let root = self.db.parse_or_expand(src.file_id).unwrap();
let node = src.value.to_node(&root);
self.cache(root, src.file_id);
"no such field".to_string()
}
- fn presentation(&self) -> InFile<SyntaxNodePtr> {
+ fn display_source(&self) -> InFile<SyntaxNodePtr> {
InFile::new(self.file, self.field.clone().into())
}
buf
}
- fn presentation(&self) -> InFile<SyntaxNodePtr> {
+ fn display_source(&self) -> InFile<SyntaxNodePtr> {
InFile {
file_id: self.file,
value: self
}
buf
}
- fn presentation(&self) -> InFile<SyntaxNodePtr> {
- let value = self
- .field_list_parent_path
- .clone()
- .map(SyntaxNodePtr::from)
- .unwrap_or_else(|| self.field_list_parent.clone().into());
- InFile { file_id: self.file, value }
+ fn display_source(&self) -> InFile<SyntaxNodePtr> {
+ InFile {
+ file_id: self.file,
+ value: self
+ .field_list_parent_path
+ .clone()
+ .map(SyntaxNodePtr::from)
+ .unwrap_or_else(|| self.field_list_parent.clone().into()),
+ }
}
fn as_any(&self) -> &(dyn Any + Send + 'static) {
self
fn message(&self) -> String {
String::from("Missing match arm")
}
- fn presentation(&self) -> InFile<SyntaxNodePtr> {
+ fn display_source(&self) -> InFile<SyntaxNodePtr> {
InFile { file_id: self.file, value: self.match_expr.clone().into() }
}
fn as_any(&self) -> &(dyn Any + Send + 'static) {
fn message(&self) -> String {
"wrap return expression in Ok".to_string()
}
- fn presentation(&self) -> InFile<SyntaxNodePtr> {
+ fn display_source(&self) -> InFile<SyntaxNodePtr> {
InFile { file_id: self.file, value: self.expr.clone().into() }
}
fn as_any(&self) -> &(dyn Any + Send + 'static) {
fn message(&self) -> String {
"break outside of loop".to_string()
}
- fn presentation(&self) -> InFile<SyntaxNodePtr> {
+ fn display_source(&self) -> InFile<SyntaxNodePtr> {
InFile { file_id: self.file, value: self.expr.clone().into() }
}
fn as_any(&self) -> &(dyn Any + Send + 'static) {
fn message(&self) -> String {
format!("This operation is unsafe and requires an unsafe function or block")
}
- fn presentation(&self) -> InFile<SyntaxNodePtr> {
+ fn display_source(&self) -> InFile<SyntaxNodePtr> {
InFile { file_id: self.file, value: self.expr.clone().into() }
}
fn as_any(&self) -> &(dyn Any + Send + 'static) {
let s = if self.expected == 1 { "" } else { "s" };
format!("Expected {} argument{}, found {}", self.expected, s, self.found)
}
- fn presentation(&self) -> InFile<SyntaxNodePtr> {
+ fn display_source(&self) -> InFile<SyntaxNodePtr> {
InFile { file_id: self.file, value: self.call_expr.clone().into() }
}
fn as_any(&self) -> &(dyn Any + Send + 'static) {
let mut actual: FxHashMap<FileId, Vec<(TextRange, String)>> = FxHashMap::default();
db.diagnostics(|d| {
+ let src = d.display_source();
+ let root = db.parse_or_expand(src.file_id).unwrap();
// FIXME: macros...
- let diagnostics_presentation = d.presentation();
- let root = db.parse_or_expand(diagnostics_presentation.file_id).unwrap();
-
- let file_id = diagnostics_presentation.file_id.original_file(&db);
- let range = diagnostics_presentation.value.to_node(&root).text_range();
+ let file_id = src.file_id.original_file(&db);
+ let range = src.value.to_node(&root).text_range();
let message = d.message().to_owned();
actual.entry(file_id).or_default().push((range, message));
});