public static string Map(VisualBasicSyntax.TypeSyntax type, bool useLongNames = false) { if (type == null) { return(string.Empty); } return(Map(type.ToString(), useLongNames)); }
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())); }
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))); }
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); }
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; }
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); } }