@Inject public LanguageServerReconcileStrategy( TextDocumentSynchronizeFactory synchronizeFactory, @Assisted ServerCapabilities serverCapabilities) { Either<TextDocumentSyncKind, TextDocumentSyncOptions> sync = serverCapabilities.getTextDocumentSync(); TextDocumentSyncKind documentSync; if (sync.isLeft()) { documentSync = sync.getLeft(); } else { documentSync = sync.getRight().getChange(); } synchronize = synchronizeFactory.getSynchronize(documentSync); }
@Test public void testWillSaveAndWillSaveWaitUntilCapabilities() throws Exception { ClientPreferences mockCapabilies = mock(ClientPreferences.class); when(mockCapabilies.isExecuteCommandDynamicRegistrationSupported()).thenReturn(Boolean.TRUE); when(preferenceManager.getClientPreferences()).thenReturn(mockCapabilies); when(mockCapabilies.isWillSaveRegistered()).thenReturn(Boolean.TRUE); when(mockCapabilies.isWillSaveWaitUntilRegistered()).thenReturn(Boolean.TRUE); InitializeResult result = initialize(true); Either<TextDocumentSyncKind, TextDocumentSyncOptions> o = result.getCapabilities().getTextDocumentSync(); assertTrue(o.isRight()); assertTrue(o.getRight().getWillSave()); assertTrue(o.getRight().getWillSaveWaitUntil()); }
/** * Defines how text documents are synced. Is either a detailed structure defining each notification or * for backwards compatibility the TextDocumentSyncKind number. */ @Pure public Either<TextDocumentSyncKind, TextDocumentSyncOptions> getTextDocumentSync() { return this.textDocumentSync; }
public void setTextDocumentSync(final TextDocumentSyncOptions textDocumentSync) { this.textDocumentSync = Either.forRight(textDocumentSync); }
public Either<TextDocumentSyncKind, TextDocumentSyncOptions> getTextDocumentSync() { return mergeTextDocumentSync(left.getTextDocumentSync(), right.getTextDocumentSync()); }
private Either<TextDocumentSyncKind, TextDocumentSyncOptions> mergeTextDocumentSync( Either<TextDocumentSyncKind, TextDocumentSyncOptions> left, Either<TextDocumentSyncKind, TextDocumentSyncOptions> right) { if (left == null) { return right; } if (right == null) { return left; } if (left.equals(right)) { return left; } if (left.isLeft() && left.getLeft() == TextDocumentSyncKind.Full) { return left; } if (left.isLeft() && left.getLeft() == TextDocumentSyncKind.Incremental) { if (right.isLeft() && right.getLeft() == TextDocumentSyncKind.Full) { return right; } else { return left; } } if (left.isRight() && right.isRight()) { TextDocumentSyncOptions leftRight = left.getRight(); TextDocumentSyncOptions rightRight = right.getRight(); if (leftRight.getChange() == TextDocumentSyncKind.Full) { return left; } if (leftRight.getChange() == TextDocumentSyncKind.Incremental) { if (rightRight.getChange() == TextDocumentSyncKind.Full) { return right; } else { return left; } } } if (left.isLeft() && right.isRight()) { return right; } if (left.isRight() && right.isLeft()) { return left; } return right; }
/** * Defines how text documents are synced. Is either a detailed structure defining each notification or * for backwards compatibility the TextDocumentSyncKind number. */ public void setTextDocumentSync(final Either<TextDocumentSyncKind, TextDocumentSyncOptions> textDocumentSync) { this.textDocumentSync = textDocumentSync; }