mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
implement type_name intrinsic
This commit is contained in:
parent
274e8301c1
commit
5208bf8f55
7 changed files with 158 additions and 56 deletions
|
@ -34,13 +34,15 @@ fn find_and_interpret(db: &RootDatabase, position: FilePosition) -> Option<Strin
|
|||
_ => return None,
|
||||
};
|
||||
let span_formatter = |file_id, text_range: TextRange| {
|
||||
let line_col = db.line_index(file_id).line_col(text_range.start());
|
||||
let path = &db
|
||||
.source_root(db.file_source_root(file_id))
|
||||
.path_for_file(&file_id)
|
||||
.map(|x| x.to_string());
|
||||
let path = path.as_deref().unwrap_or("<unknown file>");
|
||||
format!("file://{path}#{}:{}", line_col.line + 1, line_col.col)
|
||||
match db.line_index(file_id).try_line_col(text_range.start()) {
|
||||
Some(line_col) => format!("file://{path}#{}:{}", line_col.line + 1, line_col.col),
|
||||
None => format!("file://{path} range {:?}", text_range),
|
||||
}
|
||||
};
|
||||
Some(def.eval(db, span_formatter))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue