Esempio n. 1
0
        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");
        }
Esempio n. 2
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);
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        public override void VisitMethodDeclaration(MethodDeclarationSyntax node)
        {
            var name  = node.Identifier.ToString();
            var arity = node.ParameterList.Parameters.Count;
            var nl    = OurLine.NewLine(LineKind.Decl, "MethodDeclaration");
            var mod   = node.Modifiers.ToString();
            var ret   = node.ReturnType.ToString();

            OurLine.AddEssentialInfo(ref nl, "name:" + name);
            OurLine.AddEssentialInfo(ref nl, "return:" + ret);
            OurLine.AddExtraInfo(ref nl, "modifiers:" + mod);
            nl.Source     = node.ToFullString();
            nl.ParentKind = node.Parent.RawKind;
            nl.RawKind    = node.RawKind;
            LogCommand(nl);
            // currentMethod = node;
            StartBlock("MethodDeclaration");
            base.VisitMethodDeclaration(node);
            EndBlock("MethodDeclaration");
        }
Esempio n. 5
0
        // BLOCK STATEMENTS AND CONSTRUCTS

        public override void VisitPropertyDeclaration(PropertyDeclarationSyntax node)
        {
            if (debug)
            {
                Console.WriteLine(node.ToFullString());
            }
            var nl = OurLine.NewLine(LineKind.Decl, "PropertyDeclaration");

            nl.Source = node.ToFullString();
            OurLine.AddEssentialInfo(ref nl, "name:" + node?.Identifier.Text.ToString());

            var cnt = node?.AccessorList?.Accessors.Count.ToString();
            int count;

            if (cnt == null)
            {
                count = 0;
            }
            else
            {
                count = int.Parse(cnt);
            }

            OurLine.AddEssentialInfo(ref nl, "count:" + node?.AccessorList?.Accessors.Count.ToString());

            if (count > 0)
            {
                OurLine.AddExtraInfo(ref nl, "accessor1:" + node?.AccessorList?.Accessors[0].Keyword.Text);
            }
            if (count > 1)
            {
                OurLine.AddExtraInfo(ref nl, "accessor2:" + node?.AccessorList?.Accessors[1].Keyword.Text);
            }
            // sometimes has body etc..
            nl.ParentKind = node.Parent.RawKind;
            nl.RawKind    = node.RawKind;
            LogCommand(nl);
            StartBlock("PropertyDeclaration");
            base.VisitPropertyDeclaration(node);
            EndBlock("PropertyDeclaration");
        }