public void TryPromoteMiscellaneousDocumentsToProject(Project project)
        {
            if (project == null)
            {
                throw new ArgumentNullException(nameof(project));
            }

            var miscProjectInfos = miscDocumentsProjectInfos.Values.ToArray();

            for (var i = 0; i < miscProjectInfos.Length; i++)
            {
                var miscProject = CurrentSolution.GetProject(miscProjectInfos[i].Id);
                var documents   = miscProject.Documents.ToArray();

                for (var j = 0; j < documents.Length; j++)
                {
                    var document = documents[j];
                    if (FileBelongsToProject(document.FilePath, project))
                    {
                        var textLoader   = new DelegatingTextLoader(document);
                        var documentId   = DocumentId.CreateNewId(project.Id);
                        var documentInfo = DocumentInfo.Create(
                            documentId,
                            document.FilePath,
                            filePath: document.FilePath,
                            loader: textLoader);

                        // This transitively will remove the document from the misc project.
                        AddDocument(documentInfo);
                    }
                }
            }
        }
        // Internal for testing
        internal void TryUpdateViewImportDependencies(string documentFilePath, ProjectSnapshot project)
        {
            // Upon the completion of https://github.com/aspnet/Razor/issues/2633 this will no longer be necessary.

            if (!documentFilePath.EndsWith("_ViewImports.cshtml", StringComparison.Ordinal))
            {
                return;
            }

            // Adding a _ViewImports, need to refresh all open documents.
            var importAddedFilePath    = documentFilePath;
            var documentsToBeRefreshed = new List <DefaultDocumentSnapshot>();

            foreach (var filePath in project.DocumentFilePaths)
            {
                if (string.Equals(filePath, importAddedFilePath, StringComparison.Ordinal))
                {
                    continue;
                }

                if (_projectSnapshotManagerAccessor.Instance.IsDocumentOpen(filePath))
                {
                    var document = (DefaultDocumentSnapshot)project.GetDocument(filePath);

                    // This document cares about the import
                    documentsToBeRefreshed.Add(document);
                }
            }

            foreach (var document in documentsToBeRefreshed)
            {
                var delegatingTextLoader = new DelegatingTextLoader(document);
                _projectSnapshotManagerAccessor.Instance.DocumentChanged(project.FilePath, document.FilePath, delegatingTextLoader);
            }
        }