public DefaultVisualStudioDocumentTrackerFactory(
            TextBufferProjectService projectService,
            ITextDocumentFactoryService textDocumentFactory,
            VisualStudioWorkspaceAccessor workspaceAccessor,
            ImportDocumentManager importDocumentManager)
        {
            if (projectService == null)
            {
                throw new ArgumentNullException(nameof(projectService));
            }

            if (textDocumentFactory == null)
            {
                throw new ArgumentNullException(nameof(textDocumentFactory));
            }

            if (workspaceAccessor == null)
            {
                throw new ArgumentNullException(nameof(workspaceAccessor));
            }

            _projectService        = projectService;
            _textDocumentFactory   = textDocumentFactory;
            _workspace             = workspaceAccessor.Workspace;
            _importDocumentManager = importDocumentManager;

            _foregroundDispatcher = _workspace.Services.GetRequiredService <ForegroundDispatcher>();
            var razorLanguageServices = _workspace.Services.GetLanguageServices(RazorLanguage.Name);

            _projectManager        = razorLanguageServices.GetRequiredService <ProjectSnapshotManager>();
            _editorSettingsManager = razorLanguageServices.GetRequiredService <EditorSettingsManagerInternal>();
        }
예제 #2
0
        public DefaultVisualStudioDocumentTracker(
            ProjectSnapshotManager projectManager,
            TextBufferProjectService projectService,
            Workspace workspace,
            ITextBuffer textBuffer)
        {
            if (projectManager == null)
            {
                throw new ArgumentNullException(nameof(projectManager));
            }

            if (projectService == null)
            {
                throw new ArgumentNullException(nameof(projectService));
            }

            if (workspace == null)
            {
                throw new ArgumentNullException(nameof(workspace));
            }

            if (textBuffer == null)
            {
                throw new ArgumentNullException(nameof(textBuffer));
            }

            _projectManager = projectManager;
            _projectService = projectService;
            _textBuffer     = textBuffer;
            _workspace      = workspace; // For now we assume that the workspace is the always default VS workspace.

            _textViews = new List <ITextView>();
        }
예제 #3
0
        // This is only for testing. We want to avoid using the actual Roslyn GetService methods in unit tests.
        internal DefaultVisualStudioDocumentTrackerFactory(
            ForegroundDispatcher foregroundDispatcher,
            ProjectSnapshotManager projectManager,
            TextBufferProjectService projectService,
            [Import(typeof(VisualStudioWorkspace))] Workspace workspace)
        {
            if (foregroundDispatcher == null)
            {
                throw new ArgumentNullException(nameof(foregroundDispatcher));
            }

            if (projectManager == null)
            {
                throw new ArgumentNullException(nameof(projectManager));
            }

            if (projectService == null)
            {
                throw new ArgumentNullException(nameof(projectService));
            }

            if (workspace == null)
            {
                throw new ArgumentNullException(nameof(workspace));
            }

            _foregroundDispatcher = foregroundDispatcher;
            _projectManager       = projectManager;
            _projectService       = projectService;
            _workspace            = workspace;
        }
예제 #4
0
        public DefaultVisualStudioDocumentTracker(
            string filePath,
            ProjectSnapshotManager projectManager,
            TextBufferProjectService projectService,
            EditorSettingsManager editorSettingsManager,
            Workspace workspace,
            ITextBuffer textBuffer)
        {
            if (string.IsNullOrEmpty(filePath))
            {
                throw new ArgumentException(Resources.ArgumentCannotBeNullOrEmpty, nameof(filePath));
            }

            if (projectManager == null)
            {
                throw new ArgumentNullException(nameof(projectManager));
            }

            if (projectService == null)
            {
                throw new ArgumentNullException(nameof(projectService));
            }

            if (editorSettingsManager == null)
            {
                throw new ArgumentNullException(nameof(editorSettingsManager));
            }

            if (workspace == null)
            {
                throw new ArgumentNullException(nameof(workspace));
            }

            if (textBuffer == null)
            {
                throw new ArgumentNullException(nameof(textBuffer));
            }

            _filePath              = filePath;
            _projectManager        = projectManager;
            _projectService        = projectService;
            _editorSettingsManager = editorSettingsManager;
            _textBuffer            = textBuffer;
            _workspace             = workspace; // For now we assume that the workspace is the always default VS workspace.

            _textViews = new List <ITextView>();
        }
예제 #5
0
        public DefaultVisualStudioDocumentTrackerFactory(
            TextBufferProjectService projectService,
            [Import(typeof(VisualStudioWorkspace))] Workspace workspace)
        {
            if (projectService == null)
            {
                throw new ArgumentNullException(nameof(projectService));
            }

            if (workspace == null)
            {
                throw new ArgumentNullException(nameof(workspace));
            }

            _projectService = projectService;
            _workspace      = workspace;

            _foregroundDispatcher = workspace.Services.GetRequiredService <ForegroundDispatcher>();
            _projectManager       = workspace.Services.GetLanguageServices(RazorLanguage.Name).GetRequiredService <ProjectSnapshotManager>();
        }