///<summary>Creates a new document linked to an existing text buffer.</summary> public DocumentId CreateDocument(ProjectId projectId, ITextBuffer buffer, string debugName = null) { var id = DocumentId.CreateNewId(projectId, debugName); TryApplyChanges(CurrentSolution.AddDocument(id, debugName ?? "Sample Document", TextLoader.From(buffer.AsTextContainer(), VersionStamp.Create()))); OpenDocument(id, buffer); return(id); }
DocumentId CreateDocumentId(string filePath) { var project = CurrentSolution.Projects.First(); var projectId = project.Id; var documentId = DocumentId.CreateNewId(projectId, debugName: filePath); var documentInfo = DocumentInfo.Create(documentId, filePath); var solution = CurrentSolution.AddDocument(documentInfo); SetCurrentSolution(solution); return(documentId); }
///<summary>Creates a new document linked to an existing text buffer.</summary> public DocumentId CreateDocument(ProjectId projectId, ITextBuffer buffer) { // Our GetFileName() extension (which should probably be deleted) doesn't work on projection buffers var debugName = TextBufferExtensions.GetFileName(buffer) ?? "Markdown Embedded Code"; var id = DocumentId.CreateNewId(projectId, debugName); TryApplyChanges(CurrentSolution.AddDocument( id, debugName, TextLoader.From(buffer.AsTextContainer(), VersionStamp.Create()) )); OpenDocument(id, buffer); return(id); }