当前位置: 首页>>代码示例>>C#>>正文


C# ExpressionStatementSyntax.ChildNodes方法代码示例

本文整理汇总了C#中Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionStatementSyntax.ChildNodes方法的典型用法代码示例。如果您正苦于以下问题:C# ExpressionStatementSyntax.ChildNodes方法的具体用法?C# ExpressionStatementSyntax.ChildNodes怎么用?C# ExpressionStatementSyntax.ChildNodes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionStatementSyntax的用法示例。


在下文中一共展示了ExpressionStatementSyntax.ChildNodes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TraverseExpressionStatementSyntax

        //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);
//.........这里部分代码省略.........
开发者ID:Zenoware,项目名称:RoslynParser,代码行数:101,代码来源:RoslynCSharpParser.cs


注:本文中的Microsoft.CodeAnalysis.CSharp.Syntax.ExpressionStatementSyntax.ChildNodes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。