Esempio n. 1
0
        public Property()
        {
            Encapsulation = new List<Model.Encapsulation>();
            Qualifers = new List<Qualifiers>();
            Type = new Model.Type();

            Getter = new Method();
            Setter = new Method();
        }
Esempio n. 2
0
        private Model.Delegate TraverseDelegate(DelegateStatementSyntax ebs)
        {
            Model.Delegate retDelegate = new Model.Delegate();

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

            Method aMethod = new Method();

            aMethod.Name = ebs.Identifier.ValueText;

            ParameterListSyntax pls = ebs.ParameterList;

            //Parameters
            foreach (ParameterSyntax ps in pls.Parameters)
            {
                aMethod.Parameters.Add(TraverseParameters(ps));
            }

            retDelegate.ReferencedMethods.Add(aMethod);

            return retDelegate;
        }
Esempio n. 3
0
        private Method TraverseAccessVars(AssignmentStatementSyntax vnes)
        {
            Method retMethod = new Method();
            if (vnes.Left is IdentifierNameSyntax)
            {
                Variables retVar = new Variables();
                retVar.IsReferenced = true;
                retVar.Name = (vnes.Left as IdentifierNameSyntax).Identifier.ValueText;
                retMethod.AccessedVariables.Add(retVar);
            }
            else if (vnes.Left is MemberAccessExpressionSyntax)
            {
                MemberAccessExpressionSyntax maes = vnes.Left as MemberAccessExpressionSyntax;
                Variables retVar = new Variables();
                retVar.Name = maes.ToString();
                retVar.IsReferenced = true;
                retMethod.AccessedVariables.Add(retVar);
            }
            else
            {
                foreach (SyntaxNode sn in vnes.Left.ChildNodes())
                {
                    if (sn is VariableDeclaratorSyntax)
                    {
                        Variables retVar = new Variables();
                        retVar = TraverseVariableSyntax(sn as VariableDeclaratorSyntax, null, null);
                        retVar.IsReferenced = true;
                        retMethod.AccessedVariables.Add(retVar);
                    }
                    else if (sn is CallStatementSyntax)
                    {
                        retMethod.InvokedMethods.Add(TraverseInvokedMethod(sn as CallStatementSyntax));
                    }
                    else if (sn is MemberAccessExpressionSyntax)
                    {
                        MemberAccessExpressionSyntax maes = sn as MemberAccessExpressionSyntax;
                        Variables retVar = new Variables();
                        retVar.Name = maes.ToString();
                        retVar.IsReferenced = true;
                        retMethod.AccessedVariables.Add(retVar);
                    }
                }
            }
            if (vnes.Right is IdentifierNameSyntax)
            {
                Variables retVar = new Variables();
                retVar.IsReferenced = true;
                retVar.Name = (vnes.Right as IdentifierNameSyntax).Identifier.ValueText;
                retMethod.AccessedVariables.Add(retVar);
            }
            else if (vnes.Right is MemberAccessExpressionSyntax)
            {
                MemberAccessExpressionSyntax maes = vnes.Right as MemberAccessExpressionSyntax;
                Variables retVar = new Variables();
                retVar.Name = maes.ToString();
                retVar.IsReferenced = true;
                retMethod.AccessedVariables.Add(retVar);
            }
            else
            {
                foreach (SyntaxNode sn in vnes.Right.ChildNodes())
                {
                    if (sn is VariableDeclaratorSyntax)
                    {
                        Variables retVar = new Variables();
                        retVar = TraverseVariableSyntax(sn as VariableDeclaratorSyntax, null, null);
                        retVar.IsReferenced = true;
                        retMethod.AccessedVariables.Add(retVar);
                    }
                    else if (sn is CallStatementSyntax)
                    {
                        retMethod.InvokedMethods.Add(TraverseInvokedMethod(sn as CallStatementSyntax));
                    }
                    else if (sn is MemberAccessExpressionSyntax)
                    {
                        MemberAccessExpressionSyntax maes = sn as MemberAccessExpressionSyntax;
                        Variables retVar = new Variables();
                        retVar.Name = maes.ToString();
                        retVar.IsReferenced = true;
                        retMethod.AccessedVariables.Add(retVar);
                    }
                }
            }

            return retMethod;
        }
Esempio n. 4
0
        private Method TraverseVarDecls(LocalDeclarationStatementSyntax ldss)
        {
            Method retMethod = new Method();
            List<Encapsulation> accessability = new List<Encapsulation>();
            List<Qualifiers> qualifiers = new List<Qualifiers>();
            foreach (SyntaxToken st in ldss.Modifiers)
            {
                string modifier = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(st.ValueText);
                Encapsulation encap;
                Qualifiers qual;
                if (System.Enum.TryParse<Encapsulation>(modifier, out encap))
                {
                    accessability.Add(encap);
                }
                else if (System.Enum.TryParse<Qualifiers>(modifier, out qual))
                {
                    qualifiers.Add(qual);
                }
            }

            foreach (SyntaxNode ss in ldss.ChildNodes())
            {
                if (ss is VariableDeclaratorSyntax)
                {
                    Variables retVar = new Variables();
                    retVar = TraverseVariableSyntax(ss as VariableDeclaratorSyntax, accessability, qualifiers);
                    retMethod.AccessedVariables.Add(retVar);
                }
                else if (ss is CallStatementSyntax)
                {
                    retMethod.InvokedMethods.Add(TraverseInvokedMethod(ss as CallStatementSyntax));
                }
            }

            return retMethod;
        }
