Ejemplo n.º 1
0
    public override VBasic.VisualBasicSyntaxNode VisitXmlElement(CSSyntax.XmlElementSyntax node)
    {
        var Content = new SyntaxList <VBSyntax.XmlNodeSyntax>();

        VBSyntax.XmlElementStartTagSyntax StartTag = (VBSyntax.XmlElementStartTagSyntax)node.StartTag.Accept(this);

        bool NoEndTag = string.IsNullOrWhiteSpace(node.EndTag.Name.LocalName.ValueText);
        var  EndTag   = NoEndTag ? VBFactory.XmlElementEndTag(((VBSyntax.XmlNameSyntax)StartTag.Name)) : VBFactory.XmlElementEndTag((VBSyntax.XmlNameSyntax)node.EndTag.Name.Accept(this));

        try
        {
            for (int i = 0, loopTo = node.Content.Count - 1; i <= loopTo; i++)
            {
                var C = node.Content[i];
                VBSyntax.XmlNodeSyntax Node1 = (VBSyntax.XmlNodeSyntax)C.Accept(this);
                if (NoEndTag)
                {
                    var LastToken = Node1.GetLastToken();
                    if (LastToken.ValueText.IsNewLine())
                    {
                        Node1 = Node1.ReplaceToken(LastToken, default(SyntaxToken));
                    }
                }
                Content = Content.Add(Node1);
            }

            if (node.EndTag?.HasLeadingTrivia == true && node.EndTag.GetLeadingTrivia()[0].IsKind(CS.SyntaxKind.DocumentationCommentExteriorTrivia) == true)
            {
                var NewLeadingTriviaList = new SyntaxTriviaList();
                NewLeadingTriviaList = NewLeadingTriviaList.Add(VBFactory.DocumentationCommentExteriorTrivia(node.EndTag.GetLeadingTrivia()[0].ToString().Replace("///", "'''")));
                var NewTokenList = new SyntaxTokenList();
                NewTokenList = NewTokenList.Add(VBFactory.XmlTextLiteralToken(NewLeadingTriviaList, " ", " ", new SyntaxTriviaList()));
                Content      = Content.Add(VBFactory.XmlText(NewTokenList));
                EndTag       = EndTag.WithoutLeadingTrivia();
            }
        }
        catch (OperationCanceledException)
        {
            throw;
        }
        catch (Exception)
        {
        }
        var XmlElement = VBFactory.XmlElement(StartTag, Content, EndTag);

        return(XmlElement);
    }
Ejemplo n.º 2
0
 public override VBasic.VisualBasicSyntaxNode VisitXmlElementEndTag(CSSyntax.XmlElementEndTagSyntax node)
 {
     return(VBFactory.XmlElementEndTag((VBSyntax.XmlNameSyntax)node.Name.Accept(this)));
 }