From 79c90b5641d2934864c587380e4f050ab63ac029 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Tue, 24 Dec 2019 23:45:14 +0100 Subject: Collect visibility of items during nameres --- crates/ra_hir_def/src/visibility.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'crates/ra_hir_def/src/visibility.rs') diff --git a/crates/ra_hir_def/src/visibility.rs b/crates/ra_hir_def/src/visibility.rs index ef7732749..8cac52630 100644 --- a/crates/ra_hir_def/src/visibility.rs +++ b/crates/ra_hir_def/src/visibility.rs @@ -4,7 +4,7 @@ use std::sync::Arc; use either::Either; -use hir_expand::InFile; +use hir_expand::{hygiene::Hygiene, InFile}; use ra_syntax::ast::{self, VisibilityOwner}; use crate::{ @@ -73,14 +73,20 @@ impl Visibility { } fn from_ast(db: &impl DefDatabase, node: InFile>) -> Visibility { - let file_id = node.file_id; - let node = match node.value { + Self::from_ast_with_hygiene(node.value, &Hygiene::new(db, node.file_id)) + } + + pub(crate) fn from_ast_with_hygiene( + node: Option, + hygiene: &Hygiene, + ) -> Visibility { + let node = match node { None => return Visibility::private(), Some(node) => node, }; match node.kind() { ast::VisibilityKind::In(path) => { - let path = ModPath::from_src(path, &hir_expand::hygiene::Hygiene::new(db, file_id)); + let path = ModPath::from_src(path, hygiene); let path = match path { None => return Visibility::private(), Some(path) => path, -- cgit v1.2.3