public override SyntaxNode VisitModuleBlock(ModuleBlockSyntax node)
            {
                node = (ModuleBlockSyntax)base.VisitModuleBlock(node);
                var begin = (ModuleStatementSyntax)EnsureVisibility(node.ModuleStatement, node.ModuleStatement.Modifiers, (x, l) => x.WithModifiers(l), () => SyntaxKind.FriendKeyword);

                return(node.WithModuleStatement(begin));
            }
 public override void VisitModuleBlock(ModuleBlockSyntax node)
 {
     if (TryAddPublicApi(node.ModuleStatement))
     {
         base.VisitModuleBlock(node);
     }
 }
Esempio n. 3
0
        internal static CodeStructureItem MapItem(ModuleBlockSyntax node)
        {
            var item = CreateItem <ClassNode>(node);

            item.AccessModifier = node.ModuleStatement.Modifiers.GetAccessModifier();
            item.Name           = node.ModuleStatement.Identifier.Text;

            return(item);
        }
Esempio n. 4
0
        public override void VisitModuleBlock(ModuleBlockSyntax node)
        {
            if (_targetPatternRegEx.Match(node.ModuleStatement.Identifier.ToString()).Success)
            {
                RecordMatchAndContext(node, BlockType.ModuleBlock);
            }

            base.VisitModuleBlock(node);
        }
 public override SyntaxNode VisitModuleBlock(ModuleBlockSyntax node)
 {
     var savedInModule = _inModule;
     try
     {
         _inModule = true;
         return base.VisitModuleBlock(node);
     }
     finally
     {
         _inModule = savedInModule;
     }
 }
Esempio n. 6
0
            public override SyntaxNode VisitModuleBlock(ModuleBlockSyntax node)
            {
                var savedInModule = _inModule;

                try
                {
                    _inModule = true;
                    return(base.VisitModuleBlock(node));
                }
                finally
                {
                    _inModule = savedInModule;
                }
            }
        public override SyntaxNode VisitModuleBlock(ModuleBlockSyntax node)
        {
            var initInvocations = new SyntaxList <StatementSyntax>();

            var space = SyntaxFactory.SyntaxTrivia(SyntaxKind.WhitespaceTrivia, " ");

            var newline = SyntaxFactory.SyntaxTrivia(SyntaxKind.EndOfLineTrivia, Environment.NewLine);

            for (int a = 0; a < node.Members.Count; a++)
            {
                if (node.Members[a].IsKind(SyntaxKind.FieldDeclaration))
                {
                    foreach (var d in (node.Members[a] as FieldDeclarationSyntax).Declarators)
                    {
                        if (StructuresWithInitializer.Contains(
                                d?.AsClause?.Type().WithoutTrivia().ToFullString()))
                        {
                            foreach (var name in d.Names)
                            {
                                if (name.ArrayBounds != null)
                                {
                                    initInvocations = initInvocations.Add(CreateInitializer(name.Identifier.ToFullString().Trim(), d.AsClause.Type().WithoutTrivia().ToString(), true).WithTrailingTrivia(newline));
                                }
                                else
                                {
                                    initInvocations = initInvocations.Add(CreateInitializer(name.Identifier.ToFullString().Trim(), d.AsClause.Type().WithoutTrivia().ToString(), false).WithTrailingTrivia(newline));
                                }
                            }
                        }
                    }
                }
            }

            if (initInvocations.Count > 0)
            {
                var subStart = SyntaxFactory.SubStatement(SyntaxFactory.Identifier("New()").WithLeadingTrivia(space)).WithLeadingTrivia(newline).WithTrailingTrivia(newline);
                var subEnd   = SyntaxFactory.EndSubStatement(
                    SyntaxFactory.Token(SyntaxKind.EndKeyword, "End ").WithLeadingTrivia(newline), SyntaxFactory.Token(SyntaxKind.SubKeyword, "Sub")).WithTrailingTrivia(newline);

                var moduleConstructor = SyntaxFactory.SubBlock(subStart, initInvocations, subEnd);

                node = node.WithMembers(node.Members.Add(moduleConstructor));
            }

            return(base.VisitModuleBlock(node));
        }
