public override void VisitClassDeclaration(ClassDeclarationSyntax node)
        {
            var clsname = node.Identifier.ToString();
            var nl      = OurLine.NewLine(LineKind.Decl, "ClassDeclaration");

            OurLine.AddEssentialInfo(ref nl, "name:" + clsname);
            if (node.BaseList != null)
            {
                var baseTypes = node.BaseList.Types.ToString(); //.Select((t) => t.Type.Identifier.Text.ToString()).Join(", ");
                if (debug)
                {
                    System.Console.WriteLine(baseTypes);
                }
                OurLine.AddEssentialInfo(ref nl, "basetypes:" + baseTypes);
            }
            // nl.Source = node.ToFullString();
            // currentClass = node;
            var modifiers = node.Modifiers;

            OurLine.AddExtraInfo(ref nl, "modifiers:" + modifiers.ToString());

            nl.ParentKind = node.Parent.RawKind;
            nl.RawKind    = node.RawKind;
            LogCommand(nl);
            StartBlock("ClassDeclaration");
            base.VisitClassDeclaration(node);
            EndBlock("ClassDeclaration");
        }
        public override void VisitTryStatement(TryStatementSyntax node)
        {
            if (debug)
            {
                Console.WriteLine(node.ToFullString());
            }
            var nl = OurLine.NewLine(LineKind.Decl, "TryStatement");

            if (node.Finally != null)
            {
                OurLine.AddEssentialInfo(ref nl, "finally:" + node.Finally.ToString());
            }
            if (node.Catches != null)
            {
                OurLine.AddEssentialInfo(ref nl, "catches:" + node.Catches.ToString());
            }
            // we get the details later on.
            nl.Source     = node.ToFullString();
            nl.ParentKind = node.Parent.RawKind;
            nl.RawKind    = node.RawKind;
            LogCommand(nl);

            StartBlock("TryStatement");
            base.VisitTryStatement(node);
            EndBlock("TryStatement");
        }
        public override void VisitAccessorDeclaration(AccessorDeclarationSyntax node)
        {
            if (debug)
            {
                Console.WriteLine(node.ToFullString());
            }
            var nl   = OurLine.NewLine(LineKind.Decl, "AccessorDeclaration");
            var stms = node?.Body?.Statements.Select((x) => x.ToString());

            OurLine.AddEssentialInfo(ref nl, "keyword:" + node.Keyword.Text);
            if (stms != null)
            {
                var statements = string.Join("###", stms);
                OurLine.AddEssentialInfo(ref nl, "statements:" + statements);
            }

            OurLine.AddEssentialInfo(ref nl, "modifiers:" + node.Modifiers.ToString());
            OurLine.AddEssentialInfo(ref nl, "expressionBody:" + node.ExpressionBody?.ToString() ?? "");
            nl.Source = node.ToFullString();
            // nl.ParentKind = node.Parent.RawKind;
            nl.RawKind = node.RawKind;
            LogCommand(nl);
            StartBlock("AccessorDeclaration");
            base.VisitAccessorDeclaration(node);
            EndBlock("AccessorDeclaration");
        }
        public override void VisitIfStatement(IfStatementSyntax node)
        {
            if (debug)
            {
                Console.WriteLine(node.ToFullString());
            }
            var nl = OurLine.NewLine(LineKind.Decl, "IfStatement");

            // condition, statement, else.statement
            nl.Source = node.ToFullString();
            OurLine.AddEssentialInfo(ref nl, "condition:" + node.Condition.ToString());
            OurLine.AddEssentialInfo(ref nl, "statement:" + node.Statement.ToString());
            var elsey = node.Else?.Statement;

            if (elsey != null)
            {
                OurLine.AddEssentialInfo(ref nl, "else:" + elsey.ToString());
            }


            nl.ParentKind = node.Parent.RawKind;
            nl.RawKind    = node.RawKind;
            LogCommand(nl);

            StartBlock("IfStatement");
            base.VisitIfStatement(node);
            EndBlock("IfStatement");
        }
Exemple #5
0
 public static void AddEssentialInfo(ref OurLine line, string value)
 {
     if (line.Info == null)
     {
         line.Info = new Info();
     }
     line.Info.Essentials.Add(value);
 }
Exemple #6
0
 public static void AddExtraInfo(ref OurLine line, string value)
 {
     if (line.Info == null)
     {
         line.Info = new Info();
     }
     line.Info?.Extras?.Add(value);
 }
Exemple #7
0
 public void LogCommand(OurLine line)
 {
     // var s = JsonConvert.SerializeObject(line);
     if (debug)
     {
         Console.WriteLine(line);
     }
     lines.Add(line);
 }
