Beispiel #1
0
 private static void HandleDeclarations(MethodDeclarationSyntax method)
 {
     var declarations = method.DescendentNodes().OfType<VariableDeclarationSyntax>();
     foreach (var declaration in declarations)
     {
         Console.WriteLine("\t\t\td: " + declaration.Type.PlainName);
     }
 }
Beispiel #2
0
 private static void HandleConstructorInvocations(ISemanticModel sema, MethodDeclarationSyntax method)
 {
     var ctors = method.DescendentNodes().OfType<ObjectCreationExpressionSyntax>();
     foreach (var ctor in ctors)
     {
         var ctorSymbols = sema.GetSemanticInfo(ctor);
         Console.WriteLine("\t\t\tc: " + ctorSymbols.Symbol.ContainingType.Name);
     }
 }
Beispiel #3
0
 private static void HandleConditions(MethodDeclarationSyntax method)
 {
     int cc = 1;
     var ifs = method.DescendentNodes().OfType<IfStatementSyntax>();
     foreach (var cond in ifs)
     {
         var bins = cond.Condition.DescendentNodesAndSelf().OfType<BinaryExpressionSyntax>();
         cc += 1 + bins.Count();
     }
     Console.WriteLine("\t\t\tcc: " + cc);
 }
Beispiel #4
0
 private static void HandleInvocations(ISemanticModel sema, MethodDeclarationSyntax method)
 {
     var invocations = method.DescendentNodes().OfType<InvocationExpressionSyntax>();
     foreach (var invocation in invocations)
     {
         var invocSymbols = sema.GetSemanticInfo(invocation);
         Console.WriteLine("\t\t\ti: " + invocSymbols.Symbol.ContainingType.Name);
     }
 }
Beispiel #5
0
 private static void HandleStatements(MethodDeclarationSyntax method)
 {
     var statements = method.DescendentNodes().OfType<StatementSyntax>();
     Console.WriteLine("\t\t\tns: " + statements.Count(s => !(s is BlockSyntax)));
 }