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


C# StatementSyntax.DescendantNodes方法代码示例

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


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

示例1: MakeObjectInitializer

 private static Document MakeObjectInitializer(Document document, SyntaxNode root, StatementSyntax statement, ISymbol variableSymbol, SemanticModel semanticModel)
 {
     var blockParent = statement.FirstAncestorOrSelf<BlockSyntax>();
     var objectCreationExpression = statement.DescendantNodes().OfType<ObjectCreationExpressionSyntax>().Single();
     var newBlockParent = CreateNewBlockParent(statement, semanticModel, objectCreationExpression, variableSymbol);
     var newRoot = root.ReplaceNode(blockParent, newBlockParent);
     var newDocument = document.WithSyntaxRoot(newRoot);
     return newDocument;
 }
开发者ID:nikolasmagno,项目名称:code-cracker,代码行数:9,代码来源:ObjectInitializerCodeFixProvider.cs

示例2: WrapAsync

		private static async Task<Document> WrapAsync(Document document, StatementSyntax expressionStatement, CancellationToken token)
		{
			var identifierNameSyntax =
				expressionStatement.DescendantNodes().FirstOrDefault(x => x.IsKind(SyntaxKind.IdentifierName)) as
				IdentifierNameSyntax;

			if (identifierNameSyntax == null)
				return document;

			var loggerName = identifierNameSyntax.Identifier.Text;

			var expression = SyntaxFactory.ParseExpression(loggerName + ".IsDebugEnabled");
			var ifStatement = SyntaxFactory.IfStatement(expression, expressionStatement);

			var root = await document.GetSyntaxRootAsync(token);
			root = root.ReplaceNode(expressionStatement, ifStatement);

			return document.WithSyntaxRoot(root);
		}
开发者ID:ElemarJR,项目名称:raven.codeanalysis,代码行数:19,代码来源:LoggingCodeFix.cs

示例3: IsPassedAsArgument

 private static bool IsPassedAsArgument(StatementSyntax statement, SemanticModel semanticModel, ILocalSymbol identitySymbol)
 {
     if (statement == null) return false;
     var args = statement.DescendantNodes().OfKind<ArgumentSyntax>(SyntaxKind.Argument);
     foreach (var arg in args)
     {
         var argSymbol = semanticModel.GetSymbolInfo(arg.Expression).Symbol;
         if (identitySymbol.Equals(argSymbol)) return true;
     }
     return false;
 }
开发者ID:julianosaless,项目名称:code-cracker,代码行数:11,代码来源:DisposableVariableNotDisposedAnalyzer.cs


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