예제 #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 ?? true) && nodes.Count == 0)
            {
                if (name.Equals(Name) &&
                    (attributes.Equals(Attributes) || attributes.SequenceEqual(Attributes)))
                {
                    return(this);
                }

                return(new EmptyElementSyntax(LessThan, name, attributes, Slash, GreaterThan));
            }

            return(ElementSyntax.Create(
                       ElementStartTagSyntax.Create(LessThan, name, attributes, GreaterThanToken.Default),
                       nodes,
                       ElementEndTagSyntax.Create(
                           LessThanToken.Default,
                           SlashToken.Default,
                           name,
                           GreaterThan)));
        }
예제 #2
0
        protected override SyntaxBase VisitElementStartTag(ElementStartTagSyntax syntax)
        {
            var attributes = VisitAttributes(syntax.Attributes);

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

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