Exemple #8
0
        public void EndBlock(string desc)
        {
            blockCount--;
            var nl = new OurLine(LineKind.EndBlock);

            OurLine.AddEssentialInfo(ref nl, blockCount.ToString());
            OurLine.AddEssentialInfo(ref nl, desc);

            LogCommand(nl);
        }
Exemple #9
0
        public override void VisitQualifiedName(QualifiedNameSyntax node)
        {
            var text = node.ToString();
            var nl   = OurLine.NewLine(LineKind.Decl, "QualifiedName");

            OurLine.AddEssentialInfo(ref nl, "name:" + text);
            // nl.Source = node.ToFullString();
            nl.ParentKind = node.Parent.RawKind;
            nl.RawKind    = node.RawKind;
            LogCommand(nl);
            base.VisitQualifiedName(node);
        }
Exemple #10
0
        public override void VisitLiteralExpression(LiteralExpressionSyntax node)
        {
            var token = node.Token.ToString();
            var nl    = OurLine.NewLine(LineKind.Decl, "LiteralExpression");

            OurLine.AddEssentialInfo(ref nl, "token:" + token);
            nl.Source     = node.ToFullString();
            nl.ParentKind = node.Parent.RawKind;
            nl.RawKind    = node.RawKind;
            LogCommand(nl);
            base.VisitLiteralExpression(node);
        }
Exemple #11
0
        public override void VisitArgumentList(ArgumentListSyntax node)
        {
            var args = node.Arguments.ToString();
            var nl   = OurLine.NewLine(LineKind.Decl, "ArgumentList");

            OurLine.AddEssentialInfo(ref nl, "arguments:" + args);
            nl.Source     = node.ToFullString();
            nl.ParentKind = node.Parent.RawKind;
            nl.RawKind    = node.RawKind;
            LogCommand(nl);
            base.VisitArgumentList(node);
        }
Exemple #12
0
        // string currentBlock = "";
        public void StartBlock(string desc)
        {
            blockCount++;
            // currentBlock = desc;
            var nl = OurLine.NewLine(LineKind.Decl, "BlockStarts");

            OurLine.AddEssentialInfo(ref nl, blockCount.ToString());
            if (desc != "")
            {
                OurLine.AddExtraInfo(ref nl, desc);
            }
            LogCommand(nl);
        }
Exemple #13
0
 public override void VisitForEachStatement(ForEachStatementSyntax node)
 {
     if (debug)
     {
         Console.WriteLine(node.ToFullString());
     }
     Todo("ForEachStatement"); var nl = OurLine.NewLine(LineKind.Decl, "ForEachStatement");
     nl.Source     = node.ToFullString();
     nl.ParentKind = node.Parent.RawKind;
     nl.RawKind    = node.RawKind;
     LogCommand(nl);
     StartBlock("ForEachStatement");
     base.VisitForEachStatement(node);
     EndBlock("ForEachStatement");
 }
Exemple #14
0
        // TODO(mostused)
        public override void VisitExpressionStatement(ExpressionStatementSyntax node)
        {
            if (debug)
            {
                Console.WriteLine(node.ToFullString());
            }
            var nl = OurLine.NewLine(LineKind.Decl, "ExpressionStatement");

            nl.Source     = node.ToFullString();
            nl.ParentKind = node.Parent.RawKind;
            nl.RawKind    = node.RawKind;
            LogCommand(nl);

            base.VisitExpressionStatement(node);
        }
Exemple #15
0
        public override void VisitIdentifierName(IdentifierNameSyntax node)
        {
            if (debug)
            {
                Console.WriteLine(node.ToFullString());
            }
            var nl = OurLine.NewLine(LineKind.Decl, "IdentifierName");

            nl.Source = node.ToFullString();
            OurLine.AddEssentialInfo(ref nl, "name:" + node.Identifier.ToString());
            nl.ParentKind = node.Parent.RawKind;
            nl.RawKind    = node.RawKind;
            LogCommand(nl);
            base.VisitIdentifierName(node);
        }
Exemple #16
0
        public override void VisitVariableDeclaration(VariableDeclarationSyntax node)
        {
            var t       = node.Type.ToString();
            var vars    = node.Variables;
            var varName = vars[0].Identifier.ToString();
            var nl      = OurLine.NewLine(LineKind.Decl, "VariableDeclaration");

            OurLine.AddEssentialInfo(ref nl, "type:" + t);
            OurLine.AddEssentialInfo(ref nl, "name:" + varName);
            nl.Source     = node.ToFullString();
            nl.ParentKind = node.Parent.RawKind;
            nl.RawKind    = node.RawKind;
            LogCommand(nl);
            base.VisitVariableDeclaration(node);
        }
