// DependenciesAnalysis
        public static string GetDisplayString(SyntaxNode syntax, DependenciesAnalysis analysis)
        {
            var builder = new HierarchicalStringBuilder();

            using (builder.AppendTitle("Dependencies analysis:")) {
                builder.AppendHierarchy(syntax, analysis.References);
            }
            return(builder.ToString());
        }
 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);
         }
     }
 }