Exemplo n.º 1
0
        public override VisualStudioDocumentTracker Create(ITextBuffer textBuffer)
        {
            if (textBuffer == null)
            {
                throw new ArgumentNullException(nameof(textBuffer));
            }

            if (!_textDocumentFactory.TryGetTextDocument(textBuffer, out var textDocument))
            {
                Debug.Fail("Text document should be available from the text buffer.");
                return(null);
            }

            var filePath = textDocument.FilePath;
            var project  = _projectService.GetHostProject(textBuffer);

            if (project == null)
            {
                Debug.Fail("Text buffer should belong to a project.");
                return(null);
            }

            var projectPath = _projectService.GetProjectPath(project);

            var tracker = new DefaultVisualStudioDocumentTracker(_foregroundDispatcher, filePath, projectPath, _projectManager, _editorSettingsManager, _workspace, textBuffer, _importDocumentManager);

            return(tracker);
        }
        public override bool TryGetProjectPath(ITextBuffer textBuffer, out string filePath)
        {
            if (textBuffer == null)
            {
                throw new ArgumentNullException(nameof(textBuffer));
            }

            var project = _projectService.GetHostProject(textBuffer);

            if (project == null)
            {
                filePath = null;
                return(false);
            }

            filePath = _projectService.GetProjectPath(project);
            return(true);
        }
Exemplo n.º 3
0
        public override bool TryGetProjectPath(ITextBuffer textBuffer, out string filePath)
        {
            if (textBuffer is null)
            {
                throw new ArgumentNullException(nameof(textBuffer));
            }

            if (_liveShareProjectPathProvider != null &&
                _liveShareProjectPathProvider.TryGetProjectPath(textBuffer, out filePath))
            {
                return(true);
            }

            var project = _projectService.GetHostProject(textBuffer);

            if (project is null)
            {
                filePath = null;
                return(false);
            }

            filePath = _projectService.GetProjectPath(project);
            return(true);
        }