public IEnumerable <Document> GetDocuments(string filePath) { return(CurrentSolution .GetDocumentIdsWithFilePath(filePath) .Select(id => CurrentSolution.GetDocument(id)) .OfType <Document>()); }
public Document GetOrAddDocument(string filePath) { DocumentId docId = CurrentSolution.GetDocumentIdsWithFilePath(filePath).FirstOrDefault(); if (docId != null) { return(CurrentSolution.GetDocument(docId)); } if (!IsRemoteSession) { return(null); } // If the document is within the joined folder or it's a registered external file, // add it to the workspace, otherwise bail out. if (!filePath.StartsWith(_remoteRootPath) && !IsExternalLocalUri(filePath)) { return(null); } var language = GetLanguage(filePath); // Unsupported language. if (language == null) { return(null); } var folderName = Path.GetFileNameWithoutExtension(_remoteRootPath); return(AddDocumentToProject(filePath, language, folderName)); }
public void EnsureBufferUpdated(Request request) { foreach (var documentId in CurrentSolution.GetDocumentIdsWithFilePath(request.FileName)) { var buffer = Encoding.UTF8.GetBytes(request.Buffer); var sourceText = SourceText.From(new MemoryStream(buffer), encoding: Encoding.UTF8); OnDocumentChanged(documentId, sourceText); } }
public Document? GetOrAddExternalDocument(string filePath, string language) { var docId = CurrentSolution.GetDocumentIdsWithFilePath(filePath).FirstOrDefault(); if (docId != null) { return CurrentSolution.GetDocument(docId); } return AddDocumentToProject(filePath, language, ExternalProjectName); }
public DocumentId GetDocumentId(AvalonStudio.Projects.ISourceFile file) { var ids = CurrentSolution.GetDocumentIdsWithFilePath(file.Location); if (ids.Length != 1) { throw new NotImplementedException(); } return(ids.First()); }
public ITextBuffer CreateTextBuffer(string source, string filePath, string contentType) { var ct = contentTypeRegistry.GetContentType(contentType); var textBuffer = textBufferFactory.CreateTextBuffer(source, ct); var documentId = CurrentSolution.GetDocumentIdsWithFilePath(filePath).FirstOrDefault(); documentId = documentId ?? CreateDocumentId(filePath); OnDocumentOpened(documentId, textBuffer.AsTextContainer()); return(textBuffer); }
public void EnsureBufferUpdated(Request request) { if (request.Buffer == null || request.FileName == null) { return; } var sourceText = SourceText.From(request.Buffer); foreach (var documentId in CurrentSolution.GetDocumentIdsWithFilePath(request.FileName)) { OnDocumentChanged(documentId, sourceText); } }
public Document?GetOrAddDocument(string filePath) { var docId = CurrentSolution.GetDocumentIdsWithFilePath(filePath).FirstOrDefault(); if (docId != null) { return(CurrentSolution.GetDocument(docId)); } if (!IsRemoteSession) { return(null); } var language = GetLanguage(filePath); // Unsupported language. if (language == null) { return(null); } // If the document is within the joined folder or it's a registered external file, // add it to the workspace, otherwise bail out. var remoteWorkspaceRoot = GetRemoteWorkspaceRoot(filePath); var remoteExternalRoot = GetRemoteExternalRoot(filePath); if (!string.IsNullOrEmpty(remoteWorkspaceRoot)) { return(AddDocumentToProject( filePath, language, Path.GetFileName(Path.GetDirectoryName(remoteWorkspaceRoot)) )); } else if (!string.IsNullOrEmpty(remoteExternalRoot)) { return(AddDocumentToProject( filePath, language, Path.GetFileName(Path.GetDirectoryName(remoteExternalRoot)) )); } else { return(null); } }
public DocumentId GetDocumentId(string filePath) { var documentIds = CurrentSolution.GetDocumentIdsWithFilePath(filePath); return(documentIds.FirstOrDefault()); }