Esempio n. 5
0
        private Method TraverseMethod(MethodBlockSyntax mbs, ref bool isConstructor)
        {
            Method retMethod = new Method();

            //get the MethodStatementSyntax
            MethodStatementSyntax methodss = null;
            foreach (SyntaxNode sn in mbs.ChildNodes())
            {
                if (sn is MethodStatementSyntax)
                {
                    methodss = sn as MethodStatementSyntax;
                    break;
                }
                else if (sn is ConstructorBlockSyntax)
                {
                    return TraverseConstructor(sn as ConstructorBlockSyntax);
                }
            }

            if (methodss == null)
            {
                throw new Exception("Bad MethodBlockStatement!");
            }

            if (methodss != null)
            {
                retMethod.Name = methodss.Identifier.ValueText;
            }

            /*
            Preprocessors = new List<Preprocessor>();
            Encapsulation = new List<Encapsulation>();
            Base = new List<InvokedMethod>();
            ReturnType = new Type();
            Qualifiers = new List<Qualifiers>();
            Parameters = new List<Variables>();
            Decisions = new Decisions();
            AccessedVariables = new List<Variables>();
            LabelStatements = new List<LabelStatement>();
            GoToStatements = new List<GoTo>();
            InvokedMethods = new List<InvokedMethod>();
             */

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

            //TODO: Need to determine what the qualifers are

            //TODO: Qualifiers

            ParameterListSyntax pls = methodss.ParameterList;

            //Parameters
            foreach (ParameterSyntax ps in pls.Parameters)
            {
                retMethod.Parameters.Add(TraverseParameters(ps));
            }

            //Decisions
            List<MultiLineIfBlockSyntax> multiIfStms = new List<MultiLineIfBlockSyntax>();
            List<SingleLineIfStatementSyntax> ifStms = new List<SingleLineIfStatementSyntax>();
            List<ElseStatementSyntax> elseStm = new List<ElseStatementSyntax>();
            List<ForEachStatementSyntax> foreachStm = new List<ForEachStatementSyntax>();
            List<ForBlockSyntax> forStm = new List<ForBlockSyntax>();
            List<DoLoopBlockSyntax> doWhileStm = new List<DoLoopBlockSyntax>();
            List<WhileBlockSyntax> whileStm = new List<WhileBlockSyntax>();
            List<SelectBlockSyntax> switchStm = new List<SelectBlockSyntax>();
            List<CatchPartSyntax> catchStmm = new List<CatchPartSyntax>();
            //Access Variables
            List<LocalDeclarationStatementSyntax> accessVarDefs = new List<LocalDeclarationStatementSyntax>();
            List<AssignmentStatementSyntax> accessVars = new List<AssignmentStatementSyntax>();
            //Label Statements
            List<LabelStatementSyntax> labelStms = new List<LabelStatementSyntax>();
            //GoTo Statements
            List<GoToStatementSyntax> gotoStms = new List<GoToStatementSyntax>();
            //InvokedMethods
            List<CallStatementSyntax> invokedMethods = new List<CallStatementSyntax>();
            List<InvocationExpressionSyntax> invokedMethods2 = new List<InvocationExpressionSyntax>();
            //Returns
            List<ReturnStatementSyntax> returns = new List<ReturnStatementSyntax>();

            foreach (SyntaxNode sn in mbs.Statements)
            {
                if (sn is MultiLineIfBlockSyntax)
                {
                    multiIfStms.Add(sn as MultiLineIfBlockSyntax);
                }
                if (sn is SingleLineIfStatementSyntax)
                {
                    ifStms.Add(sn as SingleLineIfStatementSyntax);
                }
                else if (sn is ElseStatementSyntax)
                {
                    elseStm.Add(sn as ElseStatementSyntax);
                }
                else if (sn is ForEachStatementSyntax)
                {
                    foreachStm.Add(sn as ForEachStatementSyntax);
                }
                else if (sn is ForBlockSyntax)
                {
                    forStm.Add(sn as ForBlockSyntax);
                }
                else if (sn is DoLoopBlockSyntax)
                {
                    doWhileStm.Add(sn as DoLoopBlockSyntax);
                }
                else if (sn is WhileBlockSyntax)
                {
                    whileStm.Add(sn as WhileBlockSyntax);
                }
                else if (sn is SelectBlockSyntax)
                {
                    switchStm.Add(sn as SelectBlockSyntax);
                }
                else if (sn is CatchPartSyntax)
                {
                    catchStmm.Add(sn as CatchPartSyntax);
                }
                else if (sn is LocalDeclarationStatementSyntax)
                {
                    accessVarDefs.Add(sn as LocalDeclarationStatementSyntax);
                }
                else if (sn is AssignmentStatementSyntax)
                {
                    accessVars.Add(sn as AssignmentStatementSyntax);
                }
                else if (sn is LabelStatementSyntax)
                {
                    labelStms.Add(sn as LabelStatementSyntax);
                }
                else if (sn is LabelStatementSyntax)
                {
                    gotoStms.Add(sn as GoToStatementSyntax);
                }
                else if (sn is GoToStatementSyntax)
                {
                    gotoStms.Add(sn as GoToStatementSyntax);
                }
                else if (sn is CallStatementSyntax)
                {
                    invokedMethods.Add(sn as CallStatementSyntax);
                }
                else if (sn is InvocationExpressionSyntax)
                {
                    invokedMethods2.Add(sn as InvocationExpressionSyntax);
                }
                else if (sn is ReturnStatementSyntax)
                {
                    returns.Add(sn as ReturnStatementSyntax);
                }
            }

            foreach (MultiLineIfBlockSyntax mlbs in multiIfStms)
            {
                int exitPoints = retMethod.ExitPoints;
                Decisions tempDecision = AllDecisions(TraverseMultiIfStatement(mlbs, ref exitPoints));

                retMethod.Decisions.IfStatements.AddRange(tempDecision.IfStatements);
                retMethod.Decisions.ElseStatements.AddRange(tempDecision.ElseStatements);
                retMethod.Decisions.ForEachStatements.AddRange(tempDecision.ForEachStatements);
                retMethod.Decisions.ForStatements.AddRange(tempDecision.ForStatements);
                retMethod.Decisions.WhileLoops.AddRange(tempDecision.WhileLoops);
                retMethod.Decisions.DoWhileLoops.AddRange(tempDecision.DoWhileLoops);
                retMethod.Decisions.Catches.AddRange(tempDecision.Catches);
                retMethod.Decisions.SwitchStatements.AddRange(tempDecision.SwitchStatements);
                retMethod.ExitPoints = exitPoints;
            }

            foreach (SingleLineIfStatementSyntax iss in ifStms)
            {
                int exitPoints = retMethod.ExitPoints;
                Decisions tempDecision = AllDecisions(TraverseIfStatement(iss, ref exitPoints));
                retMethod.Decisions.IfStatements.AddRange(tempDecision.IfStatements);
                retMethod.Decisions.ElseStatements.AddRange(tempDecision.ElseStatements);
                retMethod.Decisions.ForEachStatements.AddRange(tempDecision.ForEachStatements);
                retMethod.Decisions.ForStatements.AddRange(tempDecision.ForStatements);
                retMethod.Decisions.WhileLoops.AddRange(tempDecision.WhileLoops);
                retMethod.Decisions.DoWhileLoops.AddRange(tempDecision.DoWhileLoops);
                retMethod.Decisions.Catches.AddRange(tempDecision.Catches);
                retMethod.Decisions.SwitchStatements.AddRange(tempDecision.SwitchStatements);
                retMethod.ExitPoints = exitPoints;
            }
            foreach (ElseStatementSyntax ess in elseStm)
            {
                int exitPoints = retMethod.ExitPoints;
                retMethod.Decisions.ElseStatements.Add(TravsereElseStatement(ess, ref exitPoints));
                retMethod.ExitPoints = exitPoints;
            }
            foreach (ForEachStatementSyntax fess in foreachStm)
            {
                int exitPoints = retMethod.ExitPoints;
                retMethod.Decisions.ForEachStatements.Add(TraverseForeachStatement(fess, ref exitPoints));
                retMethod.ExitPoints = exitPoints;
            }
            foreach (ForBlockSyntax fss in forStm)
            {
                int exitPoints = retMethod.ExitPoints;
                Decisions tempDecision = AllDecisions(TraverseForStatement(fss, ref exitPoints));
                retMethod.Decisions.IfStatements.AddRange(tempDecision.IfStatements);
                retMethod.Decisions.ElseStatements.AddRange(tempDecision.ElseStatements);
                retMethod.Decisions.ForEachStatements.AddRange(tempDecision.ForEachStatements);
                retMethod.Decisions.ForStatements.AddRange(tempDecision.ForStatements);
                retMethod.Decisions.WhileLoops.AddRange(tempDecision.WhileLoops);
                retMethod.Decisions.DoWhileLoops.AddRange(tempDecision.DoWhileLoops);
                retMethod.Decisions.Catches.AddRange(tempDecision.Catches);
                retMethod.Decisions.SwitchStatements.AddRange(tempDecision.SwitchStatements);
                retMethod.ExitPoints = exitPoints;
            }
            foreach (DoLoopBlockSyntax dss in doWhileStm)
            {
                int exitPoints = retMethod.ExitPoints;
                retMethod.Decisions.DoWhileLoops.Add(TraverseDoWhileLoop(dss, ref exitPoints));
                retMethod.ExitPoints = exitPoints;
            }
            foreach (WhileBlockSyntax wbs in whileStm)
            {
                int exitPoints = retMethod.ExitPoints;
                retMethod.Decisions.WhileLoops.Add(TraverseWhileLoop(wbs, ref exitPoints));
                retMethod.ExitPoints = exitPoints;
            }
            foreach (SelectBlockSyntax sbs in switchStm)
            {
                int exitPoints = retMethod.ExitPoints;
                retMethod.Decisions.SwitchStatements.Add(TraverseSwitchStatement(sbs, ref exitPoints));
                retMethod.ExitPoints = exitPoints;
            }
            foreach (CatchPartSyntax cps in catchStmm)
            {
                int exitPoints = retMethod.ExitPoints;
                retMethod.Decisions.Catches.Add(TraverseCatchStatement(cps, ref exitPoints));
                retMethod.ExitPoints = exitPoints;
            }

            foreach (LocalDeclarationStatementSyntax vds in accessVarDefs)
            {
                Method tempMethod = TraverseVarDecls(vds);
                retMethod.AccessedVariables.AddRange(tempMethod.AccessedVariables);
                retMethod.InvokedMethods.AddRange(tempMethod.InvokedMethods);
            }

            foreach (AssignmentStatementSyntax vns in accessVars)
            {
                Method tempMethod = TraverseAccessVars(vns);

                retMethod.AccessedVariables.AddRange(tempMethod.AccessedVariables);
                retMethod.InvokedMethods.AddRange(tempMethod.InvokedMethods);
            }

            foreach (LabelStatementSyntax lss in labelStms)
            {
                retMethod.LabelStatements.Add(TraverseLabel(lss));
            }

            foreach (GoToStatementSyntax gtss in gotoStms)
            {
                retMethod.GoToStatements.Add(TraverseGoTo(retMethod.LabelStatements, gtss));
            }

            foreach (CallStatementSyntax mss in invokedMethods)
            {
                retMethod.InvokedMethods.Add(TraverseInvokedMethod(mss));
            }

            foreach (InvocationExpressionSyntax ies in invokedMethods2)
            {
                retMethod.InvokedMethods.Add(TraverseInvokedMethod(ies));
            }

            return retMethod;
        }
