Exemplo n.º 1
0
        private VisualBasicSyntaxNode WithMappedBlockEnd(CsSyntax.BaseTypeDeclarationSyntax node)
        {
            var convertedNode = (VbSyntax.TypeBlockSyntax)DefaultVisitInner(node);

            return(convertedNode.WithEndBlockStatement(
                       convertedNode.EndBlockStatement.WithSourceMappingFrom(node.CloseBraceToken)
                       ));
        }
 IEnumerable <StatementSyntax> PatchInlineHelpers(CSS.BaseTypeDeclarationSyntax node)
 {
     if (inlineAssignHelperMarkers.Contains(node))
     {
         inlineAssignHelperMarkers.Remove(node);
         yield return(SyntaxFactory.ParseSyntaxTree(InlineAssignHelperCode)
                      .GetRoot().ChildNodes().FirstOrDefault().NormalizeWhitespace() as StatementSyntax);
     }
 }
            private void ConvertBaseList(CSS.BaseTypeDeclarationSyntax type, List <InheritsStatementSyntax> inherits, List <ImplementsStatementSyntax> implements)
            {
                TypeSyntax[] arr;
                switch (type.Kind())
                {
                case CS.SyntaxKind.ClassDeclaration:
                    var classOrInterface = type.BaseList?.Types.FirstOrDefault()?.Type;
                    if (classOrInterface == null)
                    {
                        return;
                    }
                    var classOrInterfaceSymbol = semanticModel.GetSymbolInfo(classOrInterface).Symbol;
                    if (classOrInterfaceSymbol == null)
                    {
                        return;
                    }
                    if (classOrInterfaceSymbol.IsInterfaceType())
                    {
                        arr = type.BaseList?.Types.Select(t => (TypeSyntax)t.Type.Accept(this)).ToArray();
                        if (arr.Length > 0)
                        {
                            implements.Add(SyntaxFactory.ImplementsStatement(arr));
                        }
                    }
                    else
                    {
                        inherits.Add(SyntaxFactory.InheritsStatement((TypeSyntax)classOrInterface.Accept(this)));
                        arr = type.BaseList?.Types.Skip(1).Select(t => (TypeSyntax)t.Type.Accept(this)).ToArray();
                        if (arr.Length > 0)
                        {
                            implements.Add(SyntaxFactory.ImplementsStatement(arr));
                        }
                    }
                    break;

                case CS.SyntaxKind.StructDeclaration:
                    arr = type.BaseList?.Types.Select(t => (TypeSyntax)t.Type.Accept(this)).ToArray();
                    if (arr.Length > 0)
                    {
                        implements.Add(SyntaxFactory.ImplementsStatement(arr));
                    }
                    break;

                case CS.SyntaxKind.InterfaceDeclaration:
                    arr = type.BaseList?.Types.Select(t => (TypeSyntax)t.Type.Accept(this)).ToArray();
                    if (arr.Length > 0)
                    {
                        inherits.Add(SyntaxFactory.InheritsStatement(arr));
                    }
                    break;
                }
            }
Exemplo n.º 4
0
        private CsSyntax.BaseTypeDeclarationSyntax WithTypeBlockTrivia(VbSyntax.TypeBlockSyntax sourceNode, CsSyntax.BaseTypeDeclarationSyntax destNode)
        {
            var beforeOpenBrace = destNode.OpenBraceToken.GetPreviousToken();
            var withAnnotation  = TriviaConverter.WithDelegateToParentAnnotation(sourceNode.BlockStatement, beforeOpenBrace);

            withAnnotation = TriviaConverter.WithDelegateToParentAnnotation(sourceNode.Inherits, withAnnotation);
            withAnnotation = TriviaConverter.WithDelegateToParentAnnotation(sourceNode.Implements, withAnnotation);
            return(destNode.ReplaceToken(beforeOpenBrace, withAnnotation));
        }