public DefaultWorkspaceSemanticTokensRefreshPublisher(IClientLanguageServer languageServer, ErrorReporter errorReporter)
        {
            if (languageServer is null)
            {
                throw new ArgumentNullException(nameof(languageServer));
            }

            if (errorReporter is null)
            {
                throw new ArgumentNullException(nameof(errorReporter));
            }

            _languageServer = languageServer;
            _workQueue      = new BatchingWorkQueue(s_debounceTimeSpan, StringComparer.Ordinal, errorReporter: errorReporter);
        }
Beispiel #2
0
        public WorkspaceProjectStateChangeDetectorTest()
        {
            EmptySolution = Workspace.CurrentSolution;

            var projectId1 = ProjectId.CreateNewId("One");
            var projectId2 = ProjectId.CreateNewId("Two");
            var projectId3 = ProjectId.CreateNewId("Three");

            CshtmlDocumentId = DocumentId.CreateNewId(projectId1);
            var cshtmlDocumentInfo = DocumentInfo.Create(CshtmlDocumentId, "Test", filePath: "file.cshtml.g.cs");

            RazorDocumentId = DocumentId.CreateNewId(projectId1);
            var razorDocumentInfo = DocumentInfo.Create(RazorDocumentId, "Test", filePath: "file.razor.g.cs");

            BackgroundVirtualCSharpDocumentId = DocumentId.CreateNewId(projectId1);
            var backgroundDocumentInfo = DocumentInfo.Create(BackgroundVirtualCSharpDocumentId, "Test", filePath: "file.razor__bg__virtual.cs");

            PartialComponentClassDocumentId = DocumentId.CreateNewId(projectId1);
            var partialComponentClassDocumentInfo = DocumentInfo.Create(PartialComponentClassDocumentId, "Test", filePath: "file.razor.cs");

            SolutionWithTwoProjects = Workspace.CurrentSolution
                                      .AddProject(ProjectInfo.Create(
                                                      projectId1,
                                                      VersionStamp.Default,
                                                      "One",
                                                      "One",
                                                      LanguageNames.CSharp,
                                                      filePath: "One.csproj",
                                                      documents: new[] { cshtmlDocumentInfo, razorDocumentInfo, partialComponentClassDocumentInfo, backgroundDocumentInfo }))
                                      .AddProject(ProjectInfo.Create(
                                                      projectId2,
                                                      VersionStamp.Default,
                                                      "Two",
                                                      "Two",
                                                      LanguageNames.CSharp,
                                                      filePath: "Two.csproj"));

            SolutionWithOneProject = EmptySolution
                                     .AddProject(ProjectInfo.Create(
                                                     projectId3,
                                                     VersionStamp.Default,
                                                     "Three",
                                                     "Three",
                                                     LanguageNames.CSharp,
                                                     filePath: "Three.csproj"));

            var project2Reference = new ProjectReference(projectId2);
            var project3Reference = new ProjectReference(projectId3);

            SolutionWithDependentProject = Workspace.CurrentSolution
                                           .AddProject(ProjectInfo.Create(
                                                           projectId1,
                                                           VersionStamp.Default,
                                                           "One",
                                                           "One",
                                                           LanguageNames.CSharp,
                                                           filePath: "One.csproj",
                                                           documents: new[] { cshtmlDocumentInfo, razorDocumentInfo, partialComponentClassDocumentInfo, backgroundDocumentInfo },
                                                           projectReferences: new[] { project2Reference }))
                                           .AddProject(ProjectInfo.Create(
                                                           projectId2,
                                                           VersionStamp.Default,
                                                           "Two",
                                                           "Two",
                                                           LanguageNames.CSharp,
                                                           filePath: "Two.csproj",
                                                           projectReferences: new[] { project3Reference }))
                                           .AddProject(ProjectInfo.Create(
                                                           projectId3,
                                                           VersionStamp.Default,
                                                           "Three",
                                                           "Three",
                                                           LanguageNames.CSharp,
                                                           filePath: "Three.csproj",
                                                           documents: new[] { razorDocumentInfo }));

            ProjectNumberOne   = SolutionWithTwoProjects.GetProject(projectId1);
            ProjectNumberTwo   = SolutionWithTwoProjects.GetProject(projectId2);
            ProjectNumberThree = SolutionWithOneProject.GetProject(projectId3);

            HostProjectOne        = new HostProject("One.csproj", FallbackRazorConfiguration.MVC_1_1, "One");
            HostProjectTwo        = new HostProject("Two.csproj", FallbackRazorConfiguration.MVC_1_1, "Two");
            HostProjectThree      = new HostProject("Three.csproj", FallbackRazorConfiguration.MVC_1_1, "Three");
            WorkQueue             = new BatchingWorkQueue(TimeSpan.FromMilliseconds(1), StringComparer.Ordinal, new DefaultErrorReporter());
            WorkQueueTestAccessor = WorkQueue.GetTestAccessor();
            WorkQueue.GetTestAccessor().NotifyBackgroundWorkCompleted = null;
            WorkQueueTestAccessor.NotifyBackgroundWorkCompleted = new ManualResetEventSlim(initialState: false);
        }