Esempio n. 6
0
        private Method TraverseReturnStatement(ReturnStatementSyntax rss)
        {
            Method retMethod = new Method();

            foreach (SyntaxNode sn in rss.ChildNodes())
            {
                if (sn is CallStatementSyntax)
                {
                    retMethod.InvokedMethods.Add(TraverseInvokedMethod(sn as CallStatementSyntax));
                }
                else if (sn is InvocationExpressionSyntax)
                {
                    retMethod.InvokedMethods.Add(TraverseInvokedMethod(sn as InvocationExpressionSyntax));
                }
                else if (sn is LocalDeclarationStatementSyntax)
                {
                    Method tempMethod = TraverseVarDecls(sn as LocalDeclarationStatementSyntax);
                    retMethod.AccessedVariables.AddRange(tempMethod.AccessedVariables);
                    retMethod.InvokedMethods.AddRange(tempMethod.InvokedMethods);
                }
                else if (sn is AssignmentStatementSyntax)
                {
                    Method tempMethod = TraverseAccessVars(sn as AssignmentStatementSyntax);

                    retMethod.AccessedVariables.AddRange(tempMethod.AccessedVariables);
                    retMethod.InvokedMethods.AddRange(tempMethod.InvokedMethods);
                }
            }

            return retMethod;
        }
        private Method TraverseVarDeclarators(VariableDeclaratorSyntax vds)
        {
            Method retMethod = new Method();
            Variables retVar = new Variables();

            if (vds.HasLeadingTrivia)
            {
                SetOuterComments(retVar, vds.GetLeadingTrivia().ToFullString());
            }

            if (vds.HasTrailingTrivia)
            {
                SetInnerComments(retVar, vds.GetTrailingTrivia().ToFullString());
            }

            retVar.Name = vds.Identifier.ValueText;
            Model.Type retType = new Model.Type();
            retType.IsKnownType = SyntaxFacts.IsKeywordKind(vds.CSharpKind());
            retType.IsNotUserDefined = SyntaxFacts.IsKeywordKind(vds.CSharpKind());
            retVar.Type = retType;
            retMethod.AccessedVariables.Add(retVar);
            var valueClauses = from aValueClase in vds.ChildNodes().OfType<EqualsValueClauseSyntax>() select aValueClase;
            foreach (EqualsValueClauseSyntax evcs in valueClauses)
            {
                retMethod.AccessedVariables.AddRange(TraverseEqualsClause(evcs).AccessedVariables);
            }
            //TODO
            //Don't know if I need more stuff here
            //or even if i can fetch it from vds
            return retMethod;
        }
        private Method TransverseAccessVars(LocalDeclarationStatementSyntax ldss)
        {
            Method retMethod = new Method();

            if (ldss.HasLeadingTrivia)
            {
                SetOuterComments(retMethod, ldss.GetLeadingTrivia().ToFullString());
            }

            if (ldss.HasTrailingTrivia)
            {
                SetInnerComments(retMethod, ldss.GetTrailingTrivia().ToFullString());
            }

            List<Encapsulation> accessability = new List<Encapsulation>();
            List<Qualifiers> qualifiers = new List<Qualifiers>();
            foreach (SyntaxToken st in ldss.Modifiers)
            {
                string modifier = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(st.ValueText);
                Encapsulation encap;
                Qualifiers qual;
                if (System.Enum.TryParse<Encapsulation>(modifier, out encap))
                {
                    accessability.Add(encap);
                }
                else if (System.Enum.TryParse<Qualifiers>(modifier, out qual))
                {
                    qualifiers.Add(qual);
                }
            }
            retMethod.Qualifiers.AddRange(qualifiers);
            retMethod.Encapsulation.AddRange(accessability);
            VariableDeclarationSyntax varDecl = ldss.Declaration;
            Model.Type tempType = new Model.Type();
            if(varDecl.Type is PredefinedTypeSyntax)
            {
                tempType.Name = varDecl.Type.ToString();
                tempType.IsKnownType = true;
                tempType.IsNotUserDefined = true;
            }
            var vars = from aVar in varDecl.ChildNodes().OfType<VariableDeclaratorSyntax>() select aVar;
            foreach (VariableDeclaratorSyntax vds in vars)
            {
                //Variables retVar = new Variables();
                Method tempMethod = TraverseVarDeclarators(vds);
                foreach (Variables vrs in tempMethod.AccessedVariables)
                {
                    vrs.Type = tempType;
                }
                retMethod.AccessedVariables.AddRange(tempMethod.AccessedVariables);
                if (vds.Initializer != null)
                {
                    var castStatements = from aCastStatement in vds.Initializer.Value.ChildNodes().OfType<CastExpressionSyntax>() select aCastStatement;
                    foreach (CastExpressionSyntax ces in castStatements)
                    {
                        Method retCast = TraverseCastExpressions(ces);
                        retMethod.AccessedVariables.AddRange(retCast.AccessedVariables);
                        retMethod.InvokedMethods.AddRange(retCast.InvokedMethods);
                    }
                }
            }

            return retMethod;
        }
        private Method TraverseInvocationExpression(InvocationExpressionSyntax ies)
        {
            //TODO
            //get method name and accessed variables
            //and attributes and qualifiers
            Method retIm = new Method();

            if (ies.HasLeadingTrivia)
            {
                SetOuterComments(retIm, ies.GetLeadingTrivia().ToFullString());
            }

            if (ies.HasTrailingTrivia)
            {
                SetInnerComments(retIm, ies.GetTrailingTrivia().ToFullString());
            }
            //havent tested this with extra stuff like setting the variable equal to the method call
            //or with variables in the method call
            var methods = from aMethod in ies.ChildNodes().OfType<IdentifierNameSyntax>() select aMethod;
            foreach (IdentifierNameSyntax ins in methods)
            {
                InvokedMethod tempMethod = new InvokedMethod();
                tempMethod.Name = ins.Identifier.ValueText;
                retIm.InvokedMethods.Add(tempMethod);
            }
            //var args = from aArg in ies.ArgumentList.Arguments.OfType<ArgumentSyntax>() select aArg;
            //foreach (ArgumentSyntax asyn in args)
            //{
            //    Variables tempVar = new Variables();

            //}
            var args = from aArg in ies.Expression.ChildNodes().OfType<IdentifierNameSyntax>() select aArg;
            foreach (IdentifierNameSyntax ins in args)
            {
                Variables tempVar = new Variables();
                tempVar.Name = ins.Identifier.ValueText;
                retIm.AccessedVariables.Add(tempVar);
            }
            retIm.Name = ies.Expression.ToString();
            return retIm;
        }
