mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 11:59:49 +00:00
Replace ID based TokenMap with proper relative text-ranges / spans
This commit is contained in:
parent
f79439caed
commit
890eb17b4e
80 changed files with 1816 additions and 2046 deletions
|
@ -149,7 +149,7 @@ mod tests {
|
|||
|
||||
fn check_hierarchy(
|
||||
ra_fixture: &str,
|
||||
expected: Expect,
|
||||
expected_nav: Expect,
|
||||
expected_incoming: Expect,
|
||||
expected_outgoing: Expect,
|
||||
) {
|
||||
|
@ -158,7 +158,7 @@ mod tests {
|
|||
let mut navs = analysis.call_hierarchy(pos).unwrap().unwrap().info;
|
||||
assert_eq!(navs.len(), 1);
|
||||
let nav = navs.pop().unwrap();
|
||||
expected.assert_eq(&nav.debug_render());
|
||||
expected_nav.assert_eq(&nav.debug_render());
|
||||
|
||||
let item_pos =
|
||||
FilePosition { file_id: nav.file_id, offset: nav.focus_or_full_range().start() };
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use hir::Semantics;
|
||||
use hir::{HirFileIdExt, Semantics};
|
||||
use ide_db::{
|
||||
base_db::FileId, helpers::pick_best_token,
|
||||
syntax_helpers::insert_whitespace_into_node::insert_ws_into, RootDatabase,
|
||||
|
|
|
@ -60,13 +60,13 @@ pub(crate) fn goto_definition(
|
|||
.into_iter()
|
||||
.filter_map(|token| {
|
||||
let parent = token.parent()?;
|
||||
if let Some(tt) = ast::TokenTree::cast(parent) {
|
||||
if let Some(tt) = ast::TokenTree::cast(parent.clone()) {
|
||||
if let Some(x) = try_lookup_include_path(sema, tt, token.clone(), file_id) {
|
||||
return Some(vec![x]);
|
||||
}
|
||||
}
|
||||
Some(
|
||||
IdentClass::classify_token(sema, &token)?
|
||||
IdentClass::classify_node(sema, &parent)?
|
||||
.definitions()
|
||||
.into_iter()
|
||||
.flat_map(|def| {
|
||||
|
@ -392,6 +392,8 @@ fn bar() {
|
|||
);
|
||||
}
|
||||
|
||||
// FIXME: We should emit two targets here, one for the identifier in the declaration, one for
|
||||
// the macro call
|
||||
#[test]
|
||||
fn goto_def_for_macro_defined_fn_no_arg() {
|
||||
check(
|
||||
|
@ -399,10 +401,10 @@ fn bar() {
|
|||
//- /lib.rs
|
||||
macro_rules! define_fn {
|
||||
() => (fn foo() {})
|
||||
//^^^
|
||||
}
|
||||
|
||||
define_fn!();
|
||||
//^^^^^^^^^^^^^
|
||||
|
||||
fn bar() {
|
||||
$0foo();
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
//! tests. This module also implements a couple of magic tricks, like renaming
|
||||
//! `self` and to `self` (to switch between associated function and method).
|
||||
|
||||
use hir::{AsAssocItem, InFile, Semantics};
|
||||
use hir::{AsAssocItem, HirFileIdExt, InFile, Semantics};
|
||||
use ide_db::{
|
||||
base_db::FileId,
|
||||
defs::{Definition, NameClass, NameRefClass},
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::fmt;
|
|||
|
||||
use ast::HasName;
|
||||
use cfg::CfgExpr;
|
||||
use hir::{db::HirDatabase, AsAssocItem, HasAttrs, HasSource, Semantics};
|
||||
use hir::{db::HirDatabase, AsAssocItem, HasAttrs, HasSource, HirFileIdExt, Semantics};
|
||||
use ide_assists::utils::test_related_attribute;
|
||||
use ide_db::{
|
||||
base_db::{FilePosition, FileRange},
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
use std::collections::HashMap;
|
||||
|
||||
use hir::{db::HirDatabase, Crate, Module};
|
||||
use hir::{db::HirDatabase, Crate, HirFileIdExt, Module};
|
||||
use ide_db::helpers::get_definition;
|
||||
use ide_db::{
|
||||
base_db::{FileId, FileRange, SourceDatabaseExt},
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
//! Computes color for a single element.
|
||||
|
||||
use hir::{AsAssocItem, HasVisibility, Semantics};
|
||||
use hir::{AsAssocItem, HasVisibility, HirFileIdExt, Semantics};
|
||||
use ide_db::{
|
||||
defs::{Definition, IdentClass, NameClass, NameRefClass},
|
||||
FxHashMap, RootDatabase, SymbolKind,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue