예제 #1
0
        public override ElementSyntaxBase With(
            NameToken name = null,
            IImmutableList <AttributeSyntaxBase> attributes = null,
            IImmutableList <NodeSyntax> nodes = null,
            bool?isEmpty = null)
        {
            name       = name ?? Name;
            nodes      = nodes ?? Nodes;
            attributes = attributes ?? Attributes;

            if ((isEmpty ?? false) && nodes.Count == 0)
            {
                return(EmptyElementSyntax.Create(
                           StartTag.LessThan,
                           Name,
                           attributes,
                           SlashToken.Default,
                           EndTag.GreaterThan));
            }

            if (name.Equals(Name) &&
                (attributes.Equals(Attributes) || attributes.SequenceEqual(Attributes)) &&
                (nodes.Equals(Nodes) || nodes.SequenceEqual(Nodes)))
            {
                return(this);
            }

            return(Create(
                       StartTag.With(name, attributes),
                       nodes,
                       EndTag.With(EndTag.Name.With(name.Text))));
        }
예제 #2
0
        protected override SyntaxBase VisitEmptyElement(EmptyElementSyntax syntax)
        {
            var attributes = VisitAttributes(syntax.Attributes);

            return(EmptyElementSyntax.Create(
                       LessThanToken.Create(TriviaSyntax.Empty, TriviaSyntax.Empty),
                       syntax.Name.WithTrivia(TriviaSyntax.Empty, TriviaSyntax.Empty),
                       attributes,
                       SlashToken.Create(TriviaSyntax.Empty, TriviaSyntax.Empty),
                       GreaterThanToken.Create(TriviaSyntax.Empty, TriviaSyntax.Empty)));
        }
예제 #3
0
        protected virtual SyntaxBase VisitEmptyElement(EmptyElementSyntax syntax)
        {
            var lessThan    = VisitAndConvert(syntax.LessThan);
            var name        = VisitAndConvert(syntax.Name);
            var attributes  = VisitAndConvert(syntax.Attributes);
            var slash       = VisitAndConvert(syntax.Slash);
            var greaterThan = VisitAndConvert(syntax.GreaterThan);

            if (SyntaxEquals(syntax.LessThan, lessThan) &&
                SyntaxEquals(syntax.Name, name) &&
                ReferenceEquals(syntax.Attributes, attributes) &&
                SyntaxEquals(syntax.Slash, slash) &&
                SyntaxEquals(syntax.GreaterThan, greaterThan))
            {
                return(syntax);
            }
            return(EmptyElementSyntax.Create(lessThan, name, attributes, slash, greaterThan));
        }