示例#1
0
        public static string Map(VisualBasicSyntax.TypeSyntax type, bool useLongNames = false)
        {
            if (type == null)
            {
                return(string.Empty);
            }

            return(Map(type.ToString(), useLongNames));
        }
示例#2
0
 public override VB.VisualBasicSyntaxNode VisitGenericName(CSS.GenericNameSyntax node)
 {
     var Identifier = VBFactory.Identifier(node.Identifier.ToString());
     var TypeList = new List<VBS.TypeSyntax>();
     foreach (CSS.TypeSyntax a in node.TypeArgumentList.Arguments)
     {
         VBS.TypeSyntax TypeIdentifier = (VBS.TypeSyntax)a.Accept(this);
         TypeList.Add(TypeIdentifier);
     }
     return VBFactory.GenericName(Identifier, VBFactory.TypeArgumentList(TypeList.ToArray()));
 }
示例#3
0
        private VariableDeclaratorSyntax ConvertToVariableDeclarator(IsPatternExpressionSyntax node)
        {
            return(node.Pattern.TypeSwitch(
                       (DeclarationPatternSyntax d) => {
                var id = ((IdentifierNameSyntax)d.Designation.Accept(_nodesVisitor)).Identifier;
                var ids = SyntaxFactory.SingletonSeparatedList(SyntaxFactory.ModifiedIdentifier(id));
                TypeSyntax right = (TypeSyntax)d.Type.Accept(_nodesVisitor);

                var simpleAsClauseSyntax = SyntaxFactory.SimpleAsClause(right);
                var equalsValueSyntax = SyntaxFactory.EqualsValue(SyntaxFactory.LiteralExpression(SyntaxKind.NothingLiteralExpression, SyntaxFactory.Token(SyntaxKind.NothingKeyword)));
                return SyntaxFactory.VariableDeclarator(ids, simpleAsClauseSyntax, equalsValueSyntax);
            },
                       p => throw new ArgumentOutOfRangeException(nameof(p), p, null)));
        }
示例#4
0
 public override VB.VisualBasicSyntaxNode VisitNameMemberCref(CSS.NameMemberCrefSyntax node)
 {
     var Name = node.Name.Accept(this);
     var CrefParameters = new List<VBS.CrefSignaturePartSyntax>();
     VBS.CrefSignatureSyntax Signature = null;
     if (node.Parameters != null)
     {
         foreach (CSS.CrefParameterSyntax p in node.Parameters.Parameters)
         {
             VBS.TypeSyntax TypeSyntax1 = (VBS.TypeSyntax)p.Accept(this);
             CrefParameters.Add(VBFactory.CrefSignaturePart(modifier: default(SyntaxToken), TypeSyntax1));
         }
         Signature = VBFactory.CrefSignature(CrefParameters.ToArray());
     }
     return VBFactory.CrefReference((VBS.TypeSyntax)Name, signature: Signature, asClause: null);
 }
示例#5
0
        static SplitInheritResult SplitInherit(this VBS.InheritsStatementSyntax vbInheritTypes, bool interfaceIsStartWithI)
        {
            SplitInheritResult retval = new SplitInheritResult();
            SyntaxList<VBS.InheritsStatementSyntax> vbInherits = new SyntaxList<VBS.InheritsStatementSyntax>();
            SyntaxList<VBS.ImplementsStatementSyntax> vbImplements = new SyntaxList<VBS.ImplementsStatementSyntax>();

            if (vbInheritTypes != null && vbInheritTypes.Types.Count > 0)
            {
                VBS.TypeSyntax vbType0 = vbInheritTypes.Types[0];
                string name = string.Empty;
                if (vbType0.IsKind(VB.SyntaxKind.QualifiedName))
                {
                    name = ((VBS.QualifiedNameSyntax)vbType0).Right.Identifier.Text;
                }
                else if (vbType0.IsKind(VB.SyntaxKind.PredefinedType))
                {
                    name = ((VBS.PredefinedTypeSyntax)vbType0).ToFullString();
                }
                else if (vbType0.IsKind(VB.SyntaxKind.IdentifierName))
                {
                    name = ((VBS.IdentifierNameSyntax)vbType0).Identifier.Text;
                }
                else if (vbType0.IsKind(VB.SyntaxKind.GenericName))
                {
                    name = ((VBS.GenericNameSyntax)vbType0).Identifier.Text;
                }

                bool firstIsInterface = interfaceIsStartWithI && name.StartsWith("I");

                if (!firstIsInterface)
                {
                    retval.Inherits = vbInherits.Add(VB.SyntaxFactory.InheritsStatement(vbInheritTypes.Types[0]));
                }

                int start = firstIsInterface ? 0 : 1;
                foreach (VBS.TypeSyntax vbType in vbInheritTypes.Types.Skip(start))
                {
                    var i = VB.SyntaxFactory.ImplementsStatement(vbType);
                    vbImplements = vbImplements.Add(i);
                }
                retval.Implements = vbImplements;
            }

            return retval;
        }
示例#6
0
        private VariableDeclaratorSyntax ConvertToVariableDeclaratorOrNull(CSS.IsPatternExpressionSyntax node)
        {
            switch (node.Pattern)
            {
            case CSS.DeclarationPatternSyntax d: {
                var        id    = ((IdentifierNameSyntax)d.Designation.Accept(_nodesVisitor)).Identifier;
                var        ids   = SyntaxFactory.SingletonSeparatedList(SyntaxFactory.ModifiedIdentifier(id));
                TypeSyntax right = (TypeSyntax)d.Type.Accept(_nodesVisitor);

                var simpleAsClauseSyntax = SyntaxFactory.SimpleAsClause(right);
                var equalsValueSyntax    = SyntaxFactory.EqualsValue(
                    SyntaxFactory.LiteralExpression(SyntaxKind.NothingLiteralExpression,
                                                    SyntaxFactory.Token(SyntaxKind.NothingKeyword)));
                return(SyntaxFactory.VariableDeclarator(ids, simpleAsClauseSyntax, equalsValueSyntax));
            }

            case CSS.ConstantPatternSyntax _:
                return(null);

            default:
                throw new ArgumentOutOfRangeException(nameof(node.Pattern), node.Pattern, null);
            }
        }