File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -748,6 +748,27 @@ fn normalize_ws_between_braces(node: &SyntaxNode) -> Option<()> {
748748 Some ( ( ) )
749749}
750750
751+ pub trait HasVisibilityEdit : ast:: HasVisibility {
752+ fn set_visibility ( & self , visbility : ast:: Visibility ) {
753+ match self . visibility ( ) {
754+ Some ( current_visibility) => {
755+ ted:: replace ( current_visibility. syntax ( ) , visbility. syntax ( ) )
756+ }
757+ None => {
758+ let vis_before = self
759+ . syntax ( )
760+ . children_with_tokens ( )
761+ . find ( |it| !matches ! ( it. kind( ) , WHITESPACE | COMMENT | ATTR ) )
762+ . unwrap_or_else ( || self . syntax ( ) . first_child_or_token ( ) . unwrap ( ) ) ;
763+
764+ ted:: insert ( ted:: Position :: before ( vis_before) , visbility. syntax ( ) ) ;
765+ }
766+ }
767+ }
768+ }
769+
770+ impl < T : ast:: HasVisibility > HasVisibilityEdit for T { }
771+
751772pub trait Indent : AstNode + Clone + Sized {
752773 fn indent_level ( & self ) -> IndentLevel {
753774 IndentLevel :: from_node ( self . syntax ( ) )
You can’t perform that action at this time.
0 commit comments