Inheritance: SyntaxRewriter
コード例 #1
0
 public static IDocument Annotate(IDocument document, TextSpan span, out IEnumerable<SyntaxAnnotation> annotations)
 {
     var oldRoot = (CompilationUnitSyntax)document.GetSyntaxRoot();
     var propertyAnnotater = new PropertyAnnotater(document, span);
     var newRoot = (CompilationUnitSyntax)propertyAnnotater.Visit(oldRoot);
     annotations = propertyAnnotater.annotations;
     return document.UpdateSyntaxRoot(newRoot);
 }
コード例 #2
0
        public static IDocument Annotate(IDocument document, TextSpan span, out IEnumerable <SyntaxAnnotation> annotations)
        {
            var oldRoot           = (CompilationUnitSyntax)document.GetSyntaxRoot();
            var propertyAnnotater = new PropertyAnnotater(document, span);
            var newRoot           = (CompilationUnitSyntax)propertyAnnotater.Visit(oldRoot);

            annotations = propertyAnnotater.annotations;
            return(document.UpdateSyntaxRoot(newRoot));
        }
コード例 #3
0
        public static CompilationUnitSyntax Apply(IText text, TextSpan span, out IEnumerable <SyntaxAnnotation> propertyAnnotations)
        {
            var document = GetDocument(text);

            document = PropertyAnnotater.Annotate(document, span, out propertyAnnotations);

            foreach (var propertyAnnotation in propertyAnnotations)
            {
                var propertyDeclaration = document.GetAnnotatedNode <PropertyDeclarationSyntax>(propertyAnnotation);
                document = document.ExpandProperty(propertyDeclaration);

                propertyDeclaration = document.GetAnnotatedNode <PropertyDeclarationSyntax>(propertyAnnotation);
                var classDeclaration = propertyDeclaration.FirstAncestorOrSelf <ClassDeclarationSyntax>();
                document = document.ImplementINotifyPropertyChanged(classDeclaration);
            }

            var newRoot = document
                          .Simplify(CodeAnnotations.Simplify)
                          .Format(CodeAnnotations.Formatting)
                          .GetSyntaxRoot();

            return((CompilationUnitSyntax)newRoot);
        }