public static ImmutableArray<SemanticModelInfo> Build(SyntaxTree tree)
            {
                var visitor = new ModelBuilder();
                visitor.builder = ArrayBuilder<SemanticModelInfo>.GetInstance();

                // Collect nodes of interest.
                visitor.Visit(tree.GetRoot());

                // Populate local scopes with local declarations
                foreach (var info in visitor.builder.Reverse())
                {
                    switch (info.Node.Kind)
                    {
                        case SyntaxKind.VariableDeclarator:
                            info.DeclScope.AddDeclaration(((VariableDeclaratorSyntax)info.Node).Identifier.ValueText, info);
                            break;

                        case SyntaxKind.CatchDeclaration:
                            info.DeclScope.AddDeclaration(((CatchDeclarationSyntax)info.Node).Identifier.ValueText, info);
                            break;

                        case SyntaxKind.ForEachStatement:
                            info.DeclScope.AddDeclaration(((ForEachStatementSyntax)info.Node).Identifier.ValueText, info);
                            break;

                        case SyntaxKind.Parameter:
                            info.DeclScope.AddDeclaration(((ParameterSyntax)info.Node).Identifier.ValueText, info);
                            break;

                        case SyntaxKind.IdentifierName:
                            break;

                        default:
                            throw new NotImplementedException();
                    }
                }

                // "Bind" identifiers
                foreach (var info in visitor.builder)
                {
                    if (info.Node.Kind == SyntaxKind.IdentifierName && info.DeclScope != null)
                    {
                        info.LocalOrParameterDeclaration = info.DeclScope.Bind(((IdentifierNameSyntax)info.Node).Identifier.ValueText);

                        if (info.LocalOrParameterDeclaration != null)
                        {
                            info.LocalOrParameterDeclaration.HasReferences = true;
                        }
                    }
                }

                return visitor.builder.ToImmutableAndFree(); 
            }