Exemple #17
0
        public override void VisitBaseList(BaseListSyntax node)
        {
            if (debug)
            {
                Console.WriteLine(node.ToFullString());
            }
            var nl = OurLine.NewLine(LineKind.Decl, "BaseList");

            nl.Source = node.ToFullString();
            OurLine.AddEssentialInfo(ref nl, node.Types.ToString());
            nl.ParentKind = node.Parent.RawKind;
            nl.RawKind    = node.RawKind;
            LogCommand(nl);
            base.VisitBaseList(node);
        }
Exemple #18
0
        // TODO: well, we probably have the same info later on, with MemberAccessExpression etc.
        public override void VisitInvocationExpression(InvocationExpressionSyntax node)
        {
            var expr = node.Expression;
            // var argList = node.ArgumentList;

            var nl = OurLine.NewLine(LineKind.Decl, "InvocationExpression");

            OurLine.AddEssentialInfo(ref nl, "expression:" + expr.ToString());
            nl.Source     = node.ToFullString();
            nl.ParentKind = node.Parent.RawKind;
            nl.RawKind    = node.RawKind;

            LogCommand(nl);
            base.VisitInvocationExpression(node);
        }
Exemple #19
0
 public override void VisitAnonymousMethodExpression(AnonymousMethodExpressionSyntax node)
 {
     if (debug)
     {
         Console.WriteLine(node.ToFullString());
     }
     Todo("AnonymousMethodExpression"); var nl = OurLine.NewLine(LineKind.Decl, "AnonymousMethodExpression");
     nl.Source     = node.ToFullString();
     nl.ParentKind = node.Parent.RawKind;
     nl.RawKind    = node.RawKind;
     LogCommand(nl);
     StartBlock("AnonymousMethodExpression");
     base.VisitAnonymousMethodExpression(node);
     EndBlock("AnonymousMethodExpression");
 }
Exemple #20
0
 public override void VisitConversionOperatorDeclaration(ConversionOperatorDeclarationSyntax node)
 {
     if (debug)
     {
         Console.WriteLine(node.ToFullString());
     }
     Todo("ConversionOperatorDeclaration"); var nl = OurLine.NewLine(LineKind.Decl, "ConversionOperatorDeclaration");
     nl.Source     = node.ToFullString();
     nl.ParentKind = node.Parent.RawKind;
     nl.RawKind    = node.RawKind;
     LogCommand(nl);
     StartBlock("ConversionOperatorDeclaration");
     base.VisitConversionOperatorDeclaration(node);
     EndBlock("ConversionOperatorDeclaration");
 }
Exemple #21
0
        public override void VisitPredefinedType(PredefinedTypeSyntax node)
        {
            if (debug)
            {
                Console.WriteLine(node.ToFullString());
            }
            var nl = OurLine.NewLine(LineKind.Decl, "PredefinedType");

            OurLine.AddEssentialInfo(ref nl, "keyword:" + node.Keyword.ToString());
            nl.Source     = node.ToFullString();
            nl.ParentKind = node.Parent.RawKind;
            nl.RawKind    = node.RawKind;
            LogCommand(nl);

            base.VisitPredefinedType(node);
        }
Exemple #22
0
        public override void VisitNamespaceDeclaration(NamespaceDeclarationSyntax node)
        {
            var name = node.Name.ToString();
            // currentNamespace = null;
            var nl = OurLine.NewLine(LineKind.Decl, "NamespaceDeclaration");

            OurLine.AddEssentialInfo(ref nl, "name:" + name);
            // nl.Source = node.ToFullString();
            nl.ParentKind = node.Parent.RawKind;
            nl.RawKind    = node.RawKind;
            LogCommand(nl);
            // currentNamespace = node;
            StartBlock("NamespaceDeclaration"); // worked wonderfully!
            base.VisitNamespaceDeclaration(node);
            EndBlock("NamespaceDeclaration");   // god is good!
        }
Exemple #23
0
        public override void VisitCatchClause(CatchClauseSyntax node)
        {
            if (debug)
            {
                Console.WriteLine(node.ToFullString());
            }
            var nl = OurLine.NewLine(LineKind.Decl, "CatchClause");

            nl.Source     = node.ToFullString();
            nl.ParentKind = node.Parent.RawKind;
            nl.RawKind    = node.RawKind;
            LogCommand(nl);
            StartBlock("CatchClause");
            base.VisitCatchClause(node);
            EndBlock("CatchClause");
        }
Exemple #24
0
        public override void VisitExplicitInterfaceSpecifier(ExplicitInterfaceSpecifierSyntax node)
        {
            if (debug)
            {
                Console.WriteLine(node.ToFullString());
            }
            var nl = OurLine.NewLine(LineKind.Decl, "ExplicitInterfaceSpecifier");

            OurLine.AddEssentialInfo(ref nl, "name:" + node.Name.ToString().TrimEnd('.'));
            // System.Console.WriteLine(node.Name.ToString());
            nl.Source     = node.ToFullString();
            nl.ParentKind = node.Parent.RawKind;
            nl.RawKind    = node.RawKind;
            LogCommand(nl);
            base.VisitExplicitInterfaceSpecifier(node);
        }