Esempio n. 8
0
        public override void VisitModuleBlock(ModuleBlockSyntax node)
        {
            var statementNode = node.ChildNodes().OfType <ModuleStatementSyntax>().FirstOrDefault();
            var defineName    = statementNode.ChildTokens().FirstOrDefault(x => x.Kind() == SyntaxKind.IdentifierToken).ToString();

            var startLength     = node.Span.Start;
            var endLength       = node.Span.End;
            var parentNamespace = GetNamespace(DefineKinds.Module, startLength, endLength);

            UserDefinitions.Add(new UserDefinition
            {
                DefineKinds    = DefineKinds.Module,
                Namespace      = parentNamespace,
                DefineName     = defineName,
                DefineFullName = $"{parentNamespace}.{defineName}",
                SourceFile     = SourceFile,
                StartLength    = startLength,
                EndLength      = endLength,
            });

            base.VisitModuleBlock(node);
        }
Esempio n. 9
0
            public override SyntaxNode VisitModuleBlock(ModuleBlockSyntax node)
            {
                var savedInModule = _inModule;

                try
                {
                    _inModule = true;
                    node      = (ModuleBlockSyntax)base.VisitModuleBlock(node);
                }
                finally
                {
                    _inModule = savedInModule;
                }

                var begin = (ModuleStatementSyntax)EnsureVisibility(
                    node.ModuleStatement,
                    node.ModuleStatement.ModuleKeyword,
                    node.ModuleStatement.Modifiers,
                    (x, k) => x.WithModuleKeyword(k),
                    (x, l) => x.WithModifiers(l),
                    () => SyntaxKind.FriendKeyword);

                return(node.WithModuleStatement(begin));
            }
Esempio n. 10
0
 public override void VisitModuleBlock(ModuleBlockSyntax node)
 {
     AddBlockData(node);
     base.VisitModuleBlock(node);
 }
Esempio n. 11
0
        public override SyntaxNode VisitModuleBlock(ModuleBlockSyntax node)
        {
            var initInvocations = new SyntaxList <StatementSyntax>();

            var space   = SyntaxFactory.SyntaxTrivia(SyntaxKind.WhitespaceTrivia, " ");
            var newline = SyntaxFactory.SyntaxTrivia(SyntaxKind.EndOfLineTrivia, Environment.NewLine);

            for (int a = 0; a < node.Members.Count; a++)
            {
                if (node.Members[a].IsKind(SyntaxKind.FieldDeclaration))
                {
                    foreach (var declarators in (node.Members[a] as FieldDeclarationSyntax).Declarators)
                    {
                        // Checks for variable declaration
                        string item = declarators?.AsClause?.Type().WithoutTrivia().ToString();
                        if (structuresWithInit.Contains(item))
                        {
                            foreach (var name in declarators.Names)
                            {
                                if (name.ArrayBounds != null)
                                {
                                    initInvocations.Add(
                                        CreateInitializer(
                                            name.Identifier.ToFullString().Trim(), item, true)
                                        .WithTrailingTrivia(newline));
                                }
                                else
                                {
                                    initInvocations.Add(
                                        CreateInitializer(
                                            name.Identifier.ToFullString().Trim(), item, false)
                                        .WithTrailingTrivia(newline));
                                }
                            }
                        } // end check of structures
                    }
                }         // end check of field declarations
            }

            if (initInvocations.Count > 0)
            {
                // Sub New() Statement
                var subStart = SyntaxFactory.SubStatement(
                    SyntaxFactory.Identifier("New()").WithLeadingTrivia(space))
                               .WithLeadingTrivia(newline)
                               .WithTrailingTrivia(newline);

                // End Sub statement
                var subEnd = SyntaxFactory.EndSubStatement(
                    SyntaxFactory.Token(SyntaxKind.EndIfKeyword, "End ").WithLeadingTrivia(newline),
                    SyntaxFactory.Token(SyntaxKind.SubKeyword, "Sub"))
                             .WithTrailingTrivia(newline);

                // Initializer for the module part of the transpiled file
                var moduleConstructor = SyntaxFactory.SubBlock(subStart, initInvocations, subEnd);

                // WithMembers => adds the specified members to the node declaration
                // it makes sense because the node is the root (I think)
                node = node.WithMembers(node.Members.Add(moduleConstructor));
            }
            // Since we want to continue the visit, we call the base method
            return(base.VisitModuleBlock(node));
        }
