public override bool TryResolvePotentialProject(string documentFilePath, out ProjectSnapshot projectSnapshot) { if (documentFilePath == null) { throw new ArgumentNullException(nameof(documentFilePath)); } _foregroundDispatcher.AssertForegroundThread(); var normalizedDocumentPath = _filePathNormalizer.Normalize(documentFilePath); var projects = _projectSnapshotManagerAccessor.Instance.Projects; for (var i = 0; i < projects.Count; i++) { if (projects[i].FilePath == _miscellaneousHostProject.FilePath) { // We don't resolve documents to belonging to the miscellaneous project. continue; } var projectDirectory = _filePathNormalizer.GetDirectory(projects[i].FilePath); if (normalizedDocumentPath.StartsWith(projectDirectory, FilePathComparison.Instance)) { projectSnapshot = projects[i]; return(true); } } projectSnapshot = null; return(false); }
public override bool TryResolveDocument(string documentFilePath, out DocumentSnapshot document) { _foregroundDispatcher.AssertForegroundThread(); var normalizedPath = _filePathNormalizer.Normalize(documentFilePath); if (!_projectResolver.TryResolvePotentialProject(normalizedPath, out var potentialProject)) { potentialProject = _projectResolver.GetMiscellaneousProject(); } if (!potentialProject.DocumentFilePaths.Contains(normalizedPath, FilePathComparer.Instance)) { var miscProject = _projectResolver.GetMiscellaneousProject(); if (!miscProject.DocumentFilePaths.Contains(normalizedPath, FilePathComparer.Instance)) { // Miscellaneous project and other tracked projects do not contain document. document = null; return(false); } potentialProject = miscProject; } document = potentialProject.GetDocument(normalizedPath); return(true); }
public override bool TryResolveDocument(string documentFilePath, out DocumentSnapshot document) { _foregroundDispatcher.AssertForegroundThread(); var normalizedPath = _filePathNormalizer.Normalize(documentFilePath); if (!_projectResolver.TryResolveProject(normalizedPath, out var project)) { // Neither the potential project determined by file path, // nor the Miscellaneous project contain the document. document = null; return(false); } document = project.GetDocument(normalizedPath); return(true); }
public override bool TryResolveProject(string documentFilePath, out ProjectSnapshot projectSnapshot, bool enforceDocumentInProject = true) { if (documentFilePath == null) { throw new ArgumentNullException(nameof(documentFilePath)); } _foregroundDispatcher.AssertForegroundThread(); var normalizedDocumentPath = _filePathNormalizer.Normalize(documentFilePath); var projects = _projectSnapshotManagerAccessor.Instance.Projects; for (var i = 0; i < projects.Count; i++) { projectSnapshot = projects[i]; if (projectSnapshot.FilePath == _miscellaneousHostProject.FilePath) { if (enforceDocumentInProject && IsDocumentInProject(projectSnapshot, documentFilePath)) { return(true); } continue; } var projectDirectory = _filePathNormalizer.GetDirectory(projectSnapshot.FilePath); if (normalizedDocumentPath.StartsWith(projectDirectory, FilePathComparison.Instance) && (!enforceDocumentInProject || IsDocumentInProject(projectSnapshot, documentFilePath))) { return(true); } } projectSnapshot = null; return(false);