From c83467796b6c7365ea4f41900d74444384a9e618 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 30 Jul 2020 18:17:28 +0200 Subject: Finalize Trait grammar --- crates/ra_ide/src/completion/patterns.rs | 4 ++-- crates/ra_ide/src/display/navigation_target.rs | 4 ++-- crates/ra_ide/src/display/short_label.rs | 2 +- crates/ra_ide/src/file_structure.rs | 2 +- crates/ra_ide/src/goto_implementation.rs | 4 ++-- crates/ra_ide/src/hover.rs | 32 +++++++++++++------------- crates/ra_ide/src/syntax_highlighting.rs | 2 +- 7 files changed, 25 insertions(+), 25 deletions(-) (limited to 'crates/ra_ide') diff --git a/crates/ra_ide/src/completion/patterns.rs b/crates/ra_ide/src/completion/patterns.rs index b8408da4e..6c11f5830 100644 --- a/crates/ra_ide/src/completion/patterns.rs +++ b/crates/ra_ide/src/completion/patterns.rs @@ -15,7 +15,7 @@ pub(crate) fn has_trait_parent(element: SyntaxElement) -> bool { not_same_range_ancestor(element) .filter(|it| it.kind() == ASSOC_ITEM_LIST) .and_then(|it| it.parent()) - .filter(|it| it.kind() == TRAIT_DEF) + .filter(|it| it.kind() == TRAIT) .is_some() } #[test] @@ -113,7 +113,7 @@ fn test_if_is_prev() { } pub(crate) fn has_trait_as_prev_sibling(element: SyntaxElement) -> bool { - previous_sibling_or_ancestor_sibling(element).filter(|it| it.kind() == TRAIT_DEF).is_some() + previous_sibling_or_ancestor_sibling(element).filter(|it| it.kind() == TRAIT).is_some() } #[test] fn test_has_trait_as_prev_sibling() { diff --git a/crates/ra_ide/src/display/navigation_target.rs b/crates/ra_ide/src/display/navigation_target.rs index 9e2c01245..45fbc86ef 100644 --- a/crates/ra_ide/src/display/navigation_target.rs +++ b/crates/ra_ide/src/display/navigation_target.rs @@ -382,7 +382,7 @@ pub(crate) fn docs_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> Option ast::Fn(it) => it.doc_comment_text(), ast::Struct(it) => it.doc_comment_text(), ast::Enum(it) => it.doc_comment_text(), - ast::TraitDef(it) => it.doc_comment_text(), + ast::Trait(it) => it.doc_comment_text(), ast::Module(it) => it.doc_comment_text(), ast::TypeAlias(it) => it.doc_comment_text(), ast::Const(it) => it.doc_comment_text(), @@ -407,7 +407,7 @@ pub(crate) fn description_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> ast::Fn(it) => it.short_label(), ast::Struct(it) => it.short_label(), ast::Enum(it) => it.short_label(), - ast::TraitDef(it) => it.short_label(), + ast::Trait(it) => it.short_label(), ast::Module(it) => it.short_label(), ast::TypeAlias(it) => it.short_label(), ast::Const(it) => it.short_label(), diff --git a/crates/ra_ide/src/display/short_label.rs b/crates/ra_ide/src/display/short_label.rs index 282f362f2..c600908a4 100644 --- a/crates/ra_ide/src/display/short_label.rs +++ b/crates/ra_ide/src/display/short_label.rs @@ -31,7 +31,7 @@ impl ShortLabel for ast::Enum { } } -impl ShortLabel for ast::TraitDef { +impl ShortLabel for ast::Trait { fn short_label(&self) -> Option { if self.unsafe_token().is_some() { short_label_from_node(self, "unsafe trait ") diff --git a/crates/ra_ide/src/file_structure.rs b/crates/ra_ide/src/file_structure.rs index 77384b6ec..3fc972460 100644 --- a/crates/ra_ide/src/file_structure.rs +++ b/crates/ra_ide/src/file_structure.rs @@ -130,7 +130,7 @@ fn structure_node(node: &SyntaxNode) -> Option { ast::Union(it) => decl(it), ast::Enum(it) => decl(it), ast::Variant(it) => decl(it), - ast::TraitDef(it) => decl(it), + ast::Trait(it) => decl(it), ast::Module(it) => decl(it), ast::TypeAlias(it) => { let ty = it.type_ref(); diff --git a/crates/ra_ide/src/goto_implementation.rs b/crates/ra_ide/src/goto_implementation.rs index e2f7e6373..9912b7142 100644 --- a/crates/ra_ide/src/goto_implementation.rs +++ b/crates/ra_ide/src/goto_implementation.rs @@ -28,7 +28,7 @@ pub(crate) fn goto_implementation( nominal_def.syntax().text_range(), impls_for_def(&sema, &nominal_def, krate)?, )); - } else if let Some(trait_def) = find_node_at_offset::(&syntax, position.offset) { + } else if let Some(trait_def) = find_node_at_offset::(&syntax, position.offset) { return Some(RangeInfo::new( trait_def.syntax().text_range(), impls_for_trait(&sema, &trait_def, krate)?, @@ -62,7 +62,7 @@ fn impls_for_def( fn impls_for_trait( sema: &Semantics, - node: &ast::TraitDef, + node: &ast::Trait, krate: Crate, ) -> Option> { let tr = sema.to_def(node)?; diff --git a/crates/ra_ide/src/hover.rs b/crates/ra_ide/src/hover.rs index 83228af2e..aa48cb412 100644 --- a/crates/ra_ide/src/hover.rs +++ b/crates/ra_ide/src/hover.rs @@ -1678,7 +1678,7 @@ fn main() { let s<|>t = foo(); } 6..9, ), name: "Foo", - kind: TRAIT_DEF, + kind: TRAIT, container_name: None, description: Some( "trait Foo", @@ -1718,7 +1718,7 @@ fn main() { let s<|>t = foo(); } 6..9, ), name: "Foo", - kind: TRAIT_DEF, + kind: TRAIT, container_name: None, description: Some( "trait Foo", @@ -1777,7 +1777,7 @@ fn main() { let s<|>t = foo(); } 6..9, ), name: "Foo", - kind: TRAIT_DEF, + kind: TRAIT, container_name: None, description: Some( "trait Foo", @@ -1796,7 +1796,7 @@ fn main() { let s<|>t = foo(); } 19..22, ), name: "Bar", - kind: TRAIT_DEF, + kind: TRAIT, container_name: None, description: Some( "trait Bar", @@ -1839,7 +1839,7 @@ fn main() { let s<|>t = foo(); } 6..9, ), name: "Foo", - kind: TRAIT_DEF, + kind: TRAIT, container_name: None, description: Some( "trait Foo", @@ -1858,7 +1858,7 @@ fn main() { let s<|>t = foo(); } 22..25, ), name: "Bar", - kind: TRAIT_DEF, + kind: TRAIT, container_name: None, description: Some( "trait Bar", @@ -1933,7 +1933,7 @@ fn foo(ar<|>g: &impl Foo) {} 6..9, ), name: "Foo", - kind: TRAIT_DEF, + kind: TRAIT, container_name: None, description: Some( "trait Foo", @@ -1973,7 +1973,7 @@ fn foo(ar<|>g: &impl Foo + Bar) {} 6..9, ), name: "Foo", - kind: TRAIT_DEF, + kind: TRAIT, container_name: None, description: Some( "trait Foo", @@ -1992,7 +1992,7 @@ fn foo(ar<|>g: &impl Foo + Bar) {} 19..22, ), name: "Bar", - kind: TRAIT_DEF, + kind: TRAIT, container_name: None, description: Some( "trait Bar", @@ -2049,7 +2049,7 @@ fn foo(ar<|>g: &impl Foo) {} 6..9, ), name: "Foo", - kind: TRAIT_DEF, + kind: TRAIT, container_name: None, description: Some( "trait Foo", @@ -2130,7 +2130,7 @@ fn main() { let s<|>t = foo(); } 6..9, ), name: "Foo", - kind: TRAIT_DEF, + kind: TRAIT, container_name: None, description: Some( "trait Foo", @@ -2167,7 +2167,7 @@ fn foo(ar<|>g: &dyn Foo) {} 6..9, ), name: "Foo", - kind: TRAIT_DEF, + kind: TRAIT, container_name: None, description: Some( "trait Foo", @@ -2205,7 +2205,7 @@ fn foo(ar<|>g: &dyn Foo) {} 6..9, ), name: "Foo", - kind: TRAIT_DEF, + kind: TRAIT, container_name: None, description: Some( "trait Foo", @@ -2265,7 +2265,7 @@ fn foo(a<|>rg: &impl ImplTrait>>>) {} 6..15, ), name: "ImplTrait", - kind: TRAIT_DEF, + kind: TRAIT, container_name: None, description: Some( "trait ImplTrait", @@ -2303,7 +2303,7 @@ fn foo(a<|>rg: &impl ImplTrait>>>) {} 28..36, ), name: "DynTrait", - kind: TRAIT_DEF, + kind: TRAIT, container_name: None, description: Some( "trait DynTrait", @@ -2370,7 +2370,7 @@ fn main() { let s<|>t = test().get(); } 6..9, ), name: "Foo", - kind: TRAIT_DEF, + kind: TRAIT, container_name: None, description: Some( "trait Foo", diff --git a/crates/ra_ide/src/syntax_highlighting.rs b/crates/ra_ide/src/syntax_highlighting.rs index 19ec73d2a..a66453c04 100644 --- a/crates/ra_ide/src/syntax_highlighting.rs +++ b/crates/ra_ide/src/syntax_highlighting.rs @@ -708,7 +708,7 @@ fn highlight_name_by_syntax(name: ast::Name) -> Highlight { STRUCT => HighlightTag::Struct, ENUM => HighlightTag::Enum, UNION => HighlightTag::Union, - TRAIT_DEF => HighlightTag::Trait, + TRAIT => HighlightTag::Trait, TYPE_ALIAS => HighlightTag::TypeAlias, TYPE_PARAM => HighlightTag::TypeParam, RECORD_FIELD => HighlightTag::Field, -- cgit v1.2.3