Exemple #25
0
        public override void VisitParameter(ParameterSyntax node)
        {
            var nl = OurLine.NewLine(LineKind.Decl, "Parameter");

            OurLine.AddEssentialInfo(ref nl, "name:" + node.Identifier.Text);
            OurLine.AddEssentialInfo(ref nl, "type:" + node.Type?.GetText().ToString());
            if (node.Modifiers.Count > 0)
            {
                OurLine.AddExtraInfo(ref nl, "modifiers:" + node.Modifiers.ToString());
            }
            nl.Source     = node.ToFullString();
            nl.ParentKind = node.Parent.RawKind;
            nl.RawKind    = node.RawKind;
            LogCommand(nl);
            base.VisitParameter(node);
        }
Exemple #26
0
        public override void VisitObjectCreationExpression(ObjectCreationExpressionSyntax node)
        {
            if (debug)
            {
                Console.WriteLine(node.ToFullString());
            }
            var nl = OurLine.NewLine(LineKind.Decl, "ObjectCreationExpression");

            OurLine.AddEssentialInfo(ref nl, "type:" + node.Type.ToString());
            // # the rest come later. (i think)
            nl.Source     = node.ToFullString();
            nl.ParentKind = node.Parent.RawKind;
            nl.RawKind    = node.RawKind;
            LogCommand(nl);
            base.VisitObjectCreationExpression(node);
        }
Exemple #27
0
        public override void VisitCastExpression(CastExpressionSyntax node)
        {
            if (debug)
            {
                Console.WriteLine(node.ToFullString());
            }
            // Todo("CastExpression");
            var nl = OurLine.NewLine(LineKind.Decl, "CastExpression");

            nl.Source     = node.ToFullString();
            nl.ParentKind = node.Parent.RawKind;
            nl.RawKind    = node.RawKind;
            OurLine.AddEssentialInfo(ref nl, "type:" + node.Type.ToString());
            OurLine.AddEssentialInfo(ref nl, "expr:" + node.Expression.ToString());
            LogCommand(nl);
            base.VisitCastExpression(node);
        }
Exemple #28
0
        public override void VisitConditionalExpression(ConditionalExpressionSyntax node)
        {
            if (debug)
            {
                Console.WriteLine(node.ToFullString());
            }
            // Todo("ConditionalExpression");
            var nl = OurLine.NewLine(LineKind.Decl, "ConditionalExpression");

            OurLine.AddEssentialInfo(ref nl, "condition:" + node.Condition.ToString());
            OurLine.AddEssentialInfo(ref nl, "whentrue:" + node.WhenTrue.ToString());
            OurLine.AddEssentialInfo(ref nl, "whenfalse:" + node.WhenFalse.ToString());
            nl.Source     = node.ToFullString();
            nl.ParentKind = node.Parent.RawKind;
            nl.RawKind    = node.RawKind;
            LogCommand(nl);
            base.VisitConditionalExpression(node);
        }
Exemple #29
0
        public override void VisitFieldDeclaration(FieldDeclarationSyntax node)
        {
            if (debug)
            {
                Console.WriteLine(node.ToFullString());
            }

            var nl = OurLine.NewLine(LineKind.Decl, "FieldDeclaration");

            OurLine.AddEssentialInfo(ref nl, "modifiers:" + node.Modifiers.ToString());
            OurLine.AddEssentialInfo(ref nl, "type:" + node.Declaration.Type.ToString());
            OurLine.AddEssentialInfo(ref nl, "variables:" + node.Declaration.Variables.ToString());
            nl.Source     = node.ToFullString();
            nl.ParentKind = node.Parent.RawKind;
            nl.RawKind    = node.RawKind;
            LogCommand(nl);
            base.VisitFieldDeclaration(node);
        }
Exemple #30
0
        // TODO(mostused)
        public override void VisitAssignmentExpression(AssignmentExpressionSyntax node)
        {
            if (debug)
            {
                Console.WriteLine(node.ToFullString());
            }
            var nl = OurLine.NewLine(LineKind.Decl, "AssignmentExpression");

            OurLine.AddEssentialInfo(ref nl, "left:" + node.Left.ToString());
            OurLine.AddEssentialInfo(ref nl, "op:" + node.OperatorToken.ToString());
            OurLine.AddEssentialInfo(ref nl, "right:" + node.Right.ToString());
            nl.Source     = node.ToFullString();
            nl.ParentKind = node.Parent.RawKind;
            nl.RawKind    = node.RawKind;
            LogCommand(nl);

            base.VisitAssignmentExpression(node);
        }