Esempio n. 10
0
        private Method TraversePrefixUnaryExpressions(PrefixUnaryExpressionSyntax pues)
        {
            Method retMethod = new Method();

            if (pues.HasLeadingTrivia)
            {
                SetOuterComments(retMethod, pues.GetLeadingTrivia().ToFullString());
            }

            if (pues.HasTrailingTrivia)
            {
                SetInnerComments(retMethod, pues.GetTrailingTrivia().ToFullString());
            }

            var vars = from aVar in pues.ChildNodes().OfType<IdentifierNameSyntax>() select aVar;
            foreach (IdentifierNameSyntax ins in vars)
            {
                Variables tempVar = new Variables();
                tempVar.Name = ins.Identifier.ValueText;
                retMethod.AccessedVariables.Add(tempVar);
            }
            return retMethod;
        }
Esempio n. 11
0
        //private Method TraverseStatementSyntax(StatementSyntax ss)
        //{
        //    Method retMethod = new Method();
        //    //TODO
        //    //Get catches for decisions
        //    if (ss is DoStatementSyntax)
        //    {
        //        DoWhileLoop dwl = TraverseDoStatements(ss as DoStatementSyntax);
        //        dwl.IsNested = true;
        //        retMethod.Decisions.DoWhileLoops.Add(dwl);
        //    }
        //    else if (ss is ExpressionStatementSyntax)
        //    {
        //        Method tempMethod = TraverseExpressionStatementSyntax(ss as ExpressionStatementSyntax);
        //        retMethod.AccessedVariables.AddRange(tempMethod.AccessedVariables);
        //        retMethod.InvokedMethods.AddRange(tempMethod.InvokedMethods);
        //    }
        //    else if (ss is ForEachStatementSyntax)
        //    {
        //        ForEachStatement fes = TraverseForEachStatements(ss as ForEachStatementSyntax);
        //        fes.IsNested = true;
        //        retMethod.Decisions.ForEachStatements.Add(fes);
        //    }
        //    else if (ss is ForStatementSyntax)
        //    {
        //        ForStatement fs = TraverseForStatements(ss as ForStatementSyntax);
        //        fs.IsNested = true;
        //        retMethod.Decisions.ForStatements.Add(fs);
        //    }
        //    else if (ss is IfStatementSyntax)
        //    {
        //        IfStatement ifstm = TraverseIfStatements(ss as IfStatementSyntax);
        //        ifstm.IsNested = true;
        //        retMethod.Decisions.IfStatements.Add(ifstm);
        //    }
        //    else if (ss is LocalDeclarationStatementSyntax)
        //    {
        //        Model.Type tempType = new Model.Type();
        //        LocalDeclarationStatementSyntax ldss = ss as LocalDeclarationStatementSyntax;
        //        if (ldss.Declaration != null)
        //        {
        //            VariableDeclarationSyntax vds = ldss.Declaration;
        //            tempType.Name = vds.Type.ToString();
        //            tempType.IsKnownType = true;
        //            tempType.IsNotUserDefined = true;
        //        }
        //        Method tempMethod = TransverseAccessVars(ss as LocalDeclarationStatementSyntax);
        //        //NOT SURE if this will work but here goes
        //        tempMethod.AccessedVariables[0].Type = tempType;
        //        retMethod.AccessedVariables.AddRange(tempMethod.AccessedVariables);
        //        retMethod.InvokedMethods.AddRange(tempMethod.InvokedMethods);
        //    }
        //    else if (ss is SwitchStatementSyntax)
        //    {
        //        SwitchStatement switchStm = TraverseSwitchStatements(ss as SwitchStatementSyntax);
        //        switchStm.IsNested = true;
        //        retMethod.Decisions.SwitchStatements.Add(switchStm);
        //    }
        //    else if (ss is WhileStatementSyntax)
        //    {
        //        WhileLoop wl = TraverseWhileLoops(ss as WhileStatementSyntax);
        //        wl.IsNested = true;
        //        retMethod.Decisions.WhileLoops.Add(wl);
        //    }
        //    return retMethod;
        //}
        private Method TraverseExpressionStatementSyntax(ExpressionStatementSyntax ess)
        {
            Method retMethod = new Method();

            if (ess.HasLeadingTrivia)
            {
                SetOuterComments(retMethod, ess.GetLeadingTrivia().ToFullString());
            }

            if (ess.HasTrailingTrivia)
            {
                SetInnerComments(retMethod, ess.GetTrailingTrivia().ToFullString());
            }

            var vars = from aVar in ess.ChildNodes().OfType<BinaryExpressionSyntax>() select aVar;
            foreach (BinaryExpressionSyntax bes in vars)
            {
                Method tempMethod = TraverseBinaryExpression(bes);
                retMethod.AccessedVariables.AddRange(tempMethod.AccessedVariables);
                retMethod.InvokedMethods.AddRange(tempMethod.InvokedMethods);
            }
            var invokedMethods = from aInvokedMethod in ess.ChildNodes().OfType<InvocationExpressionSyntax>() select aInvokedMethod;
            foreach (InvocationExpressionSyntax ies in invokedMethods)
            {
                Method tempMethod = TraverseInvocationExpression(ies);
                retMethod.InvokedMethods.AddRange(tempMethod.InvokedMethods);
                retMethod.AccessedVariables.AddRange(tempMethod.AccessedVariables);
            }
            var postfixUnaryExpressions = from aPostfixUnaryExpression in ess.ChildNodes().OfType<PostfixUnaryExpressionSyntax>() select aPostfixUnaryExpression;
            foreach (PostfixUnaryExpressionSyntax pues in postfixUnaryExpressions)
            {
                Method tempMethod = TraversePostfixUnaryExpressions(pues);
                retMethod.AccessedVariables.AddRange(tempMethod.AccessedVariables);
                retMethod.InvokedMethods.AddRange(tempMethod.InvokedMethods);
            }
            var prefixUnaryExpressions = from aPrefixUnaryExpressions in ess.ChildNodes().OfType<PrefixUnaryExpressionSyntax>() select aPrefixUnaryExpressions;
            foreach (PrefixUnaryExpressionSyntax pues in prefixUnaryExpressions)
            {
                Method tempMethod = TraversePrefixUnaryExpressions(pues);
                retMethod.AccessedVariables.AddRange(tempMethod.AccessedVariables);
                retMethod.InvokedMethods.AddRange(tempMethod.InvokedMethods);
            }
            return retMethod;
        }
