public DelegatingHandler( Action <DidOpenTextDocumentParams, SynchronizationCapability, CancellationToken> onOpenHandler, Action <DidCloseTextDocumentParams, SynchronizationCapability, CancellationToken> onCloseHandler, Action <DidChangeTextDocumentParams, SynchronizationCapability, CancellationToken> onChangeHandler, Action <DidSaveTextDocumentParams, SynchronizationCapability, CancellationToken> onSaveHandler, Func <DocumentUri, TextDocumentAttributes> getTextDocumentAttributes, TextDocumentSaveRegistrationOptions registrationOptions, TextDocumentSyncKind kind ) : this( (r, c, ct) => { onOpenHandler(r, c, ct); return(Task.CompletedTask); }, (r, c, ct) => { onCloseHandler(r, c, ct); return(Task.CompletedTask); }, (r, c, ct) => { onChangeHandler(r, c, ct); return(Task.CompletedTask); }, (r, c, ct) => { onSaveHandler(r, c, ct); return(Task.CompletedTask); }, getTextDocumentAttributes, registrationOptions, kind ) { }
public static TextDocumentSync FromTextDocumentSyncKind(TextDocumentSyncKind value) { return(new TextDocumentSync { value1 = null, value2 = value }); }
public TextDocumentSyncHandler(TextDocumentSyncKind kind, TextDocumentSaveRegistrationOptions registrationOptions) { _options = registrationOptions; _changeOptions = new TextDocumentChangeRegistrationOptions { DocumentSelector = registrationOptions.DocumentSelector, SyncKind = kind }; }
void OnServerCapabilitiesChanged() { TextDocumentSyncKind?documentSync = ServerCapabilities?.TextDocumentSync?.Change; if (documentSync.HasValue) { documentSyncKind = documentSync.Value; } }
public static ILanguageServerRegistry OnTextDocumentSync(this ILanguageServerRegistry registry, TextDocumentSyncKind kind, Func <DocumentUri, TextDocumentAttributes> getTextDocumentAttributes, Action <DidOpenTextDocumentParams, SynchronizationCapability, CancellationToken> onOpenHandler, Action <DidCloseTextDocumentParams, SynchronizationCapability, CancellationToken> onCloseHandler, Action <DidChangeTextDocumentParams, SynchronizationCapability, CancellationToken> onChangeHandler, Action <DidSaveTextDocumentParams, SynchronizationCapability, CancellationToken> onSaveHandler, TextDocumentSaveRegistrationOptions registrationOptions) { registrationOptions ??= new TextDocumentSaveRegistrationOptions(); return(registry.AddHandlers(new DelegatingHandler(onOpenHandler, onCloseHandler, onChangeHandler, onSaveHandler, getTextDocumentAttributes, registrationOptions, kind))); }
public static IDisposable OnTextDocumentSync( this ILanguageServerRegistry registry, TextDocumentSyncKind kind, Func <DidOpenTextDocumentParams, CancellationToken, Task <Unit> > onOpenHandler, Func <DidCloseTextDocumentParams, CancellationToken, Task <Unit> > onCloseHandler, Func <DidChangeTextDocumentParams, CancellationToken, Task <Unit> > onChangeHandler, Func <DidSaveTextDocumentParams, CancellationToken, Task <Unit> > onSaveHandler, Func <Uri, TextDocumentAttributes> getTextDocumentAttributes, TextDocumentSaveRegistrationOptions registrationOptions = null, Action <SynchronizationCapability> setCapability = null) { registrationOptions = registrationOptions ?? new TextDocumentSaveRegistrationOptions(); return(registry.AddHandlers(new DelegatingHandler(onOpenHandler, onCloseHandler, onChangeHandler, onSaveHandler, getTextDocumentAttributes, setCapability, registrationOptions, kind))); }
public TextDocumentSyncHandler( Mef.IRequestHandler <FileOpenRequest, FileOpenResponse> openHandler, Mef.IRequestHandler <FileCloseRequest, FileCloseResponse> closeHandler, Mef.IRequestHandler <UpdateBufferRequest, object> bufferHandler, DocumentSelector documentSelector, TextDocumentSyncKind documentSyncKind, OmniSharpWorkspace workspace) { _openHandler = openHandler; _closeHandler = closeHandler; _bufferHandler = bufferHandler; _workspace = workspace; _documentSelector = documentSelector; Options.Change = documentSyncKind; }
public DelegatingHandler( Func <DidOpenTextDocumentParams, SynchronizationCapability, CancellationToken, Task> onOpenHandler, Func <DidCloseTextDocumentParams, SynchronizationCapability, CancellationToken, Task> onCloseHandler, Func <DidChangeTextDocumentParams, SynchronizationCapability, CancellationToken, Task> onChangeHandler, Func <DidSaveTextDocumentParams, SynchronizationCapability, CancellationToken, Task> onSaveHandler, Func <DocumentUri, TextDocumentAttributes> getTextDocumentAttributes, TextDocumentSaveRegistrationOptions registrationOptions, TextDocumentSyncKind kind) : base(kind, registrationOptions) { _onOpenHandler = onOpenHandler; _onSaveHandler = onSaveHandler; _onChangeHandler = onChangeHandler; _onCloseHandler = onCloseHandler; _getTextDocumentAttributes = getTextDocumentAttributes; }
public static ILanguageServerRegistry OnTextDocumentSync(this ILanguageServerRegistry registry, TextDocumentSyncKind kind, Func <DocumentUri, TextDocumentAttributes> getTextDocumentAttributes, Action <DidOpenTextDocumentParams> onOpenHandler, Action <DidCloseTextDocumentParams> onCloseHandler, Action <DidChangeTextDocumentParams> onChangeHandler, Action <DidSaveTextDocumentParams> onSaveHandler, TextDocumentSaveRegistrationOptions registrationOptions) { registrationOptions ??= new TextDocumentSaveRegistrationOptions(); return(registry.AddHandlers(new DelegatingHandler( (r, c, ct) => onOpenHandler(r), (r, c, ct) => onCloseHandler(r), (r, c, ct) => onChangeHandler(r), (r, c, ct) => onSaveHandler(r), getTextDocumentAttributes, registrationOptions, kind))); }
public OmniSharpTextDocumentSyncHandler( Mef.IRequestHandler <FileOpenRequest, FileOpenResponse> openHandler, Mef.IRequestHandler <FileCloseRequest, FileCloseResponse> closeHandler, Mef.IRequestHandler <UpdateBufferRequest, object> bufferHandler, DocumentSelector documentSelector, TextDocumentSyncKind documentSyncKind, OmniSharpWorkspace workspace) : base(documentSyncKind, new TextDocumentSaveRegistrationOptions() { DocumentSelector = documentSelector, IncludeText = true, }) { _openHandler = openHandler; _closeHandler = closeHandler; _bufferHandler = bufferHandler; _workspace = workspace; }
public void NoFileExtension() { string configFile = Files.cr_noEnding; var ci = new ConfigInitializer(new string[] { }, configFile); ci.SetUp(); string expectedLogFile = CombineWithDefaultLogFolder("StreamRedirection"); string expectedStreamFile = CombineWithDefaultLogFolder("Log"); LogLevel expectedLogLevel = LogLevel.Error; TextDocumentSyncKind expectedSyncKind = TextDocumentSyncKind.Incremental; Console.WriteLine(LanguageServerConfig.ToString()); Assert.IsFalse(ci.Errors.HasErrors); Assert.AreEqual(expectedLogFile, LanguageServerConfig.LogFile); Assert.AreEqual(expectedStreamFile, LanguageServerConfig.RedirectedStreamFile); Assert.AreEqual(expectedSyncKind, LanguageServerConfig.SyncKind); Assert.AreEqual(expectedLogLevel, LanguageServerConfig.LogLevel); }
public void WrongLogPathType() { string configFile = Files.cr_wrongLogPathType; var ci = new ConfigInitializer(new string[] { }, configFile); ci.SetUp(); string expectedLogFile = CombineWithDefaultLogFolder("../2"); string expectedStreamFile = defaultStream; LogLevel expectedLogLevel = LogLevel.Error; TextDocumentSyncKind expectedSyncKind = TextDocumentSyncKind.Incremental; Console.WriteLine(LanguageServerConfig.ToString()); Assert.IsFalse(ci.Errors.HasErrors); Assert.AreEqual(expectedLogFile, LanguageServerConfig.LogFile); Assert.AreEqual(expectedStreamFile, LanguageServerConfig.RedirectedStreamFile); Assert.AreEqual(expectedSyncKind, LanguageServerConfig.SyncKind); Assert.AreEqual(expectedLogLevel, LanguageServerConfig.LogLevel); }
public void MissingFields() { string configFile = Files.cr_missingFields; var ci = new ConfigInitializer(new string[] { }, configFile); ci.SetUp(); string expectedLogFile = defaultLog; string expectedStreamFile = defaultStream; LogLevel expectedLogLevel = LogLevel.Error; TextDocumentSyncKind expectedSyncKind = TextDocumentSyncKind.Incremental; Console.WriteLine(LanguageServerConfig.ToString()); Assert.IsFalse(ci.Errors.HasErrors, "has error mismatch"); Assert.AreEqual(expectedLogFile, LanguageServerConfig.LogFile); Assert.AreEqual(expectedStreamFile, LanguageServerConfig.RedirectedStreamFile); Assert.AreEqual(expectedSyncKind, LanguageServerConfig.SyncKind); Assert.AreEqual(expectedLogLevel, LanguageServerConfig.LogLevel); }
public void GoodCustomValues() { string configFile = Files.cr_fine; var ci = new ConfigInitializer(new string[] { }, configFile); ci.SetUp(); string expectedLogFile = CombineWithDefaultLogFolder("./b.txt"); string expectedStreamFile = CombineWithDefaultLogFolder("./a.txt"); LogLevel expectedLogLevel = LogLevel.Trace; TextDocumentSyncKind expectedSyncKind = TextDocumentSyncKind.Full; Console.WriteLine(LanguageServerConfig.ToString()); Assert.IsFalse(ci.Errors.HasErrors); Assert.AreEqual(expectedLogFile, LanguageServerConfig.LogFile); Assert.AreEqual(expectedStreamFile, LanguageServerConfig.RedirectedStreamFile); Assert.AreEqual(expectedLogLevel, LanguageServerConfig.LogLevel); Assert.AreEqual(expectedSyncKind, LanguageServerConfig.SyncKind); }
public void SameFiles() { string configFile = Files.cr_sameFiles; var ci = new ConfigInitializer(new string[] { }, configFile); ci.SetUp(); string expectedLogFile = defaultLog; string expectedStreamFile = defaultStream; LogLevel expectedLogLevel = LogLevel.Error; TextDocumentSyncKind expectedSyncKind = TextDocumentSyncKind.Incremental; Console.WriteLine(LanguageServerConfig.ToString()); Assert.IsTrue(ci.Errors.HasErrors); Assert.IsTrue(ci.Errors.ErrorMessages.Contains("same files")); Assert.AreEqual(expectedLogFile, LanguageServerConfig.LogFile); Assert.AreEqual(expectedStreamFile, LanguageServerConfig.RedirectedStreamFile); Assert.AreEqual(expectedSyncKind, LanguageServerConfig.SyncKind); Assert.AreEqual(expectedLogLevel, LanguageServerConfig.LogLevel); }
public void ExceedingLogLevelInArgs() { string configFile = Files.cr_default; var ci = new ConfigInitializer(new string[] { "/loglevel:55" }, configFile); ci.SetUp(); string expectedLogFile = defaultLog; string expectedStreamFile = defaultStream; LogLevel expectedLogLevel = LogLevel.Error; TextDocumentSyncKind expectedSyncKind = TextDocumentSyncKind.Incremental; Console.WriteLine(LanguageServerConfig.ToString()); Assert.IsTrue(ci.Errors.HasErrors, "Error Mismatch"); Assert.AreEqual(expectedLogFile, LanguageServerConfig.LogFile); Assert.AreEqual(expectedStreamFile, LanguageServerConfig.RedirectedStreamFile); Assert.AreEqual(expectedSyncKind, LanguageServerConfig.SyncKind); Assert.AreEqual(expectedLogLevel, LanguageServerConfig.LogLevel); }
public void MissingCfGFile() { string configFile = Files.cr_default; var ci = new ConfigInitializer(new string[] { "/log:./Logs/a.txt", "/stream:./Logs/b.txt", "/loglevel:0" }, configFile); ci.SetUp(); string expectedLogFile = CombineWithDefaultLogFolder("a.txt"); string expectedStreamFile = CombineWithDefaultLogFolder("b.txt"); LogLevel expectedLogLevel = LogLevel.Trace; TextDocumentSyncKind expectedSyncKind = TextDocumentSyncKind.Incremental; Console.WriteLine(LanguageServerConfig.ToString()); Assert.IsFalse(ci.Errors.HasErrors, "Error Mismatch"); Assert.AreEqual(expectedLogFile, LanguageServerConfig.LogFile); Assert.AreEqual(expectedStreamFile, LanguageServerConfig.RedirectedStreamFile); Assert.AreEqual(expectedSyncKind, LanguageServerConfig.SyncKind); Assert.AreEqual(expectedLogLevel, LanguageServerConfig.LogLevel); }
public void NoCfgFile() { string configFile = CombinePath("/", "abasdfasfdsa.json"); var ci = new ConfigInitializer(new string[] { }, configFile); ci.SetUp(); string expectedLogFile = defaultLog; string expectedStreamFile = defaultStream; LogLevel expectedLogLevel = LogLevel.Error; TextDocumentSyncKind expectedSyncKind = TextDocumentSyncKind.Incremental; Console.WriteLine(LanguageServerConfig.ToString()); Assert.IsTrue(ci.Errors.HasErrors, "Error Mismatch"); Assert.IsTrue(ci.Errors.ErrorMessages.Contains("not be located"), "Errormsg not contained"); Assert.AreEqual(expectedLogFile, LanguageServerConfig.LogFile); Assert.AreEqual(expectedStreamFile, LanguageServerConfig.RedirectedStreamFile); Assert.AreEqual(expectedSyncKind, LanguageServerConfig.SyncKind); Assert.AreEqual(expectedLogLevel, LanguageServerConfig.LogLevel); }
public void ExceedingLogLevel() { string configFile = Files.cr_wrongLogLevel; var ci = new ConfigInitializer(new string[] { }, configFile); ci.SetUp(); string expectedLogFile = defaultLog; string expectedStreamFile = defaultStream; LogLevel expectedLogLevel = LogLevel.Error; TextDocumentSyncKind expectedSyncKind = TextDocumentSyncKind.Incremental; Console.WriteLine(LanguageServerConfig.ToString()); Assert.IsTrue(ci.Errors.HasErrors, "error expectation mismatch"); Assert.IsTrue(ci.Errors.ErrorMessages.Contains("Loglevel must be between")); Assert.AreEqual(expectedLogFile, LanguageServerConfig.LogFile); Assert.AreEqual(expectedStreamFile, LanguageServerConfig.RedirectedStreamFile); Assert.AreEqual(expectedSyncKind, LanguageServerConfig.SyncKind); Assert.AreEqual(expectedLogLevel, LanguageServerConfig.LogLevel); }
public void IllegalArgument() { string configFile = Files.cr_default; var ci = new ConfigInitializer(new string[] { "/abc:ab" }, configFile); ci.SetUp(); string expectedLogFile = defaultLog; string expectedStreamFile = defaultStream; LogLevel expectedLogLevel = LogLevel.Error; TextDocumentSyncKind expectedSyncKind = TextDocumentSyncKind.Incremental; Console.WriteLine(LanguageServerConfig.ToString()); Assert.IsTrue(ci.Errors.HasErrors, "Error Mismatch"); Assert.IsTrue(ci.Errors.ErrorMessages.Contains("Unknown switch")); Assert.AreEqual(expectedLogFile, LanguageServerConfig.LogFile); Assert.AreEqual(expectedStreamFile, LanguageServerConfig.RedirectedStreamFile); Assert.AreEqual(expectedSyncKind, LanguageServerConfig.SyncKind); Assert.AreEqual(expectedLogLevel, LanguageServerConfig.LogLevel); }
public TextDocumentSyncOptions(TextDocumentSyncKind syncKind) { OpenClose = true; Change = syncKind; }
public ServerCapabilities(TextDocumentSyncKind syncKind) { TextDocumentSync = new TextDocumentSyncOptions(syncKind); HoverProvider = true; }
public InitializeResult(TextDocumentSyncKind syncKind) { Capabilities = new ServerCapabilities(syncKind); }
public TextDocumentSync(TextDocumentSyncKind kind) => Kind = kind;