public override void VisitStructDeclaration(StructDeclarationSyntax node) { var capture = new AutoArrangeCaptureWalker(); capture.VisitTypeDeclaration(node); this.Types.Add(capture); }
public CodeActionEdit GetEdit( CancellationToken cancellationToken) { var captureWalker = new AutoArrangeCaptureWalker(); captureWalker.VisitTypeDeclaration(this.token); var result = new AutoArrangeReplaceRewriter( captureWalker).VisitTypeDeclaration(this.token); var tree = (SyntaxNode)this.document.GetSyntaxRoot( cancellationToken); var newTree = tree.ReplaceNodes(new [] { this.token }, (a, b) => result); return(new CodeActionEdit(document.UpdateSyntaxRoot(newTree))); }
public AutoArrangeReplaceRewriter( AutoArrangeCaptureWalker rewriter) { rewriter.Constructors.Sort( (a, b) => a.Identifier.ValueText.CompareTo( b.Identifier.ValueText)); rewriter.Enums.Sort( (a, b) => a.Identifier.ValueText.CompareTo( b.Identifier.ValueText)); rewriter.Events.Sort( (a, b) => a.Identifier.ValueText.CompareTo( b.Identifier.ValueText)); rewriter.Fields.Sort( (a, b) => a.Declaration.Variables[0] .Identifier.ValueText.CompareTo( b.Declaration.Variables[0] .Identifier.ValueText)); rewriter.Methods.Sort( (a, b) => a.Identifier.ValueText.CompareTo( b.Identifier.ValueText)); rewriter.Properties.Sort( (a, b) => a.Identifier.ValueText.CompareTo( b.Identifier.ValueText)); rewriter.Types.Sort( (a, b) => a.Target.Identifier.ValueText.CompareTo( b.Target.Identifier.ValueText)); this.nodes = new List <SyntaxNode>(); this.nodes.AddRange(rewriter.Events); this.nodes.AddRange(rewriter.Fields); this.nodes.AddRange(rewriter.Constructors); this.nodes.AddRange(rewriter.Methods); this.nodes.AddRange(rewriter.Properties); this.nodes.AddRange(rewriter.Enums); this.nodes.AddRange( from typeRewriter in rewriter.Types select new AutoArrangeReplaceRewriter(typeRewriter) .VisitTypeDeclaration(typeRewriter.Target) as TypeDeclarationSyntax); }