diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-07-17 11:43:33 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-07-17 11:43:33 +0100 |
commit | 6ae6c1460e1e0524664af39fd0dbe3b1af3fac50 (patch) | |
tree | 7e2e84a42863d4cc284e2954198e944e3cc7b3a1 /crates | |
parent | f157a0983a11132a3095f4241d60759c81a7ef26 (diff) | |
parent | d7548a36a7e814a165b05ffcb9ec5b55e0b291da (diff) |
Merge #5420
5420: Unclutter NavigationTarget API r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_ide/src/call_hierarchy.rs | 3 | ||||
-rw-r--r-- | crates/ra_ide/src/display/navigation_target.rs | 81 | ||||
-rw-r--r-- | crates/ra_ide/src/goto_definition.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide/src/goto_implementation.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide/src/goto_type_definition.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide/src/hover.rs | 144 | ||||
-rw-r--r-- | crates/ra_ide/src/lib.rs | 16 | ||||
-rw-r--r-- | crates/ra_ide/src/references.rs | 6 | ||||
-rw-r--r-- | crates/ra_ide/src/runnables.rs | 60 | ||||
-rw-r--r-- | crates/rust-analyzer/src/handlers.rs | 20 | ||||
-rw-r--r-- | crates/rust-analyzer/src/to_proto.rs | 28 |
11 files changed, 166 insertions, 198 deletions
diff --git a/crates/ra_ide/src/call_hierarchy.rs b/crates/ra_ide/src/call_hierarchy.rs index 6af251d23..c28af8ab3 100644 --- a/crates/ra_ide/src/call_hierarchy.rs +++ b/crates/ra_ide/src/call_hierarchy.rs | |||
@@ -154,7 +154,8 @@ mod tests { | |||
154 | let nav = navs.pop().unwrap(); | 154 | let nav = navs.pop().unwrap(); |
155 | nav.assert_match(expected); | 155 | nav.assert_match(expected); |
156 | 156 | ||
157 | let item_pos = FilePosition { file_id: nav.file_id(), offset: nav.range().start() }; | 157 | let item_pos = |
158 | FilePosition { file_id: nav.file_id, offset: nav.focus_or_full_range().start() }; | ||
158 | let incoming_calls = analysis.incoming_calls(item_pos).unwrap().unwrap(); | 159 | let incoming_calls = analysis.incoming_calls(item_pos).unwrap().unwrap(); |
159 | assert_eq!(incoming_calls.len(), expected_incoming.len()); | 160 | assert_eq!(incoming_calls.len(), expected_incoming.len()); |
160 | 161 | ||
diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs index 8bf2428ed..6dcb9415a 100644 --- a/crates/ra_ide/src/display/navigation_target.rs +++ b/crates/ra_ide/src/display/navigation_target.rs | |||
@@ -22,15 +22,28 @@ use super::short_label::ShortLabel; | |||
22 | /// code, like a function or a struct, but this is not strictly required. | 22 | /// code, like a function or a struct, but this is not strictly required. |
23 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 23 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] |
24 | pub struct NavigationTarget { | 24 | pub struct NavigationTarget { |
25 | // FIXME: use FileRange? | 25 | pub file_id: FileId, |
26 | file_id: FileId, | 26 | /// Range which encompasses the whole element. |
27 | full_range: TextRange, | 27 | /// |
28 | name: SmolStr, | 28 | /// Should include body, doc comments, attributes, etc. |
29 | kind: SyntaxKind, | 29 | /// |
30 | focus_range: Option<TextRange>, | 30 | /// Clients should use this range to answer "is the cursor inside the |
31 | container_name: Option<SmolStr>, | 31 | /// element?" question. |
32 | description: Option<String>, | 32 | pub full_range: TextRange, |
33 | docs: Option<String>, | 33 | /// A "most interesting" range withing the `full_range`. |
34 | /// | ||
35 | /// Typically, `full_range` is the whole syntax node, including doc | ||
36 | /// comments, and `focus_range` is the range of the identifier. "Most | ||
37 | /// interesting" range within the full range, typically the range of | ||
38 | /// identifier. | ||
39 | /// | ||
40 | /// Clients should place the cursor on this range when navigating to this target. | ||
41 | pub focus_range: Option<TextRange>, | ||
42 | pub name: SmolStr, | ||
43 | pub kind: SyntaxKind, | ||
44 | pub container_name: Option<SmolStr>, | ||
45 | pub description: Option<String>, | ||
46 | pub docs: Option<String>, | ||
34 | } | 47 | } |
35 | 48 | ||
36 | pub(crate) trait ToNav { | 49 | pub(crate) trait ToNav { |
@@ -42,44 +55,9 @@ pub(crate) trait TryToNav { | |||
42 | } | 55 | } |
43 | 56 | ||
44 | impl NavigationTarget { | 57 | impl NavigationTarget { |
45 | /// When `focus_range` is specified, returns it. otherwise | 58 | pub fn focus_or_full_range(&self) -> TextRange { |
46 | /// returns `full_range` | ||
47 | pub fn range(&self) -> TextRange { | ||
48 | self.focus_range.unwrap_or(self.full_range) | 59 | self.focus_range.unwrap_or(self.full_range) |
49 | } | 60 | } |
50 | /// A "most interesting" range withing the `full_range`. | ||
51 | /// | ||
52 | /// Typically, `full_range` is the whole syntax node, | ||
53 | /// including doc comments, and `focus_range` is the range of the identifier. | ||
54 | pub fn focus_range(&self) -> Option<TextRange> { | ||
55 | self.focus_range | ||
56 | } | ||
57 | pub fn full_range(&self) -> TextRange { | ||
58 | self.full_range | ||
59 | } | ||
60 | pub fn file_id(&self) -> FileId { | ||
61 | self.file_id | ||
62 | } | ||
63 | |||
64 | pub fn name(&self) -> &SmolStr { | ||
65 | &self.name | ||
66 | } | ||
67 | |||
68 | pub fn container_name(&self) -> Option<&SmolStr> { | ||
69 | self.container_name.as_ref() | ||
70 | } | ||
71 | |||
72 | pub fn kind(&self) -> SyntaxKind { | ||
73 | self.kind | ||
74 | } | ||
75 | |||
76 | pub fn docs(&self) -> Option<&str> { | ||
77 | self.docs.as_deref() | ||
78 | } | ||
79 | |||
80 | pub fn description(&self) -> Option<&str> { | ||
81 | self.description.as_deref() | ||
82 | } | ||
83 | 61 | ||
84 | pub(crate) fn from_module_to_decl(db: &RootDatabase, module: hir::Module) -> NavigationTarget { | 62 | pub(crate) fn from_module_to_decl(db: &RootDatabase, module: hir::Module) -> NavigationTarget { |
85 | let name = module.name(db).map(|it| it.to_string().into()).unwrap_or_default(); | 63 | let name = module.name(db).map(|it| it.to_string().into()).unwrap_or_default(); |
@@ -107,17 +85,12 @@ impl NavigationTarget { | |||
107 | 85 | ||
108 | #[cfg(test)] | 86 | #[cfg(test)] |
109 | pub(crate) fn debug_render(&self) -> String { | 87 | pub(crate) fn debug_render(&self) -> String { |
110 | let mut buf = format!( | 88 | let mut buf = |
111 | "{} {:?} {:?} {:?}", | 89 | format!("{} {:?} {:?} {:?}", self.name, self.kind, self.file_id, self.full_range); |
112 | self.name(), | 90 | if let Some(focus_range) = self.focus_range { |
113 | self.kind(), | ||
114 | self.file_id(), | ||
115 | self.full_range() | ||
116 | ); | ||
117 | if let Some(focus_range) = self.focus_range() { | ||
118 | buf.push_str(&format!(" {:?}", focus_range)) | 91 | buf.push_str(&format!(" {:?}", focus_range)) |
119 | } | 92 | } |
120 | if let Some(container_name) = self.container_name() { | 93 | if let Some(container_name) = &self.container_name { |
121 | buf.push_str(&format!(" {}", container_name)) | 94 | buf.push_str(&format!(" {}", container_name)) |
122 | } | 95 | } |
123 | buf | 96 | buf |
diff --git a/crates/ra_ide/src/goto_definition.rs b/crates/ra_ide/src/goto_definition.rs index c30b20611..db6d20a37 100644 --- a/crates/ra_ide/src/goto_definition.rs +++ b/crates/ra_ide/src/goto_definition.rs | |||
@@ -130,7 +130,7 @@ mod tests { | |||
130 | assert_eq!(navs.len(), 1); | 130 | assert_eq!(navs.len(), 1); |
131 | 131 | ||
132 | let nav = navs.pop().unwrap(); | 132 | let nav = navs.pop().unwrap(); |
133 | assert_eq!(expected, FileRange { file_id: nav.file_id(), range: nav.range() }); | 133 | assert_eq!(expected, FileRange { file_id: nav.file_id, range: nav.focus_or_full_range() }); |
134 | } | 134 | } |
135 | 135 | ||
136 | #[test] | 136 | #[test] |
diff --git a/crates/ra_ide/src/goto_implementation.rs b/crates/ra_ide/src/goto_implementation.rs index 9acc960fc..3ee048f28 100644 --- a/crates/ra_ide/src/goto_implementation.rs +++ b/crates/ra_ide/src/goto_implementation.rs | |||
@@ -98,7 +98,7 @@ mod tests { | |||
98 | 98 | ||
99 | let mut actual = navs | 99 | let mut actual = navs |
100 | .into_iter() | 100 | .into_iter() |
101 | .map(|nav| FileRange { file_id: nav.file_id(), range: nav.range() }) | 101 | .map(|nav| FileRange { file_id: nav.file_id, range: nav.focus_or_full_range() }) |
102 | .collect::<Vec<_>>(); | 102 | .collect::<Vec<_>>(); |
103 | actual.sort_by_key(key); | 103 | actual.sort_by_key(key); |
104 | 104 | ||
diff --git a/crates/ra_ide/src/goto_type_definition.rs b/crates/ra_ide/src/goto_type_definition.rs index 069cb283e..8f52feea6 100644 --- a/crates/ra_ide/src/goto_type_definition.rs +++ b/crates/ra_ide/src/goto_type_definition.rs | |||
@@ -67,7 +67,7 @@ mod tests { | |||
67 | let mut navs = analysis.goto_type_definition(position).unwrap().unwrap().info; | 67 | let mut navs = analysis.goto_type_definition(position).unwrap().unwrap().info; |
68 | assert_eq!(navs.len(), 1); | 68 | assert_eq!(navs.len(), 1); |
69 | let nav = navs.pop().unwrap(); | 69 | let nav = navs.pop().unwrap(); |
70 | assert_eq!(expected, FileRange { file_id: nav.file_id(), range: nav.range() }); | 70 | assert_eq!(expected, FileRange { file_id: nav.file_id, range: nav.focus_or_full_range() }); |
71 | } | 71 | } |
72 | 72 | ||
73 | #[test] | 73 | #[test] |
diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs index a4c97e7f9..d067c339d 100644 --- a/crates/ra_ide/src/hover.rs +++ b/crates/ra_ide/src/hover.rs | |||
@@ -133,8 +133,8 @@ pub(crate) fn hover(db: &RootDatabase, position: FilePosition) -> Option<RangeIn | |||
133 | fn show_implementations_action(db: &RootDatabase, def: Definition) -> Option<HoverAction> { | 133 | fn show_implementations_action(db: &RootDatabase, def: Definition) -> Option<HoverAction> { |
134 | fn to_action(nav_target: NavigationTarget) -> HoverAction { | 134 | fn to_action(nav_target: NavigationTarget) -> HoverAction { |
135 | HoverAction::Implementaion(FilePosition { | 135 | HoverAction::Implementaion(FilePosition { |
136 | file_id: nav_target.file_id(), | 136 | file_id: nav_target.file_id, |
137 | offset: nav_target.range().start(), | 137 | offset: nav_target.focus_or_full_range().start(), |
138 | }) | 138 | }) |
139 | } | 139 | } |
140 | 140 | ||
@@ -1357,11 +1357,11 @@ fn foo_<|>test() {} | |||
1357 | 1, | 1357 | 1, |
1358 | ), | 1358 | ), |
1359 | full_range: 0..24, | 1359 | full_range: 0..24, |
1360 | name: "foo_test", | ||
1361 | kind: FN_DEF, | ||
1362 | focus_range: Some( | 1360 | focus_range: Some( |
1363 | 11..19, | 1361 | 11..19, |
1364 | ), | 1362 | ), |
1363 | name: "foo_test", | ||
1364 | kind: FN_DEF, | ||
1365 | container_name: None, | 1365 | container_name: None, |
1366 | description: None, | 1366 | description: None, |
1367 | docs: None, | 1367 | docs: None, |
@@ -1400,11 +1400,11 @@ mod tests<|> { | |||
1400 | 1, | 1400 | 1, |
1401 | ), | 1401 | ), |
1402 | full_range: 0..46, | 1402 | full_range: 0..46, |
1403 | name: "tests", | ||
1404 | kind: MODULE, | ||
1405 | focus_range: Some( | 1403 | focus_range: Some( |
1406 | 4..9, | 1404 | 4..9, |
1407 | ), | 1405 | ), |
1406 | name: "tests", | ||
1407 | kind: MODULE, | ||
1408 | container_name: None, | 1408 | container_name: None, |
1409 | description: None, | 1409 | description: None, |
1410 | docs: None, | 1410 | docs: None, |
@@ -1439,11 +1439,11 @@ fn main() { let s<|>t = S{ f1:0 }; } | |||
1439 | 1, | 1439 | 1, |
1440 | ), | 1440 | ), |
1441 | full_range: 0..19, | 1441 | full_range: 0..19, |
1442 | name: "S", | ||
1443 | kind: STRUCT_DEF, | ||
1444 | focus_range: Some( | 1442 | focus_range: Some( |
1445 | 7..8, | 1443 | 7..8, |
1446 | ), | 1444 | ), |
1445 | name: "S", | ||
1446 | kind: STRUCT_DEF, | ||
1447 | container_name: None, | 1447 | container_name: None, |
1448 | description: Some( | 1448 | description: Some( |
1449 | "struct S", | 1449 | "struct S", |
@@ -1478,11 +1478,11 @@ fn main() { let s<|>t = S{ f1:Arg(0) }; } | |||
1478 | 1, | 1478 | 1, |
1479 | ), | 1479 | ), |
1480 | full_range: 17..37, | 1480 | full_range: 17..37, |
1481 | name: "S", | ||
1482 | kind: STRUCT_DEF, | ||
1483 | focus_range: Some( | 1481 | focus_range: Some( |
1484 | 24..25, | 1482 | 24..25, |
1485 | ), | 1483 | ), |
1484 | name: "S", | ||
1485 | kind: STRUCT_DEF, | ||
1486 | container_name: None, | 1486 | container_name: None, |
1487 | description: Some( | 1487 | description: Some( |
1488 | "struct S", | 1488 | "struct S", |
@@ -1497,11 +1497,11 @@ fn main() { let s<|>t = S{ f1:Arg(0) }; } | |||
1497 | 1, | 1497 | 1, |
1498 | ), | 1498 | ), |
1499 | full_range: 0..16, | 1499 | full_range: 0..16, |
1500 | name: "Arg", | ||
1501 | kind: STRUCT_DEF, | ||
1502 | focus_range: Some( | 1500 | focus_range: Some( |
1503 | 7..10, | 1501 | 7..10, |
1504 | ), | 1502 | ), |
1503 | name: "Arg", | ||
1504 | kind: STRUCT_DEF, | ||
1505 | container_name: None, | 1505 | container_name: None, |
1506 | description: Some( | 1506 | description: Some( |
1507 | "struct Arg", | 1507 | "struct Arg", |
@@ -1536,11 +1536,11 @@ fn main() { let s<|>t = S{ f1: S{ f1: Arg(0) } }; } | |||
1536 | 1, | 1536 | 1, |
1537 | ), | 1537 | ), |
1538 | full_range: 17..37, | 1538 | full_range: 17..37, |
1539 | name: "S", | ||
1540 | kind: STRUCT_DEF, | ||
1541 | focus_range: Some( | 1539 | focus_range: Some( |
1542 | 24..25, | 1540 | 24..25, |
1543 | ), | 1541 | ), |
1542 | name: "S", | ||
1543 | kind: STRUCT_DEF, | ||
1544 | container_name: None, | 1544 | container_name: None, |
1545 | description: Some( | 1545 | description: Some( |
1546 | "struct S", | 1546 | "struct S", |
@@ -1555,11 +1555,11 @@ fn main() { let s<|>t = S{ f1: S{ f1: Arg(0) } }; } | |||
1555 | 1, | 1555 | 1, |
1556 | ), | 1556 | ), |
1557 | full_range: 0..16, | 1557 | full_range: 0..16, |
1558 | name: "Arg", | ||
1559 | kind: STRUCT_DEF, | ||
1560 | focus_range: Some( | 1558 | focus_range: Some( |
1561 | 7..10, | 1559 | 7..10, |
1562 | ), | 1560 | ), |
1561 | name: "Arg", | ||
1562 | kind: STRUCT_DEF, | ||
1563 | container_name: None, | 1563 | container_name: None, |
1564 | description: Some( | 1564 | description: Some( |
1565 | "struct Arg", | 1565 | "struct Arg", |
@@ -1597,11 +1597,11 @@ fn main() { let s<|>t = (A(1), B(2), M::C(3) ); } | |||
1597 | 1, | 1597 | 1, |
1598 | ), | 1598 | ), |
1599 | full_range: 0..14, | 1599 | full_range: 0..14, |
1600 | name: "A", | ||
1601 | kind: STRUCT_DEF, | ||
1602 | focus_range: Some( | 1600 | focus_range: Some( |
1603 | 7..8, | 1601 | 7..8, |
1604 | ), | 1602 | ), |
1603 | name: "A", | ||
1604 | kind: STRUCT_DEF, | ||
1605 | container_name: None, | 1605 | container_name: None, |
1606 | description: Some( | 1606 | description: Some( |
1607 | "struct A", | 1607 | "struct A", |
@@ -1616,11 +1616,11 @@ fn main() { let s<|>t = (A(1), B(2), M::C(3) ); } | |||
1616 | 1, | 1616 | 1, |
1617 | ), | 1617 | ), |
1618 | full_range: 15..29, | 1618 | full_range: 15..29, |
1619 | name: "B", | ||
1620 | kind: STRUCT_DEF, | ||
1621 | focus_range: Some( | 1619 | focus_range: Some( |
1622 | 22..23, | 1620 | 22..23, |
1623 | ), | 1621 | ), |
1622 | name: "B", | ||
1623 | kind: STRUCT_DEF, | ||
1624 | container_name: None, | 1624 | container_name: None, |
1625 | description: Some( | 1625 | description: Some( |
1626 | "struct B", | 1626 | "struct B", |
@@ -1635,11 +1635,11 @@ fn main() { let s<|>t = (A(1), B(2), M::C(3) ); } | |||
1635 | 1, | 1635 | 1, |
1636 | ), | 1636 | ), |
1637 | full_range: 42..60, | 1637 | full_range: 42..60, |
1638 | name: "C", | ||
1639 | kind: STRUCT_DEF, | ||
1640 | focus_range: Some( | 1638 | focus_range: Some( |
1641 | 53..54, | 1639 | 53..54, |
1642 | ), | 1640 | ), |
1641 | name: "C", | ||
1642 | kind: STRUCT_DEF, | ||
1643 | container_name: None, | 1643 | container_name: None, |
1644 | description: Some( | 1644 | description: Some( |
1645 | "pub struct C", | 1645 | "pub struct C", |
@@ -1674,11 +1674,11 @@ fn main() { let s<|>t = foo(); } | |||
1674 | 1, | 1674 | 1, |
1675 | ), | 1675 | ), |
1676 | full_range: 0..12, | 1676 | full_range: 0..12, |
1677 | name: "Foo", | ||
1678 | kind: TRAIT_DEF, | ||
1679 | focus_range: Some( | 1677 | focus_range: Some( |
1680 | 6..9, | 1678 | 6..9, |
1681 | ), | 1679 | ), |
1680 | name: "Foo", | ||
1681 | kind: TRAIT_DEF, | ||
1682 | container_name: None, | 1682 | container_name: None, |
1683 | description: Some( | 1683 | description: Some( |
1684 | "trait Foo", | 1684 | "trait Foo", |
@@ -1714,11 +1714,11 @@ fn main() { let s<|>t = foo(); } | |||
1714 | 1, | 1714 | 1, |
1715 | ), | 1715 | ), |
1716 | full_range: 0..15, | 1716 | full_range: 0..15, |
1717 | name: "Foo", | ||
1718 | kind: TRAIT_DEF, | ||
1719 | focus_range: Some( | 1717 | focus_range: Some( |
1720 | 6..9, | 1718 | 6..9, |
1721 | ), | 1719 | ), |
1720 | name: "Foo", | ||
1721 | kind: TRAIT_DEF, | ||
1722 | container_name: None, | 1722 | container_name: None, |
1723 | description: Some( | 1723 | description: Some( |
1724 | "trait Foo", | 1724 | "trait Foo", |
@@ -1733,11 +1733,11 @@ fn main() { let s<|>t = foo(); } | |||
1733 | 1, | 1733 | 1, |
1734 | ), | 1734 | ), |
1735 | full_range: 16..25, | 1735 | full_range: 16..25, |
1736 | name: "S", | ||
1737 | kind: STRUCT_DEF, | ||
1738 | focus_range: Some( | 1736 | focus_range: Some( |
1739 | 23..24, | 1737 | 23..24, |
1740 | ), | 1738 | ), |
1739 | name: "S", | ||
1740 | kind: STRUCT_DEF, | ||
1741 | container_name: None, | 1741 | container_name: None, |
1742 | description: Some( | 1742 | description: Some( |
1743 | "struct S", | 1743 | "struct S", |
@@ -1773,11 +1773,11 @@ fn main() { let s<|>t = foo(); } | |||
1773 | 1, | 1773 | 1, |
1774 | ), | 1774 | ), |
1775 | full_range: 0..12, | 1775 | full_range: 0..12, |
1776 | name: "Foo", | ||
1777 | kind: TRAIT_DEF, | ||
1778 | focus_range: Some( | 1776 | focus_range: Some( |
1779 | 6..9, | 1777 | 6..9, |
1780 | ), | 1778 | ), |
1779 | name: "Foo", | ||
1780 | kind: TRAIT_DEF, | ||
1781 | container_name: None, | 1781 | container_name: None, |
1782 | description: Some( | 1782 | description: Some( |
1783 | "trait Foo", | 1783 | "trait Foo", |
@@ -1792,11 +1792,11 @@ fn main() { let s<|>t = foo(); } | |||
1792 | 1, | 1792 | 1, |
1793 | ), | 1793 | ), |
1794 | full_range: 13..25, | 1794 | full_range: 13..25, |
1795 | name: "Bar", | ||
1796 | kind: TRAIT_DEF, | ||
1797 | focus_range: Some( | 1795 | focus_range: Some( |
1798 | 19..22, | 1796 | 19..22, |
1799 | ), | 1797 | ), |
1798 | name: "Bar", | ||
1799 | kind: TRAIT_DEF, | ||
1800 | container_name: None, | 1800 | container_name: None, |
1801 | description: Some( | 1801 | description: Some( |
1802 | "trait Bar", | 1802 | "trait Bar", |
@@ -1835,11 +1835,11 @@ fn main() { let s<|>t = foo(); } | |||
1835 | 1, | 1835 | 1, |
1836 | ), | 1836 | ), |
1837 | full_range: 0..15, | 1837 | full_range: 0..15, |
1838 | name: "Foo", | ||
1839 | kind: TRAIT_DEF, | ||
1840 | focus_range: Some( | 1838 | focus_range: Some( |
1841 | 6..9, | 1839 | 6..9, |
1842 | ), | 1840 | ), |
1841 | name: "Foo", | ||
1842 | kind: TRAIT_DEF, | ||
1843 | container_name: None, | 1843 | container_name: None, |
1844 | description: Some( | 1844 | description: Some( |
1845 | "trait Foo", | 1845 | "trait Foo", |
@@ -1854,11 +1854,11 @@ fn main() { let s<|>t = foo(); } | |||
1854 | 1, | 1854 | 1, |
1855 | ), | 1855 | ), |
1856 | full_range: 16..31, | 1856 | full_range: 16..31, |
1857 | name: "Bar", | ||
1858 | kind: TRAIT_DEF, | ||
1859 | focus_range: Some( | 1857 | focus_range: Some( |
1860 | 22..25, | 1858 | 22..25, |
1861 | ), | 1859 | ), |
1860 | name: "Bar", | ||
1861 | kind: TRAIT_DEF, | ||
1862 | container_name: None, | 1862 | container_name: None, |
1863 | description: Some( | 1863 | description: Some( |
1864 | "trait Bar", | 1864 | "trait Bar", |
@@ -1873,11 +1873,11 @@ fn main() { let s<|>t = foo(); } | |||
1873 | 1, | 1873 | 1, |
1874 | ), | 1874 | ), |
1875 | full_range: 32..44, | 1875 | full_range: 32..44, |
1876 | name: "S1", | ||
1877 | kind: STRUCT_DEF, | ||
1878 | focus_range: Some( | 1876 | focus_range: Some( |
1879 | 39..41, | 1877 | 39..41, |
1880 | ), | 1878 | ), |
1879 | name: "S1", | ||
1880 | kind: STRUCT_DEF, | ||
1881 | container_name: None, | 1881 | container_name: None, |
1882 | description: Some( | 1882 | description: Some( |
1883 | "struct S1", | 1883 | "struct S1", |
@@ -1892,11 +1892,11 @@ fn main() { let s<|>t = foo(); } | |||
1892 | 1, | 1892 | 1, |
1893 | ), | 1893 | ), |
1894 | full_range: 45..57, | 1894 | full_range: 45..57, |
1895 | name: "S2", | ||
1896 | kind: STRUCT_DEF, | ||
1897 | focus_range: Some( | 1895 | focus_range: Some( |
1898 | 52..54, | 1896 | 52..54, |
1899 | ), | 1897 | ), |
1898 | name: "S2", | ||
1899 | kind: STRUCT_DEF, | ||
1900 | container_name: None, | 1900 | container_name: None, |
1901 | description: Some( | 1901 | description: Some( |
1902 | "struct S2", | 1902 | "struct S2", |
@@ -1929,11 +1929,11 @@ fn foo(ar<|>g: &impl Foo) {} | |||
1929 | 1, | 1929 | 1, |
1930 | ), | 1930 | ), |
1931 | full_range: 0..12, | 1931 | full_range: 0..12, |
1932 | name: "Foo", | ||
1933 | kind: TRAIT_DEF, | ||
1934 | focus_range: Some( | 1932 | focus_range: Some( |
1935 | 6..9, | 1933 | 6..9, |
1936 | ), | 1934 | ), |
1935 | name: "Foo", | ||
1936 | kind: TRAIT_DEF, | ||
1937 | container_name: None, | 1937 | container_name: None, |
1938 | description: Some( | 1938 | description: Some( |
1939 | "trait Foo", | 1939 | "trait Foo", |
@@ -1969,11 +1969,11 @@ fn foo(ar<|>g: &impl Foo + Bar<S>) {} | |||
1969 | 1, | 1969 | 1, |
1970 | ), | 1970 | ), |
1971 | full_range: 0..12, | 1971 | full_range: 0..12, |
1972 | name: "Foo", | ||
1973 | kind: TRAIT_DEF, | ||
1974 | focus_range: Some( | 1972 | focus_range: Some( |
1975 | 6..9, | 1973 | 6..9, |
1976 | ), | 1974 | ), |
1975 | name: "Foo", | ||
1976 | kind: TRAIT_DEF, | ||
1977 | container_name: None, | 1977 | container_name: None, |
1978 | description: Some( | 1978 | description: Some( |
1979 | "trait Foo", | 1979 | "trait Foo", |
@@ -1988,11 +1988,11 @@ fn foo(ar<|>g: &impl Foo + Bar<S>) {} | |||
1988 | 1, | 1988 | 1, |
1989 | ), | 1989 | ), |
1990 | full_range: 13..28, | 1990 | full_range: 13..28, |
1991 | name: "Bar", | ||
1992 | kind: TRAIT_DEF, | ||
1993 | focus_range: Some( | 1991 | focus_range: Some( |
1994 | 19..22, | 1992 | 19..22, |
1995 | ), | 1993 | ), |
1994 | name: "Bar", | ||
1995 | kind: TRAIT_DEF, | ||
1996 | container_name: None, | 1996 | container_name: None, |
1997 | description: Some( | 1997 | description: Some( |
1998 | "trait Bar", | 1998 | "trait Bar", |
@@ -2007,11 +2007,11 @@ fn foo(ar<|>g: &impl Foo + Bar<S>) {} | |||
2007 | 1, | 2007 | 1, |
2008 | ), | 2008 | ), |
2009 | full_range: 29..39, | 2009 | full_range: 29..39, |
2010 | name: "S", | ||
2011 | kind: STRUCT_DEF, | ||
2012 | focus_range: Some( | 2010 | focus_range: Some( |
2013 | 36..37, | 2011 | 36..37, |
2014 | ), | 2012 | ), |
2013 | name: "S", | ||
2014 | kind: STRUCT_DEF, | ||
2015 | container_name: None, | 2015 | container_name: None, |
2016 | description: Some( | 2016 | description: Some( |
2017 | "struct S", | 2017 | "struct S", |
@@ -2045,11 +2045,11 @@ fn foo(ar<|>g: &impl Foo<S>) {} | |||
2045 | 1, | 2045 | 1, |
2046 | ), | 2046 | ), |
2047 | full_range: 0..15, | 2047 | full_range: 0..15, |
2048 | name: "Foo", | ||
2049 | kind: TRAIT_DEF, | ||
2050 | focus_range: Some( | 2048 | focus_range: Some( |
2051 | 6..9, | 2049 | 6..9, |
2052 | ), | 2050 | ), |
2051 | name: "Foo", | ||
2052 | kind: TRAIT_DEF, | ||
2053 | container_name: None, | 2053 | container_name: None, |
2054 | description: Some( | 2054 | description: Some( |
2055 | "trait Foo", | 2055 | "trait Foo", |
@@ -2064,11 +2064,11 @@ fn foo(ar<|>g: &impl Foo<S>) {} | |||
2064 | 1, | 2064 | 1, |
2065 | ), | 2065 | ), |
2066 | full_range: 16..27, | 2066 | full_range: 16..27, |
2067 | name: "S", | ||
2068 | kind: STRUCT_DEF, | ||
2069 | focus_range: Some( | 2067 | focus_range: Some( |
2070 | 23..24, | 2068 | 23..24, |
2071 | ), | 2069 | ), |
2070 | name: "S", | ||
2071 | kind: STRUCT_DEF, | ||
2072 | container_name: None, | 2072 | container_name: None, |
2073 | description: Some( | 2073 | description: Some( |
2074 | "struct S", | 2074 | "struct S", |
@@ -2107,11 +2107,11 @@ fn main() { let s<|>t = foo(); } | |||
2107 | 1, | 2107 | 1, |
2108 | ), | 2108 | ), |
2109 | full_range: 42..55, | 2109 | full_range: 42..55, |
2110 | name: "B", | ||
2111 | kind: STRUCT_DEF, | ||
2112 | focus_range: Some( | 2110 | focus_range: Some( |
2113 | 49..50, | 2111 | 49..50, |
2114 | ), | 2112 | ), |
2113 | name: "B", | ||
2114 | kind: STRUCT_DEF, | ||
2115 | container_name: None, | 2115 | container_name: None, |
2116 | description: Some( | 2116 | description: Some( |
2117 | "struct B", | 2117 | "struct B", |
@@ -2126,11 +2126,11 @@ fn main() { let s<|>t = foo(); } | |||
2126 | 1, | 2126 | 1, |
2127 | ), | 2127 | ), |
2128 | full_range: 0..12, | 2128 | full_range: 0..12, |
2129 | name: "Foo", | ||
2130 | kind: TRAIT_DEF, | ||
2131 | focus_range: Some( | 2129 | focus_range: Some( |
2132 | 6..9, | 2130 | 6..9, |
2133 | ), | 2131 | ), |
2132 | name: "Foo", | ||
2133 | kind: TRAIT_DEF, | ||
2134 | container_name: None, | 2134 | container_name: None, |
2135 | description: Some( | 2135 | description: Some( |
2136 | "trait Foo", | 2136 | "trait Foo", |
@@ -2163,11 +2163,11 @@ fn foo(ar<|>g: &dyn Foo) {} | |||
2163 | 1, | 2163 | 1, |
2164 | ), | 2164 | ), |
2165 | full_range: 0..12, | 2165 | full_range: 0..12, |
2166 | name: "Foo", | ||
2167 | kind: TRAIT_DEF, | ||
2168 | focus_range: Some( | 2166 | focus_range: Some( |
2169 | 6..9, | 2167 | 6..9, |
2170 | ), | 2168 | ), |
2169 | name: "Foo", | ||
2170 | kind: TRAIT_DEF, | ||
2171 | container_name: None, | 2171 | container_name: None, |
2172 | description: Some( | 2172 | description: Some( |
2173 | "trait Foo", | 2173 | "trait Foo", |
@@ -2201,11 +2201,11 @@ fn foo(ar<|>g: &dyn Foo<S>) {} | |||
2201 | 1, | 2201 | 1, |
2202 | ), | 2202 | ), |
2203 | full_range: 0..15, | 2203 | full_range: 0..15, |
2204 | name: "Foo", | ||
2205 | kind: TRAIT_DEF, | ||
2206 | focus_range: Some( | 2204 | focus_range: Some( |
2207 | 6..9, | 2205 | 6..9, |
2208 | ), | 2206 | ), |
2207 | name: "Foo", | ||
2208 | kind: TRAIT_DEF, | ||
2209 | container_name: None, | 2209 | container_name: None, |
2210 | description: Some( | 2210 | description: Some( |
2211 | "trait Foo", | 2211 | "trait Foo", |
@@ -2220,11 +2220,11 @@ fn foo(ar<|>g: &dyn Foo<S>) {} | |||
2220 | 1, | 2220 | 1, |
2221 | ), | 2221 | ), |
2222 | full_range: 16..27, | 2222 | full_range: 16..27, |
2223 | name: "S", | ||
2224 | kind: STRUCT_DEF, | ||
2225 | focus_range: Some( | 2223 | focus_range: Some( |
2226 | 23..24, | 2224 | 23..24, |
2227 | ), | 2225 | ), |
2226 | name: "S", | ||
2227 | kind: STRUCT_DEF, | ||
2228 | container_name: None, | 2228 | container_name: None, |
2229 | description: Some( | 2229 | description: Some( |
2230 | "struct S", | 2230 | "struct S", |
@@ -2261,11 +2261,11 @@ fn foo(a<|>rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {} | |||
2261 | 1, | 2261 | 1, |
2262 | ), | 2262 | ), |
2263 | full_range: 0..21, | 2263 | full_range: 0..21, |
2264 | name: "ImplTrait", | ||
2265 | kind: TRAIT_DEF, | ||
2266 | focus_range: Some( | 2264 | focus_range: Some( |
2267 | 6..15, | 2265 | 6..15, |
2268 | ), | 2266 | ), |
2267 | name: "ImplTrait", | ||
2268 | kind: TRAIT_DEF, | ||
2269 | container_name: None, | 2269 | container_name: None, |
2270 | description: Some( | 2270 | description: Some( |
2271 | "trait ImplTrait", | 2271 | "trait ImplTrait", |
@@ -2280,11 +2280,11 @@ fn foo(a<|>rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {} | |||
2280 | 1, | 2280 | 1, |
2281 | ), | 2281 | ), |
2282 | full_range: 43..57, | 2282 | full_range: 43..57, |
2283 | name: "B", | ||
2284 | kind: STRUCT_DEF, | ||
2285 | focus_range: Some( | 2283 | focus_range: Some( |
2286 | 50..51, | 2284 | 50..51, |
2287 | ), | 2285 | ), |
2286 | name: "B", | ||
2287 | kind: STRUCT_DEF, | ||
2288 | container_name: None, | 2288 | container_name: None, |
2289 | description: Some( | 2289 | description: Some( |
2290 | "struct B", | 2290 | "struct B", |
@@ -2299,11 +2299,11 @@ fn foo(a<|>rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {} | |||
2299 | 1, | 2299 | 1, |
2300 | ), | 2300 | ), |
2301 | full_range: 22..42, | 2301 | full_range: 22..42, |
2302 | name: "DynTrait", | ||
2303 | kind: TRAIT_DEF, | ||
2304 | focus_range: Some( | 2302 | focus_range: Some( |
2305 | 28..36, | 2303 | 28..36, |
2306 | ), | 2304 | ), |
2305 | name: "DynTrait", | ||
2306 | kind: TRAIT_DEF, | ||
2307 | container_name: None, | 2307 | container_name: None, |
2308 | description: Some( | 2308 | description: Some( |
2309 | "trait DynTrait", | 2309 | "trait DynTrait", |
@@ -2318,11 +2318,11 @@ fn foo(a<|>rg: &impl ImplTrait<B<dyn DynTrait<B<S>>>>) {} | |||
2318 | 1, | 2318 | 1, |
2319 | ), | 2319 | ), |
2320 | full_range: 58..69, | 2320 | full_range: 58..69, |
2321 | name: "S", | ||
2322 | kind: STRUCT_DEF, | ||
2323 | focus_range: Some( | 2321 | focus_range: Some( |
2324 | 65..66, | 2322 | 65..66, |
2325 | ), | 2323 | ), |
2324 | name: "S", | ||
2325 | kind: STRUCT_DEF, | ||
2326 | container_name: None, | 2326 | container_name: None, |
2327 | description: Some( | 2327 | description: Some( |
2328 | "struct S", | 2328 | "struct S", |
@@ -2366,11 +2366,11 @@ fn main() { let s<|>t = test().get(); } | |||
2366 | 1, | 2366 | 1, |
2367 | ), | 2367 | ), |
2368 | full_range: 0..62, | 2368 | full_range: 0..62, |
2369 | name: "Foo", | ||
2370 | kind: TRAIT_DEF, | ||
2371 | focus_range: Some( | 2369 | focus_range: Some( |
2372 | 6..9, | 2370 | 6..9, |
2373 | ), | 2371 | ), |
2372 | name: "Foo", | ||
2373 | kind: TRAIT_DEF, | ||
2374 | container_name: None, | 2374 | container_name: None, |
2375 | description: Some( | 2375 | description: Some( |
2376 | "trait Foo", | 2376 | "trait Foo", |
diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs index d3b20f371..353f430ff 100644 --- a/crates/ra_ide/src/lib.rs +++ b/crates/ra_ide/src/lib.rs | |||
@@ -545,8 +545,8 @@ mod tests { | |||
545 | 545 | ||
546 | let s = symbols.pop().unwrap(); | 546 | let s = symbols.pop().unwrap(); |
547 | 547 | ||
548 | assert_eq!(s.name(), "FooInner"); | 548 | assert_eq!(s.name, "FooInner"); |
549 | assert!(s.container_name().is_none()); | 549 | assert!(s.container_name.is_none()); |
550 | } | 550 | } |
551 | 551 | ||
552 | #[test] | 552 | #[test] |
@@ -561,8 +561,8 @@ fn foo() { | |||
561 | 561 | ||
562 | let s = symbols.pop().unwrap(); | 562 | let s = symbols.pop().unwrap(); |
563 | 563 | ||
564 | assert_eq!(s.name(), "FooInner"); | 564 | assert_eq!(s.name, "FooInner"); |
565 | assert_eq!(s.container_name(), Some(&SmolStr::new("foo"))); | 565 | assert_eq!(s.container_name, Some(SmolStr::new("foo"))); |
566 | 566 | ||
567 | let code = r#" | 567 | let code = r#" |
568 | mod foo { | 568 | mod foo { |
@@ -574,8 +574,8 @@ mod foo { | |||
574 | 574 | ||
575 | let s = symbols.pop().unwrap(); | 575 | let s = symbols.pop().unwrap(); |
576 | 576 | ||
577 | assert_eq!(s.name(), "FooInner"); | 577 | assert_eq!(s.name, "FooInner"); |
578 | assert_eq!(s.container_name(), Some(&SmolStr::new("foo"))); | 578 | assert_eq!(s.container_name, Some(SmolStr::new("foo"))); |
579 | } | 579 | } |
580 | 580 | ||
581 | #[test] | 581 | #[test] |
@@ -588,8 +588,8 @@ struct Foo; | |||
588 | 588 | ||
589 | let symbols = get_symbols_matching(code, "Foo"); | 589 | let symbols = get_symbols_matching(code, "Foo"); |
590 | 590 | ||
591 | let fn_match = symbols.iter().find(|s| s.name() == "foo").map(|s| s.kind()); | 591 | let fn_match = symbols.iter().find(|s| s.name == "foo").map(|s| s.kind); |
592 | let struct_match = symbols.iter().find(|s| s.name() == "Foo").map(|s| s.kind()); | 592 | let struct_match = symbols.iter().find(|s| s.name == "Foo").map(|s| s.kind); |
593 | 593 | ||
594 | assert_eq!(fn_match, Some(FN_DEF)); | 594 | assert_eq!(fn_match, Some(FN_DEF)); |
595 | assert_eq!(struct_match, Some(STRUCT_DEF)); | 595 | assert_eq!(struct_match, Some(STRUCT_DEF)); |
diff --git a/crates/ra_ide/src/references.rs b/crates/ra_ide/src/references.rs index c2b0d5efe..fe1c074d1 100644 --- a/crates/ra_ide/src/references.rs +++ b/crates/ra_ide/src/references.rs | |||
@@ -74,8 +74,8 @@ impl IntoIterator for ReferenceSearchResult { | |||
74 | let mut v = Vec::with_capacity(self.len()); | 74 | let mut v = Vec::with_capacity(self.len()); |
75 | v.push(Reference { | 75 | v.push(Reference { |
76 | file_range: FileRange { | 76 | file_range: FileRange { |
77 | file_id: self.declaration.nav.file_id(), | 77 | file_id: self.declaration.nav.file_id, |
78 | range: self.declaration.nav.range(), | 78 | range: self.declaration.nav.focus_or_full_range(), |
79 | }, | 79 | }, |
80 | kind: self.declaration.kind, | 80 | kind: self.declaration.kind, |
81 | access: self.declaration.access, | 81 | access: self.declaration.access, |
@@ -112,7 +112,7 @@ pub(crate) fn find_all_refs( | |||
112 | .filter(|r| search_kind == ReferenceKind::Other || search_kind == r.kind) | 112 | .filter(|r| search_kind == ReferenceKind::Other || search_kind == r.kind) |
113 | .collect(); | 113 | .collect(); |
114 | 114 | ||
115 | let decl_range = def.try_to_nav(sema.db)?.range(); | 115 | let decl_range = def.try_to_nav(sema.db)?.focus_or_full_range(); |
116 | 116 | ||
117 | let declaration = Declaration { | 117 | let declaration = Declaration { |
118 | nav: def.try_to_nav(sema.db)?, | 118 | nav: def.try_to_nav(sema.db)?, |
diff --git a/crates/ra_ide/src/runnables.rs b/crates/ra_ide/src/runnables.rs index ed15d6494..0994beec5 100644 --- a/crates/ra_ide/src/runnables.rs +++ b/crates/ra_ide/src/runnables.rs | |||
@@ -299,11 +299,11 @@ fn bench() {} | |||
299 | 1, | 299 | 1, |
300 | ), | 300 | ), |
301 | full_range: 1..13, | 301 | full_range: 1..13, |
302 | name: "main", | ||
303 | kind: FN_DEF, | ||
304 | focus_range: Some( | 302 | focus_range: Some( |
305 | 4..8, | 303 | 4..8, |
306 | ), | 304 | ), |
305 | name: "main", | ||
306 | kind: FN_DEF, | ||
307 | container_name: None, | 307 | container_name: None, |
308 | description: None, | 308 | description: None, |
309 | docs: None, | 309 | docs: None, |
@@ -317,11 +317,11 @@ fn bench() {} | |||
317 | 1, | 317 | 1, |
318 | ), | 318 | ), |
319 | full_range: 15..39, | 319 | full_range: 15..39, |
320 | name: "test_foo", | ||
321 | kind: FN_DEF, | ||
322 | focus_range: Some( | 320 | focus_range: Some( |
323 | 26..34, | 321 | 26..34, |
324 | ), | 322 | ), |
323 | name: "test_foo", | ||
324 | kind: FN_DEF, | ||
325 | container_name: None, | 325 | container_name: None, |
326 | description: None, | 326 | description: None, |
327 | docs: None, | 327 | docs: None, |
@@ -342,11 +342,11 @@ fn bench() {} | |||
342 | 1, | 342 | 1, |
343 | ), | 343 | ), |
344 | full_range: 41..75, | 344 | full_range: 41..75, |
345 | name: "test_foo", | ||
346 | kind: FN_DEF, | ||
347 | focus_range: Some( | 345 | focus_range: Some( |
348 | 62..70, | 346 | 62..70, |
349 | ), | 347 | ), |
348 | name: "test_foo", | ||
349 | kind: FN_DEF, | ||
350 | container_name: None, | 350 | container_name: None, |
351 | description: None, | 351 | description: None, |
352 | docs: None, | 352 | docs: None, |
@@ -367,11 +367,11 @@ fn bench() {} | |||
367 | 1, | 367 | 1, |
368 | ), | 368 | ), |
369 | full_range: 77..99, | 369 | full_range: 77..99, |
370 | name: "bench", | ||
371 | kind: FN_DEF, | ||
372 | focus_range: Some( | 370 | focus_range: Some( |
373 | 89..94, | 371 | 89..94, |
374 | ), | 372 | ), |
373 | name: "bench", | ||
374 | kind: FN_DEF, | ||
375 | container_name: None, | 375 | container_name: None, |
376 | description: None, | 376 | description: None, |
377 | docs: None, | 377 | docs: None, |
@@ -410,11 +410,11 @@ fn foo() {} | |||
410 | 1, | 410 | 1, |
411 | ), | 411 | ), |
412 | full_range: 1..13, | 412 | full_range: 1..13, |
413 | name: "main", | ||
414 | kind: FN_DEF, | ||
415 | focus_range: Some( | 413 | focus_range: Some( |
416 | 4..8, | 414 | 4..8, |
417 | ), | 415 | ), |
416 | name: "main", | ||
417 | kind: FN_DEF, | ||
418 | container_name: None, | 418 | container_name: None, |
419 | description: None, | 419 | description: None, |
420 | docs: None, | 420 | docs: None, |
@@ -428,9 +428,9 @@ fn foo() {} | |||
428 | 1, | 428 | 1, |
429 | ), | 429 | ), |
430 | full_range: 15..57, | 430 | full_range: 15..57, |
431 | focus_range: None, | ||
431 | name: "foo", | 432 | name: "foo", |
432 | kind: FN_DEF, | 433 | kind: FN_DEF, |
433 | focus_range: None, | ||
434 | container_name: None, | 434 | container_name: None, |
435 | description: None, | 435 | description: None, |
436 | docs: None, | 436 | docs: None, |
@@ -472,11 +472,11 @@ impl Data { | |||
472 | 1, | 472 | 1, |
473 | ), | 473 | ), |
474 | full_range: 1..13, | 474 | full_range: 1..13, |
475 | name: "main", | ||
476 | kind: FN_DEF, | ||
477 | focus_range: Some( | 475 | focus_range: Some( |
478 | 4..8, | 476 | 4..8, |
479 | ), | 477 | ), |
478 | name: "main", | ||
479 | kind: FN_DEF, | ||
480 | container_name: None, | 480 | container_name: None, |
481 | description: None, | 481 | description: None, |
482 | docs: None, | 482 | docs: None, |
@@ -490,9 +490,9 @@ impl Data { | |||
490 | 1, | 490 | 1, |
491 | ), | 491 | ), |
492 | full_range: 44..98, | 492 | full_range: 44..98, |
493 | focus_range: None, | ||
493 | name: "foo", | 494 | name: "foo", |
494 | kind: FN_DEF, | 495 | kind: FN_DEF, |
495 | focus_range: None, | ||
496 | container_name: None, | 496 | container_name: None, |
497 | description: None, | 497 | description: None, |
498 | docs: None, | 498 | docs: None, |
@@ -529,11 +529,11 @@ mod test_mod { | |||
529 | 1, | 529 | 1, |
530 | ), | 530 | ), |
531 | full_range: 1..51, | 531 | full_range: 1..51, |
532 | name: "test_mod", | ||
533 | kind: MODULE, | ||
534 | focus_range: Some( | 532 | focus_range: Some( |
535 | 5..13, | 533 | 5..13, |
536 | ), | 534 | ), |
535 | name: "test_mod", | ||
536 | kind: MODULE, | ||
537 | container_name: None, | 537 | container_name: None, |
538 | description: None, | 538 | description: None, |
539 | docs: None, | 539 | docs: None, |
@@ -549,11 +549,11 @@ mod test_mod { | |||
549 | 1, | 549 | 1, |
550 | ), | 550 | ), |
551 | full_range: 20..49, | 551 | full_range: 20..49, |
552 | name: "test_foo1", | ||
553 | kind: FN_DEF, | ||
554 | focus_range: Some( | 552 | focus_range: Some( |
555 | 35..44, | 553 | 35..44, |
556 | ), | 554 | ), |
555 | name: "test_foo1", | ||
556 | kind: FN_DEF, | ||
557 | container_name: None, | 557 | container_name: None, |
558 | description: None, | 558 | description: None, |
559 | docs: None, | 559 | docs: None, |
@@ -595,11 +595,11 @@ mod foo { | |||
595 | 1, | 595 | 1, |
596 | ), | 596 | ), |
597 | full_range: 15..77, | 597 | full_range: 15..77, |
598 | name: "test_mod", | ||
599 | kind: MODULE, | ||
600 | focus_range: Some( | 598 | focus_range: Some( |
601 | 19..27, | 599 | 19..27, |
602 | ), | 600 | ), |
601 | name: "test_mod", | ||
602 | kind: MODULE, | ||
603 | container_name: None, | 603 | container_name: None, |
604 | description: None, | 604 | description: None, |
605 | docs: None, | 605 | docs: None, |
@@ -615,11 +615,11 @@ mod foo { | |||
615 | 1, | 615 | 1, |
616 | ), | 616 | ), |
617 | full_range: 38..71, | 617 | full_range: 38..71, |
618 | name: "test_foo1", | ||
619 | kind: FN_DEF, | ||
620 | focus_range: Some( | 618 | focus_range: Some( |
621 | 57..66, | 619 | 57..66, |
622 | ), | 620 | ), |
621 | name: "test_foo1", | ||
622 | kind: FN_DEF, | ||
623 | container_name: None, | 623 | container_name: None, |
624 | description: None, | 624 | description: None, |
625 | docs: None, | 625 | docs: None, |
@@ -663,11 +663,11 @@ mod foo { | |||
663 | 1, | 663 | 1, |
664 | ), | 664 | ), |
665 | full_range: 33..107, | 665 | full_range: 33..107, |
666 | name: "test_mod", | ||
667 | kind: MODULE, | ||
668 | focus_range: Some( | 666 | focus_range: Some( |
669 | 37..45, | 667 | 37..45, |
670 | ), | 668 | ), |
669 | name: "test_mod", | ||
670 | kind: MODULE, | ||
671 | container_name: None, | 671 | container_name: None, |
672 | description: None, | 672 | description: None, |
673 | docs: None, | 673 | docs: None, |
@@ -683,11 +683,11 @@ mod foo { | |||
683 | 1, | 683 | 1, |
684 | ), | 684 | ), |
685 | full_range: 60..97, | 685 | full_range: 60..97, |
686 | name: "test_foo1", | ||
687 | kind: FN_DEF, | ||
688 | focus_range: Some( | 686 | focus_range: Some( |
689 | 83..92, | 687 | 83..92, |
690 | ), | 688 | ), |
689 | name: "test_foo1", | ||
690 | kind: FN_DEF, | ||
691 | container_name: None, | 691 | container_name: None, |
692 | description: None, | 692 | description: None, |
693 | docs: None, | 693 | docs: None, |
@@ -726,11 +726,11 @@ fn test_foo1() {} | |||
726 | 1, | 726 | 1, |
727 | ), | 727 | ), |
728 | full_range: 1..50, | 728 | full_range: 1..50, |
729 | name: "test_foo1", | ||
730 | kind: FN_DEF, | ||
731 | focus_range: Some( | 729 | focus_range: Some( |
732 | 36..45, | 730 | 36..45, |
733 | ), | 731 | ), |
732 | name: "test_foo1", | ||
733 | kind: FN_DEF, | ||
734 | container_name: None, | 734 | container_name: None, |
735 | description: None, | 735 | description: None, |
736 | docs: None, | 736 | docs: None, |
@@ -774,11 +774,11 @@ fn test_foo1() {} | |||
774 | 1, | 774 | 1, |
775 | ), | 775 | ), |
776 | full_range: 1..72, | 776 | full_range: 1..72, |
777 | name: "test_foo1", | ||
778 | kind: FN_DEF, | ||
779 | focus_range: Some( | 777 | focus_range: Some( |
780 | 58..67, | 778 | 58..67, |
781 | ), | 779 | ), |
780 | name: "test_foo1", | ||
781 | kind: FN_DEF, | ||
782 | container_name: None, | 782 | container_name: None, |
783 | description: None, | 783 | description: None, |
784 | docs: None, | 784 | docs: None, |
diff --git a/crates/rust-analyzer/src/handlers.rs b/crates/rust-analyzer/src/handlers.rs index 18d660f42..326977b62 100644 --- a/crates/rust-analyzer/src/handlers.rs +++ b/crates/rust-analyzer/src/handlers.rs | |||
@@ -341,10 +341,10 @@ pub(crate) fn handle_workspace_symbol( | |||
341 | fn exec_query(snap: &GlobalStateSnapshot, query: Query) -> Result<Vec<SymbolInformation>> { | 341 | fn exec_query(snap: &GlobalStateSnapshot, query: Query) -> Result<Vec<SymbolInformation>> { |
342 | let mut res = Vec::new(); | 342 | let mut res = Vec::new(); |
343 | for nav in snap.analysis.symbol_search(query)? { | 343 | for nav in snap.analysis.symbol_search(query)? { |
344 | let container_name = nav.container_name().map(|v| v.to_string()); | 344 | let container_name = nav.container_name.as_ref().map(|v| v.to_string()); |
345 | let info = SymbolInformation { | 345 | let info = SymbolInformation { |
346 | name: nav.name().to_string(), | 346 | name: nav.name.to_string(), |
347 | kind: to_proto::symbol_kind(nav.kind()), | 347 | kind: to_proto::symbol_kind(nav.kind), |
348 | location: to_proto::location_from_nav(snap, nav)?, | 348 | location: to_proto::location_from_nav(snap, nav)?, |
349 | container_name, | 349 | container_name, |
350 | deprecated: None, | 350 | deprecated: None, |
@@ -434,7 +434,7 @@ pub(crate) fn handle_runnables( | |||
434 | let mut res = Vec::new(); | 434 | let mut res = Vec::new(); |
435 | for runnable in snap.analysis.runnables(file_id)? { | 435 | for runnable in snap.analysis.runnables(file_id)? { |
436 | if let Some(offset) = offset { | 436 | if let Some(offset) = offset { |
437 | if !runnable.nav.full_range().contains_inclusive(offset) { | 437 | if !runnable.nav.full_range.contains_inclusive(offset) { |
438 | continue; | 438 | continue; |
439 | } | 439 | } |
440 | } | 440 | } |
@@ -874,7 +874,7 @@ pub(crate) fn handle_code_lens( | |||
874 | } | 874 | } |
875 | 875 | ||
876 | let action = runnable.action(); | 876 | let action = runnable.action(); |
877 | let range = to_proto::range(&line_index, runnable.nav.range()); | 877 | let range = to_proto::range(&line_index, runnable.nav.focus_or_full_range()); |
878 | let r = to_proto::runnable(&snap, file_id, runnable)?; | 878 | let r = to_proto::runnable(&snap, file_id, runnable)?; |
879 | if snap.config.lens.run { | 879 | if snap.config.lens.run { |
880 | let lens = CodeLens { | 880 | let lens = CodeLens { |
@@ -1063,7 +1063,7 @@ pub(crate) fn handle_call_hierarchy_prepare( | |||
1063 | let RangeInfo { range: _, info: navs } = nav_info; | 1063 | let RangeInfo { range: _, info: navs } = nav_info; |
1064 | let res = navs | 1064 | let res = navs |
1065 | .into_iter() | 1065 | .into_iter() |
1066 | .filter(|it| it.kind() == SyntaxKind::FN_DEF) | 1066 | .filter(|it| it.kind == SyntaxKind::FN_DEF) |
1067 | .map(|it| to_proto::call_hierarchy_item(&snap, it)) | 1067 | .map(|it| to_proto::call_hierarchy_item(&snap, it)) |
1068 | .collect::<Result<Vec<_>>>()?; | 1068 | .collect::<Result<Vec<_>>>()?; |
1069 | 1069 | ||
@@ -1089,7 +1089,7 @@ pub(crate) fn handle_call_hierarchy_incoming( | |||
1089 | let mut res = vec![]; | 1089 | let mut res = vec![]; |
1090 | 1090 | ||
1091 | for call_item in call_items.into_iter() { | 1091 | for call_item in call_items.into_iter() { |
1092 | let file_id = call_item.target.file_id(); | 1092 | let file_id = call_item.target.file_id; |
1093 | let line_index = snap.analysis.file_line_index(file_id)?; | 1093 | let line_index = snap.analysis.file_line_index(file_id)?; |
1094 | let item = to_proto::call_hierarchy_item(&snap, call_item.target)?; | 1094 | let item = to_proto::call_hierarchy_item(&snap, call_item.target)?; |
1095 | res.push(CallHierarchyIncomingCall { | 1095 | res.push(CallHierarchyIncomingCall { |
@@ -1124,7 +1124,7 @@ pub(crate) fn handle_call_hierarchy_outgoing( | |||
1124 | let mut res = vec![]; | 1124 | let mut res = vec![]; |
1125 | 1125 | ||
1126 | for call_item in call_items.into_iter() { | 1126 | for call_item in call_items.into_iter() { |
1127 | let file_id = call_item.target.file_id(); | 1127 | let file_id = call_item.target.file_id; |
1128 | let line_index = snap.analysis.file_line_index(file_id)?; | 1128 | let line_index = snap.analysis.file_line_index(file_id)?; |
1129 | let item = to_proto::call_hierarchy_item(&snap, call_item.target)?; | 1129 | let item = to_proto::call_hierarchy_item(&snap, call_item.target)?; |
1130 | res.push(CallHierarchyOutgoingCall { | 1130 | res.push(CallHierarchyOutgoingCall { |
@@ -1220,13 +1220,13 @@ fn goto_location_command(snap: &GlobalStateSnapshot, nav: &NavigationTarget) -> | |||
1220 | let link = to_proto::location_link(snap, None, nav.clone()).ok()?; | 1220 | let link = to_proto::location_link(snap, None, nav.clone()).ok()?; |
1221 | to_value(link).ok()? | 1221 | to_value(link).ok()? |
1222 | } else { | 1222 | } else { |
1223 | let range = FileRange { file_id: nav.file_id(), range: nav.range() }; | 1223 | let range = FileRange { file_id: nav.file_id, range: nav.focus_or_full_range() }; |
1224 | let location = to_proto::location(snap, range).ok()?; | 1224 | let location = to_proto::location(snap, range).ok()?; |
1225 | to_value(location).ok()? | 1225 | to_value(location).ok()? |
1226 | }; | 1226 | }; |
1227 | 1227 | ||
1228 | Some(Command { | 1228 | Some(Command { |
1229 | title: nav.name().to_string(), | 1229 | title: nav.name.to_string(), |
1230 | command: "rust-analyzer.gotoLocation".into(), | 1230 | command: "rust-analyzer.gotoLocation".into(), |
1231 | arguments: Some(vec![value]), | 1231 | arguments: Some(vec![value]), |
1232 | }) | 1232 | }) |
diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index 7fcb43a4f..783012c1a 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs | |||
@@ -497,9 +497,9 @@ pub(crate) fn location_from_nav( | |||
497 | snap: &GlobalStateSnapshot, | 497 | snap: &GlobalStateSnapshot, |
498 | nav: NavigationTarget, | 498 | nav: NavigationTarget, |
499 | ) -> Result<lsp_types::Location> { | 499 | ) -> Result<lsp_types::Location> { |
500 | let url = url(snap, nav.file_id()); | 500 | let url = url(snap, nav.file_id); |
501 | let line_index = snap.analysis.file_line_index(nav.file_id())?; | 501 | let line_index = snap.analysis.file_line_index(nav.file_id)?; |
502 | let range = range(&line_index, nav.full_range()); | 502 | let range = range(&line_index, nav.full_range); |
503 | let loc = lsp_types::Location::new(url, range); | 503 | let loc = lsp_types::Location::new(url, range); |
504 | Ok(loc) | 504 | Ok(loc) |
505 | } | 505 | } |
@@ -531,12 +531,12 @@ fn location_info( | |||
531 | snap: &GlobalStateSnapshot, | 531 | snap: &GlobalStateSnapshot, |
532 | target: NavigationTarget, | 532 | target: NavigationTarget, |
533 | ) -> Result<(lsp_types::Url, lsp_types::Range, lsp_types::Range)> { | 533 | ) -> Result<(lsp_types::Url, lsp_types::Range, lsp_types::Range)> { |
534 | let line_index = snap.analysis.file_line_index(target.file_id())?; | 534 | let line_index = snap.analysis.file_line_index(target.file_id)?; |
535 | 535 | ||
536 | let target_uri = url(snap, target.file_id()); | 536 | let target_uri = url(snap, target.file_id); |
537 | let target_range = range(&line_index, target.full_range()); | 537 | let target_range = range(&line_index, target.full_range); |
538 | let target_selection_range = | 538 | let target_selection_range = |
539 | target.focus_range().map(|it| range(&line_index, it)).unwrap_or(target_range); | 539 | target.focus_range.map(|it| range(&line_index, it)).unwrap_or(target_range); |
540 | Ok((target_uri, target_range, target_selection_range)) | 540 | Ok((target_uri, target_range, target_selection_range)) |
541 | } | 541 | } |
542 | 542 | ||
@@ -555,13 +555,7 @@ pub(crate) fn goto_definition_response( | |||
555 | let locations = targets | 555 | let locations = targets |
556 | .into_iter() | 556 | .into_iter() |
557 | .map(|nav| { | 557 | .map(|nav| { |
558 | location( | 558 | location(snap, FileRange { file_id: nav.file_id, range: nav.focus_or_full_range() }) |
559 | snap, | ||
560 | FileRange { | ||
561 | file_id: nav.file_id(), | ||
562 | range: nav.focus_range().unwrap_or(nav.range()), | ||
563 | }, | ||
564 | ) | ||
565 | }) | 559 | }) |
566 | .collect::<Result<Vec<_>>>()?; | 560 | .collect::<Result<Vec<_>>>()?; |
567 | Ok(locations.into()) | 561 | Ok(locations.into()) |
@@ -666,9 +660,9 @@ pub(crate) fn call_hierarchy_item( | |||
666 | snap: &GlobalStateSnapshot, | 660 | snap: &GlobalStateSnapshot, |
667 | target: NavigationTarget, | 661 | target: NavigationTarget, |
668 | ) -> Result<lsp_types::CallHierarchyItem> { | 662 | ) -> Result<lsp_types::CallHierarchyItem> { |
669 | let name = target.name().to_string(); | 663 | let name = target.name.to_string(); |
670 | let detail = target.description().map(|it| it.to_string()); | 664 | let detail = target.description.clone(); |
671 | let kind = symbol_kind(target.kind()); | 665 | let kind = symbol_kind(target.kind); |
672 | let (uri, range, selection_range) = location_info(snap, target)?; | 666 | let (uri, range, selection_range) = location_info(snap, target)?; |
673 | Ok(lsp_types::CallHierarchyItem { name, kind, tags: None, detail, uri, range, selection_range }) | 667 | Ok(lsp_types::CallHierarchyItem { name, kind, tags: None, detail, uri, range, selection_range }) |
674 | } | 668 | } |