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


C# LocalDeclarationStatementSyntax.GetTrailingTrivia方法代码示例

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


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

示例1: TransverseAccessVars

        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;
        }
开发者ID:Zenoware,项目名称:RoslynParser,代码行数:64,代码来源:RoslynCSharpParser.cs


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