Example #1
0
        public static ITextDocumentSyncHandler With(this ITextDocumentSyncHandler handler, DocumentSelector?documentSelector, string language)
        {
            ((IDidChangeTextDocumentHandler)handler).GetRegistrationOptions(Arg.Any <SynchronizationCapability>(), Arg.Any <ClientCapabilities>()).Returns(new TextDocumentChangeRegistrationOptions()
            {
                DocumentSelector = documentSelector
            });
            ((IDidOpenTextDocumentHandler)handler).GetRegistrationOptions(Arg.Any <SynchronizationCapability>(), Arg.Any <ClientCapabilities>()).Returns(new TextDocumentOpenRegistrationOptions()
            {
                DocumentSelector = documentSelector
            });
            ((IDidCloseTextDocumentHandler)handler).GetRegistrationOptions(Arg.Any <SynchronizationCapability>(), Arg.Any <ClientCapabilities>()).Returns(new TextDocumentCloseRegistrationOptions()
            {
                DocumentSelector = documentSelector
            });
            ((IDidSaveTextDocumentHandler)handler).GetRegistrationOptions(Arg.Any <SynchronizationCapability>(), Arg.Any <ClientCapabilities>()).Returns(new TextDocumentSaveRegistrationOptions()
            {
                DocumentSelector = documentSelector
            });
            handler.GetTextDocumentAttributes(Arg.Any <DocumentUri>())
            .Returns(c => new TextDocumentAttributes(c.Arg <DocumentUri>(), language));

            handler
            .GetTextDocumentAttributes(Arg.Is <DocumentUri>(x => documentSelector.IsMatch(new TextDocumentAttributes(x, language))))
            .Returns(c => new TextDocumentAttributes(c.Arg <DocumentUri>(), language));

            return(handler);
        }
Example #2
0
        public static ITextDocumentSyncHandler With(this ITextDocumentSyncHandler handler, DocumentSelector documentSelector)
        {
            ((IDidChangeTextDocumentHandler)handler).GetRegistrationOptions().Returns(new TextDocumentChangeRegistrationOptions()
            {
                DocumentSelector = documentSelector
            });
            ((IDidOpenTextDocumentHandler)handler).GetRegistrationOptions().Returns(new TextDocumentRegistrationOptions()
            {
                DocumentSelector = documentSelector
            });
            ((IDidCloseTextDocumentHandler)handler).GetRegistrationOptions().Returns(new TextDocumentRegistrationOptions()
            {
                DocumentSelector = documentSelector
            });
            ((IDidSaveTextDocumentHandler)handler).GetRegistrationOptions().Returns(new TextDocumentSaveRegistrationOptions()
            {
                DocumentSelector = documentSelector
            });

            handler
            .GetTextDocumentAttributes(Arg.Is <Uri>(x => documentSelector.IsMatch(new TextDocumentAttributes(x, ""))))
            .Returns(c => new TextDocumentAttributes(c.Arg <Uri>(), ""));

            return(handler);
        }
Example #3
0
        public static ITextDocumentSyncHandler With(this ITextDocumentSyncHandler handler, DocumentSelector documentSelector, string language)
        {
            ((IDidChangeTextDocumentHandler)handler).GetRegistrationOptions().Returns(new TextDocumentChangeRegistrationOptions()
            {
                DocumentSelector = documentSelector
            });
            ((IDidOpenTextDocumentHandler)handler).GetRegistrationOptions().Returns(new TextDocumentRegistrationOptions()
            {
                DocumentSelector = documentSelector
            });
            ((IDidCloseTextDocumentHandler)handler).GetRegistrationOptions().Returns(new TextDocumentRegistrationOptions()
            {
                DocumentSelector = documentSelector
            });
            ((IDidSaveTextDocumentHandler)handler).GetRegistrationOptions().Returns(new TextDocumentSaveRegistrationOptions()
            {
                DocumentSelector = documentSelector
            });
            ((ITextDocumentIdentifier)handler).GetTextDocumentAttributes(Arg.Any <DocumentUri>())
            .Returns((info) => new TextDocumentAttributes(info.Arg <DocumentUri>(), language));

            handler
            .GetTextDocumentAttributes(Arg.Is <DocumentUri>(x => documentSelector.IsMatch(new TextDocumentAttributes(x, language))))
            .Returns(c => new TextDocumentAttributes(c.Arg <DocumentUri>(), language));

            return(handler);
        }