Example #1
0
        private RazorProximityExpressionResolver CreateResolverWith(
            FileUriProvider uriProvider              = null,
            LSPDocumentManager documentManager       = null,
            LSPProjectionProvider projectionProvider = null)
        {
            var documentUri = DocumentUri;

            uriProvider ??= Mock.Of <FileUriProvider>(provider => provider.TryGet(HostTextbuffer, out documentUri) == true && provider.TryGet(It.IsNotIn(HostTextbuffer), out It.Ref <Uri> .IsAny) == false, MockBehavior.Strict);
            var csharpVirtualDocumentSnapshot    = new CSharpVirtualDocumentSnapshot(CSharpDocumentUri, CSharpTextBuffer.CurrentSnapshot, hostDocumentSyncVersion: 0);
            LSPDocumentSnapshot documentSnapshot = new TestLSPDocumentSnapshot(DocumentUri, 0, csharpVirtualDocumentSnapshot);

            documentManager ??= Mock.Of <LSPDocumentManager>(manager => manager.TryGetDocument(DocumentUri, out documentSnapshot) == true, MockBehavior.Strict);
            if (projectionProvider is null)
            {
                projectionProvider = new Mock <LSPProjectionProvider>(MockBehavior.Strict).Object;
                Mock.Get(projectionProvider).Setup(projectionProvider => projectionProvider.GetProjectionAsync(It.IsAny <LSPDocumentSnapshot>(), It.IsAny <Position>(), CancellationToken.None))
                .Returns(Task.FromResult <ProjectionResult>(null));
            }
            var razorProximityExpressionResolver = DefaultRazorProximityExpressionResolver.CreateTestInstance(
                uriProvider,
                documentManager,
                projectionProvider);

            return(razorProximityExpressionResolver);
        }
        private RazorProximityExpressionResolver CreateResolverWith(
            FileUriProvider uriProvider              = null,
            LSPDocumentManager documentManager       = null,
            LSPProjectionProvider projectionProvider = null)
        {
            var documentUri = DocumentUri;

            uriProvider ??= Mock.Of <FileUriProvider>(provider => provider.TryGet(HostTextbuffer, out documentUri) == true && provider.TryGet(It.IsNotIn(HostTextbuffer), out It.Ref <Uri> .IsAny) == false, MockBehavior.Strict);
            var csharpDocumentUri                = new Uri(DocumentUri.OriginalString + ".g.cs", UriKind.Absolute);
            var csharpVirtualDocumentSnapshot    = new CSharpVirtualDocumentSnapshot(csharpDocumentUri, CSharpTextBuffer.CurrentSnapshot, hostDocumentSyncVersion: 0);
            LSPDocumentSnapshot documentSnapshot = new TestLSPDocumentSnapshot(DocumentUri, 0, csharpVirtualDocumentSnapshot);

            documentManager ??= Mock.Of <LSPDocumentManager>(manager => manager.TryGetDocument(DocumentUri, out documentSnapshot) == true, MockBehavior.Strict);
            if (projectionProvider is null)
            {
                projectionProvider = new Mock <LSPProjectionProvider>(MockBehavior.Strict).Object;
                Mock.Get(projectionProvider).Setup(projectionProvider => projectionProvider.GetProjectionAsync(It.IsAny <LSPDocumentSnapshot>(), It.IsAny <Position>(), CancellationToken.None))
                .Returns(Task.FromResult <ProjectionResult>(null));
            }
            CodeAnalysis.Workspace workspace     = null;
            var workspaceAccessor                = Mock.Of <VisualStudioWorkspaceAccessor>(accessor => accessor.TryGetWorkspace(It.IsAny <ITextBuffer>(), out workspace) == false, MockBehavior.Strict);
            var razorProximityExpressionResolver = new DefaultRazorProximityExpressionResolver(
                uriProvider,
                documentManager,
                projectionProvider,
                workspaceAccessor);

            return(razorProximityExpressionResolver);
        }
        private RazorProximityExpressionResolver CreateResolverWith(
            FileUriProvider uriProvider        = null,
            LSPDocumentManager documentManager = null)
        {
            var documentUri = DocumentUri;

            uriProvider ??= Mock.Of <FileUriProvider>(provider => provider.TryGet(HostTextbuffer, out documentUri) == true && provider.TryGet(It.IsNotIn(HostTextbuffer), out It.Ref <Uri> .IsAny) == false, MockBehavior.Strict);
            var csharpVirtualDocumentSnapshot    = new CSharpVirtualDocumentSnapshot(CSharpDocumentUri, CSharpTextBuffer.CurrentSnapshot, hostDocumentSyncVersion: 0);
            LSPDocumentSnapshot documentSnapshot = new TestLSPDocumentSnapshot(DocumentUri, 0, csharpVirtualDocumentSnapshot);

            documentManager ??= Mock.Of <LSPDocumentManager>(manager => manager.TryGetDocument(DocumentUri, out documentSnapshot) == true, MockBehavior.Strict);

            var razorProximityExpressionResolver = new DefaultRazorProximityExpressionResolver(
                uriProvider,
                documentManager,
                TestLSPProximityExpressionProvider.Instance);

            return(razorProximityExpressionResolver);
        }
        private RazorProximityExpressionResolver CreateResolverWith(
            FileUriProvider uriProvider              = null,
            LSPDocumentManager documentManager       = null,
            LSPProjectionProvider projectionProvider = null)
        {
            var documentUri = DocumentUri;

            uriProvider ??= Mock.Of <FileUriProvider>(provider => provider.TryGet(HostTextbuffer, out documentUri) == true);
            var csharpDocumentUri                = new Uri(DocumentUri.OriginalString + ".g.cs", UriKind.Absolute);
            var csharpVirtualDocumentSnapshot    = new CSharpVirtualDocumentSnapshot(csharpDocumentUri, CSharpTextBuffer.CurrentSnapshot, hostDocumentSyncVersion: 0);
            LSPDocumentSnapshot documentSnapshot = new TestLSPDocumentSnapshot(DocumentUri, 0, csharpVirtualDocumentSnapshot);

            documentManager ??= Mock.Of <LSPDocumentManager>(manager => manager.TryGetDocument(DocumentUri, out documentSnapshot) == true);
            projectionProvider ??= Mock.Of <LSPProjectionProvider>();
            var csharpProximityExpressionResolver = new DefaultCSharpProximityExpressionResolver();
            var razorProximityExpressionResolver  = new DefaultRazorProximityExpressionResolver(
                uriProvider,
                documentManager,
                projectionProvider,
                csharpProximityExpressionResolver);

            return(razorProximityExpressionResolver);
        }