예제 #1
0
        internal override void AfterVisitChild()
        {
            if (RootModule.LastScanTokenIndex > ParserContext.Stop.TokenIndex)
            {
                return; // Already scanned in child node.
            }
            for (int i = RootModule.LastScanTokenIndex; i <= ParserContext.Stop.TokenIndex; i++)
            {
                var token = RootModule.VB6CommonTokenStream.Get(i);
                switch (token.Type)
                {
                case VisualBasic6Parser.NEWLINE:
                    ParentCodeBlock.AddCodeModel(new VBNewLine(token));
                    break;

                case VisualBasic6Parser.COMMENT:
                    var isOnNewLine = true;
                    if (token.TokenIndex > 0)
                    {
                        isOnNewLine = (RootModule.VB6CommonTokenStream.Get(token.TokenIndex - 1).Type == VisualBasic6Parser.NEWLINE);
                    }
                    ParentCodeBlock.AddCodeModel(new VBComment(token, isOnNewLine));
                    break;

                default:
                    // ignore the rest
                    break;
                }
            }
            // Make sure to set last scan position to the next token, since the current one has been scanned.
            RootModule.LastScanTokenIndex = ParserContext.Stop.TokenIndex + 1;
        }
예제 #2
0
        internal override void BeforeVisitChild()
        {
            // Look for comment/new line between last scanned position and this code block
            for (int i = RootModule.LastScanTokenIndex; i < ParserContext.Start.TokenIndex; i++)
            {
                var token = RootModule.VB6CommonTokenStream.Get(i);
                switch (token.Type)
                {
                case VisualBasic6Parser.NEWLINE:
                    ParentCodeBlock.AddCodeModel(new VBNewLine(token));
                    break;

                case VisualBasic6Parser.COMMENT:
                    var isOnNewLine = true;
                    if (token.TokenIndex > 0)
                    {
                        isOnNewLine = (RootModule.VB6CommonTokenStream.Get(token.TokenIndex - 1).Type == VisualBasic6Parser.NEWLINE);
                    }
                    ParentCodeBlock.AddCodeModel(new VBComment(token, isOnNewLine));
                    break;

                default:
                    // ignore the rest
                    break;
                }
            }
            // Make sure to set last scan position before visiting all child nodes. This is a shared variable.
            RootModule.LastScanTokenIndex = ParserContext.Start.TokenIndex;
        }
예제 #3
0
        internal override void BeforeVisitChild()
        {
            base.BeforeVisitChild();

            // Not supported in VB.Net
            // VB6 reference: https://docs.microsoft.com/en-us/previous-versions/visualstudio/visual-basic-6/aa243378(v=vs.60)

            var m = new UnSupportedGoSubReturn(ParserContext.Start.Line, ParserContext.Start.Column);

            RootModule.AddConversionMessage(m);
            var c = new VBConversionMessage(m);

            ParentCodeBlock.AddCodeModel(c);
        }
예제 #4
0
        // For Demo
        internal override void BeforeVisitChild()
        {
            // Let base class parse other things first before adding warning
            base.BeforeVisitChild();

            // Give warning for Class_Terminate, cannot convert with 100% same behavior, requires manual re-factoring if doing critical tasks.
            var ctx        = ParserContext as VisualBasic6Parser.SubStmtContext;
            var methodName = ctx.ambiguousIdentifier().GetText();

            if (methodName.Equals("Class_Terminate", StringComparison.InvariantCultureIgnoreCase))
            {
                var m = new UnSupportedClassTerminate(ParserContext.Start.Line, ParserContext.Start.Column);
                RootModule.AddConversionMessage(m);
                var c = new VBConversionMessage(m);
                ParentCodeBlock.AddCodeModel(c);
            }
        }