aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src/item_tree.rs
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2020-06-22 18:15:54 +0100
committerJonas Schievink <[email protected]>2020-06-24 15:53:16 +0100
commitffa0435050ae57c5171c19224ca6e9f8a4e3435d (patch)
tree02173f630fafb0804bb6009da7216fcab8a814d2 /crates/ra_hir_def/src/item_tree.rs
parent19586bc5c62541db5253986c84ce3ba5c6392656 (diff)
Make generics and attr queries use ItemTree
Now it's fast
Diffstat (limited to 'crates/ra_hir_def/src/item_tree.rs')
-rw-r--r--crates/ra_hir_def/src/item_tree.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/crates/ra_hir_def/src/item_tree.rs b/crates/ra_hir_def/src/item_tree.rs
index 59a4a411a..efcb5dc60 100644
--- a/crates/ra_hir_def/src/item_tree.rs
+++ b/crates/ra_hir_def/src/item_tree.rs
@@ -175,6 +175,9 @@ pub trait ItemTreeNode: Clone {
175 175
176 /// Downcasts a `ModItem` to a `FileItemTreeId` specific to this type. 176 /// Downcasts a `ModItem` to a `FileItemTreeId` specific to this type.
177 fn id_from_mod_item(mod_item: ModItem) -> Option<FileItemTreeId<Self>>; 177 fn id_from_mod_item(mod_item: ModItem) -> Option<FileItemTreeId<Self>>;
178
179 /// Upcasts a `FileItemTreeId` to a generic `ModItem`.
180 fn id_to_mod_item(id: FileItemTreeId<Self>) -> ModItem;
178} 181}
179 182
180/// Trait for item tree nodes that allow accessing the original AST node. 183/// Trait for item tree nodes that allow accessing the original AST node.
@@ -232,6 +235,10 @@ macro_rules! nodes {
232 None 235 None
233 } 236 }
234 } 237 }
238
239 fn id_to_mod_item(id: FileItemTreeId<Self>) -> ModItem {
240 ModItem::$node(id)
241 }
235 } 242 }
236 )+ }; 243 )+ };
237} 244}