private IEnumerable <CodeActionOperation> CreateAddDocumentAndUpdateUsingsOrImportsOperations( Project projectToBeUpdated, Project triggeringProject, string documentName, SyntaxNode root, Document generatingDocument, string includeUsingsOrImports, IList <string> containers, SourceCodeKind sourceCodeKind, CancellationToken cancellationToken) { // TODO(cyrusn): make sure documentId is unique. var documentId = DocumentId.CreateNewId(projectToBeUpdated.Id, documentName); var updatedSolution = projectToBeUpdated.Solution.AddDocument(DocumentInfo.Create( documentId, documentName, containers, sourceCodeKind)); updatedSolution = updatedSolution.WithDocumentSyntaxRoot(documentId, root, PreservationMode.PreserveIdentity); // Update the Generating Document with a using if required if (includeUsingsOrImports != null) { updatedSolution = _service.TryAddUsingsOrImportToDocument(updatedSolution, null, _document.Document, _state.SimpleName, includeUsingsOrImports, cancellationToken); } // Add reference of the updated project to the triggering Project if they are 2 different projects updatedSolution = AddProjectReference(projectToBeUpdated, triggeringProject, updatedSolution); return(new CodeActionOperation[] { new ApplyChangesOperation(updatedSolution), new OpenDocumentOperation(documentId) }); }