Esempio n. 12
0
        private Method TraverseEqualsClause(EqualsValueClauseSyntax evcs)
        {
            Method retMethod = new Method();

            if (evcs.HasLeadingTrivia)
            {
                SetOuterComments(retMethod, evcs.GetLeadingTrivia().ToFullString());
            }

            if (evcs.HasTrailingTrivia)
            {
                SetInnerComments(retMethod, evcs.GetTrailingTrivia().ToFullString());
            }

            var binaryExprs = from aBinaryExpr in evcs.ChildNodes().OfType<BinaryExpressionSyntax>() select aBinaryExpr;
            foreach(BinaryExpressionSyntax bes in binaryExprs)
            {
                Method tempMethod = TraverseBinaryExpression(bes);
                retMethod.AccessedVariables.AddRange(tempMethod.AccessedVariables);
                retMethod.InvokedMethods.AddRange(tempMethod.InvokedMethods);
            }
            var castExprs = from aCastExpr in evcs.ChildNodes().OfType<CastExpressionSyntax>() select aCastExpr;
            foreach (CastExpressionSyntax ces in castExprs)
            {
                Method tempMethod = TraverseCastExpressions(ces);
                retMethod.AccessedVariables.AddRange(tempMethod.AccessedVariables);
                retMethod.InvokedMethods.AddRange(tempMethod.InvokedMethods);
            }
            return retMethod;
        }
Esempio n. 13
0
        private Method TraverseCastExpressions(CastExpressionSyntax ces)
        {
            Method retMethod = new Method();

            if (ces.HasLeadingTrivia)
            {
                SetOuterComments(retMethod, ces.GetLeadingTrivia().ToFullString());
            }

            if (ces.HasTrailingTrivia)
            {
                SetInnerComments(retMethod, ces.GetTrailingTrivia().ToFullString());
            }

            var variables = from aVariable in ces.ChildNodes().OfType<IdentifierNameSyntax>() select aVariable;
            Model.Type type = new Model.Type();
            type.Name = ces.Type.ToString();
            type.IsKnownType = SyntaxFacts.IsKeywordKind(ces.Type.CSharpKind());
            type.IsNotUserDefined = SyntaxFacts.IsKeywordKind(ces.Type.CSharpKind());
            foreach (IdentifierNameSyntax ins in variables)
            {
                //TODO put a bp here and test if this adds method names (bad) or just var names(good)
                Variables vars = new Variables();
                vars.Name = ins.Identifier.ValueText;
                vars.IsReferenced = true;
                vars.Type = type;
                retMethod.AccessedVariables.Add(vars);
            }
            var binaryExprs = from aBinaryExpr in ces.ChildNodes().OfType<BinaryExpressionSyntax>() select aBinaryExpr;
            foreach (BinaryExpressionSyntax bes in binaryExprs)
            {
                Method retMethod2 = TraverseBinaryExpression(bes);
                retMethod.AccessedVariables.AddRange(retMethod2.AccessedVariables);
                retMethod.InvokedMethods.AddRange(retMethod2.InvokedMethods);
            }
            var invokedMethods = from aInvokedMethod in ces.ChildNodes().OfType<InvocationExpressionSyntax>() select aInvokedMethod;
            foreach (InvocationExpressionSyntax ies in invokedMethods)
            {
                Method tempMethod = TraverseInvocationExpression(ies);
                retMethod.InvokedMethods.AddRange(tempMethod.InvokedMethods);
                retMethod.AccessedVariables.AddRange(tempMethod.AccessedVariables);
            }
            var castExprs = from aCastExpr in ces.ChildNodes().OfType<CastExpressionSyntax>() select aCastExpr;
            foreach (CastExpressionSyntax ces2 in castExprs)
            {
                Method retMethod3 = TraverseCastExpressions(ces2);
                retMethod.AccessedVariables.AddRange(retMethod3.AccessedVariables);
                retMethod.InvokedMethods.AddRange(retMethod3.InvokedMethods);
            }
            return retMethod;
        }