Esempio n. 12
0
 public override void VisitModuleBlock(ModuleBlockSyntax node)
 {
     LogicalLineCount++;
     base.VisitModuleBlock(node);
 }
Esempio n. 13
0
        private Module TraverseModule(ModuleBlockSyntax mbs)
        {
            Module retClass = new Module();
            retClass.Name = mbs.Begin.Identifier.ValueText;
            //encapsulation

            foreach (SyntaxToken st in mbs.Begin.Modifiers)
            {
                string modifier = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(st.ValueText);
                Encapsulation encap;
                Qualifiers qual;
                if (System.Enum.TryParse<Encapsulation>(modifier, out encap))
                {
                    retClass.Encapsulation.Add(encap);
                }
                else if (System.Enum.TryParse<Qualifiers>(modifier, out qual))
                {
                    retClass.Qualifiers.Add(qual);
                }
            }

            List<EnumBlockSyntax> enums = new List<EnumBlockSyntax>();
            List<StructureBlockSyntax> structs = new List<StructureBlockSyntax>();
            List<MethodBlockSyntax> methods = new List<MethodBlockSyntax>();
            List<FieldDeclarationSyntax> Fields = new List<FieldDeclarationSyntax>();
            List<PropertyBlockSyntax> properties = new List<PropertyBlockSyntax>();
            List<ConstructorBlockSyntax> constructors = new List<ConstructorBlockSyntax>();
            List<ModuleBlockSyntax> modules = new List<ModuleBlockSyntax>();
            List<ClassBlockSyntax> classes = new List<ClassBlockSyntax>();

            foreach (SyntaxNode sn in mbs.ChildNodes())
            {
                if (sn is EnumBlockSyntax)
                {
                    enums.Add(sn as EnumBlockSyntax);
                }
                else if (sn is StructureBlockSyntax)
                {
                    structs.Add(sn as StructureBlockSyntax);
                }
                else if (sn is MethodBlockSyntax)
                {
                    methods.Add(sn as MethodBlockSyntax);
                }
                else if (sn is FieldDeclarationSyntax)
                {
                    Fields.Add(sn as FieldDeclarationSyntax);
                }
                else if (sn is PropertyBlockSyntax)
                {
                    properties.Add(sn as PropertyBlockSyntax);
                }
                else if (sn is ConstructorBlockSyntax)
                {
                    constructors.Add(sn as ConstructorBlockSyntax);
                }
                else if (sn is ModuleBlockSyntax)
                {
                    modules.Add(sn as ModuleBlockSyntax);
                }
                else if (sn is ClassBlockSyntax)
                {
                    classes.Add(sn as ClassBlockSyntax);
                }
            }

            foreach (EnumBlockSyntax ebs in enums)
            {
                //traverse enums
                retClass.Enums.Add(TraverseEnum(ebs));
            }

            foreach (StructureBlockSyntax sbs in structs)
            {
                retClass.Structs.Add(TraverseStruct(sbs));
            }

            foreach (MethodBlockSyntax methbs in methods)
            {
                bool isConstructor = false;
                Method tempMethod = TraverseMethod(methbs, ref isConstructor);
                if (isConstructor)
                {
                    retClass.Constructors.Add(tempMethod as Constructor);
                }
                else
                {
                    retClass.Methods.Add(tempMethod);
                }
            }

            foreach (FieldDeclarationSyntax fds in Fields)
            {
                retClass.Fields.Add(TraverseField(fds));
            }

            foreach (PropertyBlockSyntax pbs in properties)
            {
                retClass.Properties.Add(TraverseProperties(pbs));
            }

            foreach (ConstructorBlockSyntax css in constructors)
            {
                retClass.Constructors.Add(TraverseConstructor(css));
            }

            foreach (ModuleBlockSyntax mbs2 in modules)
            {
                retClass.Modules.Add(TraverseModule(mbs2));
            }

            foreach (ClassBlockSyntax mbs2 in classes)
            {
                retClass.Classes.Add(TraverseClass(mbs2));
            }

            foreach (SyntaxNode sn in mbs.Begin.ChildNodes())
            {
                if (sn is InheritsOrImplementsStatementSyntax)
                {
                }
            }
            return retClass;
        }