From b9ca8ab868a051fca47462113490433a5085d3c8 Mon Sep 17 00:00:00 2001 From: Andrea Pretto Date: Sat, 26 Jan 2019 13:21:41 +0100 Subject: Better visibility check. --- crates/ra_ide_api_light/src/folding_ranges.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'crates/ra_ide_api_light/src/folding_ranges.rs') diff --git a/crates/ra_ide_api_light/src/folding_ranges.rs b/crates/ra_ide_api_light/src/folding_ranges.rs index 0f2f1399b..87feb9bd8 100644 --- a/crates/ra_ide_api_light/src/folding_ranges.rs +++ b/crates/ra_ide_api_light/src/folding_ranges.rs @@ -83,7 +83,11 @@ fn fold_kind(kind: SyntaxKind) -> Option { } fn has_visibility(node: &SyntaxNode) -> bool { - return node.descendants().any(|n| n.kind() == VISIBILITY); + use ast::VisibilityOwner; + + return ast::Module::cast(node) + .and_then(|m| m.visibility()) + .is_some(); } fn has_newline(node: &SyntaxNode) -> bool { -- cgit v1.2.3