Esempio n. 14
0
        private Method TraverseBinaryExpression(BinaryExpressionSyntax bes)
        {
            var variables = from aVariable in bes.ChildNodes().OfType<IdentifierNameSyntax>() select aVariable;
            Method retMethod = new Method();

            if (bes.HasLeadingTrivia)
            {
                SetOuterComments(retMethod, bes.GetLeadingTrivia().ToFullString());
            }

            if (bes.HasTrailingTrivia)
            {
                SetInnerComments(retMethod, bes.GetTrailingTrivia().ToFullString());
            }

            //Casting on the back end....ex:
            // abc = def as double ------- def as double is the binary expression
            if (bes.OperatorToken.IsKind(SyntaxKind.AsKeyword))
            {
                if (bes.Left is IdentifierNameSyntax)
                {
                    IdentifierNameSyntax ins = bes.Left as IdentifierNameSyntax;
                    Variables tempVar = new Variables();
                    tempVar.Name = ins.Identifier.ValueText;
                    if (bes.Right is PredefinedTypeSyntax)
                    {
                        PredefinedTypeSyntax pts = bes.Right as PredefinedTypeSyntax;
                        Model.Type tempType = new Model.Type();
                        tempType.Name = pts.ToString();
                        tempType.IsKnownType = true;
                        tempType.IsNotUserDefined = true;
                        tempVar.Type = tempType;
                    }
                    retMethod.AccessedVariables.Add(tempVar);
                }
                else if (bes.Left is MemberAccessExpressionSyntax)
                {
                    MemberAccessExpressionSyntax maes = bes.Left as MemberAccessExpressionSyntax;
                    Variables tempVar = new Variables();
                    tempVar.Name = maes.ToString();
                    tempVar.IsReferenced = true;
                    retMethod.AccessedVariables.Add(tempVar);
                }
            }
            else
            {
                foreach (IdentifierNameSyntax ins in variables)
                {
                    //TODO put a bp here and test if this adds method names (bad) or just var names(good)
                    Variables vars = new Variables();
                    vars.Name = ins.Identifier.ValueText;
                    vars.IsReferenced = true;
                    retMethod.AccessedVariables.Add(vars);
                    //TODO variable types
                }
                var binaryExprs = from aBinaryExpr in bes.ChildNodes().OfType<BinaryExpressionSyntax>() select aBinaryExpr;
                foreach (BinaryExpressionSyntax bes2 in binaryExprs)
                {
                    Method retMethod2 = TraverseBinaryExpression(bes2);
                    retMethod.AccessedVariables.AddRange(retMethod2.AccessedVariables);
                    retMethod.InvokedMethods.AddRange(retMethod2.InvokedMethods);
                }
                var invokedMethods = from aInvokedMethod in bes.ChildNodes().OfType<InvocationExpressionSyntax>() select aInvokedMethod;
                foreach (InvocationExpressionSyntax ies in invokedMethods)
                {
                    Method tempMethod = TraverseInvocationExpression(ies);
                    retMethod.InvokedMethods.AddRange(tempMethod.InvokedMethods);
                    retMethod.AccessedVariables.AddRange(tempMethod.AccessedVariables);
                }
                var castExprs = from aCastExpr in bes.ChildNodes().OfType<CastExpressionSyntax>() select aCastExpr;
                foreach (CastExpressionSyntax ces in castExprs)
                {
                    Method retMethod3 = TraverseCastExpressions(ces);
                    retMethod.AccessedVariables.AddRange(retMethod3.AccessedVariables);
                    retMethod.InvokedMethods.AddRange(retMethod3.InvokedMethods);
                }
            }
            return retMethod;
        }
