private static IDisposable AppendSection(this HierarchicalStringBuilder builder, SyntaxNode scope)
        {
            var identifiers = (scope as MemberDeclarationSyntax)?.GetIdentifiers();

            if (identifiers != null)
            {
                return(builder.AppendSection("{0}: {1}", scope.Kind(), identifiers.Join()));
            }
            else
            {
                return(builder.AppendSection("{0}", scope.Kind()));
            }
        }
示例#2
0
 private static void AppendObject(this HierarchicalStringBuilder builder, NamespaceArchNode @namespace)
 {
     using var scope = builder.AppendSection("Namespace: {0}", @namespace.Name);
     foreach (var group in @namespace.Groups)
     {
         builder.AppendObject(group);
     }
 }
示例#3
0
 private static void AppendObject(this HierarchicalStringBuilder builder, ModuleArchNode module)
 {
     using var scope = builder.AppendSection("Module: {0}", module.Name);
     foreach (var @namespace in module.Namespaces)
     {
         builder.AppendObject(@namespace);
     }
 }
 // ControlFlowGraph/BasicBlock
 private static void AppendProperty(this HierarchicalStringBuilder builder, string name, BasicBlock block)
 {
     using (builder.AppendSection("{0}: Ordinal={1}, Kind={2}, Condition={3}, IsReachable={4}", name, block.Ordinal, block.Kind, block.ConditionKind, block.IsReachable)) {
         builder.AppendProperty("Fall through successor", block.FallThroughSuccessor);
         builder.AppendProperty("Conditional successor", block.ConditionalSuccessor);
         builder.AppendProperty("Branch operation", block.BranchValue);
         foreach (var operation in block.Operations)
         {
             builder.AppendProperty("Operation", operation);
         }
     }
 }
 // ControlFlowGraph/ControlFlowRegion
 private static void AppendProperty(this HierarchicalStringBuilder builder, string name, ControlFlowRegion region)
 {
     using (builder.AppendSection("{0}: Kind={1}", name, region.Kind)) {
         builder.AppendLine("Capture ids: {0}", region.CaptureIds.Join());
         builder.AppendLine("Locals: {0}", region.Locals.Join());
         builder.AppendLine("Local functions: {0}", region.LocalFunctions.Join());
         foreach (var nestedRegion in region.NestedRegions)
         {
             builder.AppendProperty("Nested region", nestedRegion);
         }
     }
 }
 private static void AppendHierarchy(this HierarchicalStringBuilder builder, SyntaxNode scope, ImmutableArray <DependenciesAnalysis.Reference> references)
 {
     using (builder.AppendSection(scope)) {
         if (scope is StatementSyntax && scope.Parent?.Parent is MethodDeclarationSyntax)
         {
             builder.AppendText(scope.ToString());
         }
         foreach (var reference in references.Where(i => i.GetScope() == scope))
         {
             builder.AppendItem(reference);
         }
         foreach (var child in scope.ChildNodes().Where(IsScope))
         {
             // This loop enters into only direct children scopes, so it may not come to some scopes
             builder.AppendHierarchy(child, references);
         }
     }
 }