public static InlineScriptElementSyntax Create(
     ElementStartTagSyntax startTag,
     ScriptToken script,
     ElementEndTagSyntax endTag)
 {
     return(new InlineScriptElementSyntax(startTag, script, endTag));
 }
Exemple #2
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)));
        }
        ElementSyntax(ElementStartTagSyntax startTag, IImmutableList <NodeSyntax> nodes, ElementEndTagSyntax endTag)
        {
            StartTag = startTag ?? throw new ArgumentNullException(nameof(startTag));
            Nodes    = nodes ?? throw new ArgumentNullException(nameof(nodes));
            EndTag   = endTag ?? throw new ArgumentNullException(nameof(endTag));

            DescendantElementCount = nodes.OfType <ElementSyntaxBase>().Sum(x => x.DescendantElementCount + 1);
        }
Exemple #4
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)));
        }
        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));
        }
 InlineScriptElementSyntax(ElementStartTagSyntax startTag, ScriptToken script, ElementEndTagSyntax endTag)
 {
     StartTag = startTag ?? throw new ArgumentNullException(nameof(startTag));
     Script   = script ?? throw new ArgumentNullException(nameof(script));
     EndTag   = endTag ?? throw new ArgumentNullException(nameof(endTag));
 }
 public static ElementSyntax Create(ElementStartTagSyntax startTag, IImmutableList <NodeSyntax> nodes, ElementEndTagSyntax endTag)
 {
     return(new ElementSyntax(startTag, nodes, endTag));
 }