Esempio n. 15
0
        //private object TransverseClassTypes(object classType)
        //{
        //    object retObj;
        //    if (classType is ClassDeclarationSyntax)
        //    {
        //        retObj = new Class();
        //        classType = classType as ClassDeclarationSyntax;
        //    }
        //    else if (classType is StructDeclarationSyntax)
        //    {
        //        retObj = new Struct();
        //        classType = classType as StructDeclarationSyntax;
        //    }
        //        //Class retObj = new Class();
        //        //Name
        //        (retObj is Class ? retObj as Class : retObj as Struct).Name = (classType is ClassDeclarationSyntax ? (ClassDeclarationSyntax)classType : (StructDeclarationSyntax)classType).Identifier.ValueText;
        //        //encapsulation
        //        foreach (SyntaxToken st in classType.Modifiers)
        //        {
        //            string modifier = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(st.ValueText);
        //            retObj.Encapsulation.Add((Encapsulation)System.Enum.Parse(typeof(Encapsulation), modifier));
        //        }
        //        var enums = from aEnu in classType.ChildNodes().OfType<EnumDeclarationSyntax>() select aEnu;
        //        foreach (EnumDeclarationSyntax eds in enums)
        //        {
        //            retObj.Enums.Add(TraverseEnums(eds));
        //        }
        //        var structs = from aStruct in classType.ChildNodes().OfType<StructDeclarationSyntax>() select aStruct;
        //        foreach (StructDeclarationSyntax sds in structs)
        //        {
        //            retObj.Structs.Add(TransverseStructs(sds));
        //        }
        //        var methods = from aMethod in classType.ChildNodes().OfType<MethodDeclarationSyntax>() select aMethod;
        //        foreach (MethodDeclarationSyntax mds in methods)
        //        {
        //            retObj.Methods.Add(TransverseMethods(mds));
        //        }
        //        var fields = from aField in classType.ChildNodes().OfType<FieldDeclarationSyntax>() select aField;
        //        foreach (FieldDeclarationSyntax fds in fields)
        //        {
        //            retObj.Attributes.Add(TransverseVariables(fds));
        //        }
        //        //var properties = from aProperty in classType.ChildNodes().OfType<PropertyDeclarationSyntax>() select aProperty;
        //        //foreach (PropertyDeclarationSyntax pds in properties)
        //        //{
        //        //    //traverse attributes
        //        //}
        //        var constructors = from aConstructor in classType.ChildNodes().OfType<ConstructorDeclarationSyntax>() select aConstructor;
        //        foreach (ConstructorDeclarationSyntax cods in constructors)
        //        {
        //            retObj.Constructors.Add(TransverseConstructors(cods));
        //        }
        //        var destructors = from aDestructor in classType.ChildNodes().OfType<DestructorDeclarationSyntax>() select aDestructor;
        //        foreach (DestructorDeclarationSyntax dds in destructors)
        //        {
        //            retObj.Destructors.Add(TransverseDestructors(dds));
        //        }
        //        var classes = from aClass in classType.ChildNodes().OfType<ClassDeclarationSyntax>() select aClass;
        //        foreach (ClassDeclarationSyntax classType2 in classes)
        //        {
        //            retObj.Classes.Add(TraverseClass(classType2));
        //        }
        //        return retObj;
        //}
        private Method TransverseMethods(MethodDeclarationSyntax mds)
        {
            Method retMethod = new Method();
            //public int DecisionsCount { get; }
            //public int ExitPoints { get; set; }
            //public bool IsFriend { get; }
            //public bool IsPolymophic { get; }
            //public bool IsPublic { get; }
            //public bool IsStatic { get; }
            //public List<Preprocessor> Preprocessors { get; set; }
            retMethod.Name = mds.Identifier.ValueText;

            if (mds.HasLeadingTrivia)
            {
                SetOuterComments(retMethod, mds.GetLeadingTrivia().ToFullString());
            }

            if (mds.HasTrailingTrivia)
            {
                SetInnerComments(retMethod, mds.GetTrailingTrivia().ToFullString());
            }

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

            TypeSyntax ts = mds.ReturnType;
            Model.Type retType = new Model.Type();
            retType.Name = ts.ToString();
            retType.IsKnownType = SyntaxFacts.IsKeywordKind(ts.CSharpKind());
            retType.IsNotUserDefined = SyntaxFacts.IsKeywordKind(ts.CSharpKind());
            //TODO
            //rettype.generictype
            retMethod.ReturnType = retType;

            ParameterListSyntax pls = mds.ParameterList;
            foreach (ParameterSyntax ps in pls.Parameters)
            {
                retMethod.Parameters.Add(TraverseParamaters(ps));
            }
            BlockSyntax bs = mds.Body;
            if (bs != null)
            {
                var labelStatements = from aLabelStatement in bs.ChildNodes().OfType<LabeledStatementSyntax>() select aLabelStatement;
                foreach (LabeledStatementSyntax lss in labelStatements)
                {
                    retMethod.LabelStatements.Add(TraverseLabelStatements(lss));
                }

                var goToStatements = from aGoToStatement in bs.ChildNodes().OfType<GotoStatementSyntax>() select aGoToStatement;
                foreach (GotoStatementSyntax gtss in goToStatements)
                {
                    GoTo gt = TraverseGoToStatements(gtss);
                    retMethod.GoToStatements.Add(gt);
                }

                //Preprocessors = new List<Preprocessor>();
                //Base = new List<InvokedMethod>();
                //Decisions = new Decisions();

                var accessVarsDecl = from aAccessVarsDecl in bs.ChildNodes().OfType<LocalDeclarationStatementSyntax>() select aAccessVarsDecl;
                foreach (LocalDeclarationStatementSyntax ldss in accessVarsDecl)
                {
                    Method tempMethod = TransverseAccessVars(ldss);
                    retMethod.AccessedVariables.AddRange(tempMethod.AccessedVariables);
                    retMethod.InvokedMethods.AddRange(tempMethod.InvokedMethods);
                }

                var ifStatements = from aIfStatement in bs.ChildNodes().OfType<IfStatementSyntax>() select aIfStatement;
                foreach (IfStatementSyntax iss in ifStatements)
                {
                    int exitPoints = retMethod.ExitPoints;
                    Decisions tempDecision = AllDecisions(TraverseIfStatements(iss, ref exitPoints));
                    retMethod.Decisions.IfStatements.AddRange(tempDecision.IfStatements);
                    retMethod.Decisions.ElseStatements.AddRange(tempDecision.ElseStatements);
                    retMethod.Decisions.ForEachStatements.AddRange(tempDecision.ForEachStatements);
                    retMethod.Decisions.ForStatements.AddRange(tempDecision.ForStatements);
                    retMethod.Decisions.WhileLoops.AddRange(tempDecision.WhileLoops);
                    retMethod.Decisions.DoWhileLoops.AddRange(tempDecision.DoWhileLoops);
                    retMethod.Decisions.Catches.AddRange(tempDecision.Catches);
                    retMethod.Decisions.SwitchStatements.AddRange(tempDecision.SwitchStatements);
                    retMethod.ExitPoints = exitPoints;
                }
                var elseStatements = from aElseStatements in bs.ChildNodes().OfType<ElseClauseSyntax>() select aElseStatements;
                foreach (ElseClauseSyntax ecs in elseStatements)
                {
                    int exitPoints = retMethod.ExitPoints;
                    Decisions tempDecision = TraverseElseClauses(ecs, ref exitPoints);
                    retMethod.Decisions.IfStatements.AddRange(tempDecision.IfStatements);
                    retMethod.Decisions.ElseStatements.AddRange(tempDecision.ElseStatements);
                    retMethod.Decisions.ForEachStatements.AddRange(tempDecision.ForEachStatements);
                    retMethod.Decisions.ForStatements.AddRange(tempDecision.ForStatements);
                    retMethod.Decisions.WhileLoops.AddRange(tempDecision.WhileLoops);
                    retMethod.Decisions.DoWhileLoops.AddRange(tempDecision.DoWhileLoops);
                    retMethod.Decisions.Catches.AddRange(tempDecision.Catches);
                    retMethod.Decisions.SwitchStatements.AddRange(tempDecision.SwitchStatements);
                    retMethod.ExitPoints = exitPoints;
                }
                var whileLoops = from aWhileLoop in bs.ChildNodes().OfType<WhileStatementSyntax>() select aWhileLoop;
                foreach (WhileStatementSyntax wss in whileLoops)
                {
                    int exitPoints = retMethod.ExitPoints;
                    Decisions tempDecision = TraverseWhileLoops(wss, ref exitPoints);
                    retMethod.Decisions.IfStatements.AddRange(tempDecision.IfStatements);
                    retMethod.Decisions.ElseStatements.AddRange(tempDecision.ElseStatements);
                    retMethod.Decisions.ForEachStatements.AddRange(tempDecision.ForEachStatements);
                    retMethod.Decisions.ForStatements.AddRange(tempDecision.ForStatements);
                    retMethod.Decisions.WhileLoops.AddRange(tempDecision.WhileLoops);
                    retMethod.Decisions.DoWhileLoops.AddRange(tempDecision.DoWhileLoops);
                    retMethod.Decisions.Catches.AddRange(tempDecision.Catches);
                    retMethod.Decisions.SwitchStatements.AddRange(tempDecision.SwitchStatements);
                    retMethod.ExitPoints = exitPoints;
                }
                var doWhileLoops = from aDoWhileLoop in bs.ChildNodes().OfType<DoStatementSyntax>() select aDoWhileLoop;
                foreach (DoStatementSyntax dss in doWhileLoops)
                {
                    int exitPoints = retMethod.ExitPoints;
                    Decisions tempDecision = TraverseDoStatements(dss, ref exitPoints);
                    retMethod.Decisions.IfStatements.AddRange(tempDecision.IfStatements);
                    retMethod.Decisions.ElseStatements.AddRange(tempDecision.ElseStatements);
                    retMethod.Decisions.ForEachStatements.AddRange(tempDecision.ForEachStatements);
                    retMethod.Decisions.ForStatements.AddRange(tempDecision.ForStatements);
                    retMethod.Decisions.WhileLoops.AddRange(tempDecision.WhileLoops);
                    retMethod.Decisions.DoWhileLoops.AddRange(tempDecision.DoWhileLoops);
                    retMethod.Decisions.Catches.AddRange(tempDecision.Catches);
                    retMethod.Decisions.SwitchStatements.AddRange(tempDecision.SwitchStatements);
                    retMethod.ExitPoints = exitPoints;
                }
                var forLoops = from aForLoop in bs.ChildNodes().OfType<ForStatementSyntax>() select aForLoop;
                foreach (ForStatementSyntax fss in forLoops)
                {
                    int exitPoints = retMethod.ExitPoints;
                    Decisions tempDecision = TraverseForStatements(fss, ref exitPoints);
                    retMethod.Decisions.IfStatements.AddRange(tempDecision.IfStatements);
                    retMethod.Decisions.ElseStatements.AddRange(tempDecision.ElseStatements);
                    retMethod.Decisions.ForEachStatements.AddRange(tempDecision.ForEachStatements);
                    retMethod.Decisions.ForStatements.AddRange(tempDecision.ForStatements);
                    retMethod.Decisions.WhileLoops.AddRange(tempDecision.WhileLoops);
                    retMethod.Decisions.DoWhileLoops.AddRange(tempDecision.DoWhileLoops);
                    retMethod.Decisions.Catches.AddRange(tempDecision.Catches);
                    retMethod.Decisions.SwitchStatements.AddRange(tempDecision.SwitchStatements);
                    retMethod.ExitPoints = exitPoints;
                }
                var foreachLoops = from aForeachLoop in bs.ChildNodes().OfType<ForEachStatementSyntax>() select aForeachLoop;
                foreach (ForEachStatementSyntax fess in foreachLoops)
                {
                    int exitPoints = retMethod.ExitPoints;
                    Decisions tempDecision = TraverseForEachStatements(fess, ref exitPoints);
                    retMethod.Decisions.IfStatements.AddRange(tempDecision.IfStatements);
                    retMethod.Decisions.ElseStatements.AddRange(tempDecision.ElseStatements);
                    retMethod.Decisions.ForEachStatements.AddRange(tempDecision.ForEachStatements);
                    retMethod.Decisions.ForStatements.AddRange(tempDecision.ForStatements);
                    retMethod.Decisions.WhileLoops.AddRange(tempDecision.WhileLoops);
                    retMethod.Decisions.DoWhileLoops.AddRange(tempDecision.DoWhileLoops);
                    retMethod.Decisions.Catches.AddRange(tempDecision.Catches);
                    retMethod.Decisions.SwitchStatements.AddRange(tempDecision.SwitchStatements);
                    retMethod.ExitPoints = exitPoints;
                }
                var switches = from aSwitch in bs.ChildNodes().OfType<SwitchStatementSyntax>() select aSwitch;
                foreach (SwitchStatementSyntax sss in switches)
                {
                    int exitPoints = retMethod.ExitPoints;
                    Decisions tempDecision = TraverseSwitchStatements(sss, ref exitPoints);
                    retMethod.Decisions.IfStatements.AddRange(tempDecision.IfStatements);
                    retMethod.Decisions.ElseStatements.AddRange(tempDecision.ElseStatements);
                    retMethod.Decisions.ForEachStatements.AddRange(tempDecision.ForEachStatements);
                    retMethod.Decisions.ForStatements.AddRange(tempDecision.ForStatements);
                    retMethod.Decisions.WhileLoops.AddRange(tempDecision.WhileLoops);
                    retMethod.Decisions.DoWhileLoops.AddRange(tempDecision.DoWhileLoops);
                    retMethod.Decisions.Catches.AddRange(tempDecision.Catches);
                    retMethod.Decisions.SwitchStatements.AddRange(tempDecision.SwitchStatements);
                    retMethod.ExitPoints = exitPoints;
                }
                var catches = from aCatch in bs.ChildNodes().OfType<CatchClauseSyntax>() select aCatch;
                foreach (CatchClauseSyntax ccs in catches)
                {
                    int exitPoints = retMethod.ExitPoints;
                    Decisions tempDecision = TraverseCatchClauses(ccs, ref exitPoints);
                    retMethod.Decisions.IfStatements.AddRange(tempDecision.IfStatements);
                    retMethod.Decisions.ElseStatements.AddRange(tempDecision.ElseStatements);
                    retMethod.Decisions.ForEachStatements.AddRange(tempDecision.ForEachStatements);
                    retMethod.Decisions.ForStatements.AddRange(tempDecision.ForStatements);
                    retMethod.Decisions.WhileLoops.AddRange(tempDecision.WhileLoops);
                    retMethod.Decisions.DoWhileLoops.AddRange(tempDecision.DoWhileLoops);
                    retMethod.Decisions.Catches.AddRange(tempDecision.Catches);
                    retMethod.Decisions.SwitchStatements.AddRange(tempDecision.SwitchStatements);
                    retMethod.ExitPoints = exitPoints;
                }
                var breaks = from aBreak in bs.ChildNodes().OfType<BreakStatementSyntax>() select aBreak;
                foreach (BreakStatementSyntax bss in breaks)
                {
                    //TODO get breaks
                    //note that breaks are NOT in retMethod.Decisions
                }
                var checks = from aCheck in bs.ChildNodes().OfType<CheckedStatementSyntax>() select aCheck;
                foreach (CheckedStatementSyntax css in checks)
                {
                    //TODO get checks
                    //note that checks are NOT in retMethod.Decisions
                }
                var continues = from aContinue in bs.ChildNodes().OfType<ContinueStatementSyntax>() select aContinue;
                foreach (ContinueStatementSyntax css in continues)
                {
                    //TODO get continues
                    //note that continues are NOT in retMethod.Decisions
                }
                var emptys = from aEmpty in bs.ChildNodes().OfType<EmptyStatementSyntax>() select aEmpty;
                foreach (EmptyStatementSyntax ess in emptys)
                {
                    //TODO get emptys
                    //note that emptys are NOT in retMethod.Decisions
                }
                var exprs = from aExpr in bs.ChildNodes().OfType<ExpressionStatementSyntax>() select aExpr;
                foreach (ExpressionStatementSyntax ess in exprs)
                {
                    //TODO get expressions
                    //note that expressions are NOT in retMethod.Decisions
                }
                var fixeds = from aFixed in bs.ChildNodes().OfType<FixedStatementSyntax>() select aFixed;
                foreach (FixedStatementSyntax fss in fixeds)
                {
                    //TODO get fixed
                    //note that these are NOT in retMethod.Decisions
                }
                var locks = from aLock in bs.ChildNodes().OfType<LockStatementSyntax>() select aLock;
                foreach (LockStatementSyntax lss in locks)
                {
                    //TODO get lock
                    //note that these are NOT in retMethod.Decisions
                }
                var returns = from aReturn in bs.ChildNodes().OfType<ReturnStatementSyntax>() select aReturn;
                foreach (ReturnStatementSyntax rss in returns)
                {
                    retMethod.ExitPoints++;
                }
                var throws = from aThrow in bs.ChildNodes().OfType<ThrowStatementSyntax>() select aThrow;
                foreach (ThrowStatementSyntax tss in throws)
                {
                    //TODO get throws
                    //note that these are NOT in retMethod.Decisions
                }
                var trys = from aTry in bs.ChildNodes().OfType<TryStatementSyntax>() select aTry;
                foreach (TryStatementSyntax tss in trys)
                {
                    //TODO get trys
                    //note that these are NOT in retMethod.Decisions
                }
                var unsafes = from aUnsafe in bs.ChildNodes().OfType<UnsafeStatementSyntax>() select aUnsafe;
                foreach (UnsafeStatementSyntax uss in unsafes)
                {
                    //TODO get unsafes
                    //note that these are NOT in retMethod.Decisions
                }
                var usings = from aUsing in bs.ChildNodes().OfType<UsingStatementSyntax>() select aUsing;
                foreach (UsingStatementSyntax uss in usings)
                {
                    //TODO get usings
                    //note that these are NOT in retMethod.Decisions
                }
                var yields = from aYield in bs.ChildNodes().OfType<YieldStatementSyntax>() select aYield;
                foreach (YieldStatementSyntax yss in yields)
                {
                    //TODO get yields
                    //note that these are NOT in retMethod.Decisions
                }
                var invokedMethods = from aInvokedMethod in bs.ChildNodes().OfType<InvocationExpressionSyntax>() select aInvokedMethod;
                foreach (InvocationExpressionSyntax ies in invokedMethods)
                {
                    Method tempMethod = TraverseInvocationExpression(ies);
                    retMethod.InvokedMethods.AddRange(tempMethod.InvokedMethods);
                    retMethod.AccessedVariables.AddRange(tempMethod.AccessedVariables);
                }

                //InvokedMethods = new List<InvokedMethod>();
            }
            return retMethod;
        }