Search in sources :

Example 6 with ClientPreferences

use of org.eclipse.jdt.ls.core.internal.preferences.ClientPreferences in project eclipse.jdt.ls by eclipse.

the class InitHandlerTest method testExecuteCommandProvider.

@Test
public void testExecuteCommandProvider() throws Exception {
    ClientPreferences mockCapabilies = mock(ClientPreferences.class);
    when(mockCapabilies.isExecuteCommandDynamicRegistrationSupported()).thenReturn(Boolean.FALSE);
    when(preferenceManager.getClientPreferences()).thenReturn(mockCapabilies);
    InitializeResult result = initialize(false);
    List<String> commands = result.getCapabilities().getExecuteCommandProvider().getCommands();
    assertFalse(commands.isEmpty());
}
Also used : InitializeResult(org.eclipse.lsp4j.InitializeResult) ClientPreferences(org.eclipse.jdt.ls.core.internal.preferences.ClientPreferences) AbstractProjectsManagerBasedTest(org.eclipse.jdt.ls.core.internal.managers.AbstractProjectsManagerBasedTest) Test(org.junit.Test)

Example 7 with ClientPreferences

use of org.eclipse.jdt.ls.core.internal.preferences.ClientPreferences in project eclipse.jdt.ls by eclipse.

the class InitHandlerTest method testExecuteCommandProviderDynamicRegistration.

@Test
public void testExecuteCommandProviderDynamicRegistration() throws Exception {
    ClientPreferences mockCapabilies = mock(ClientPreferences.class);
    when(mockCapabilies.isExecuteCommandDynamicRegistrationSupported()).thenReturn(Boolean.TRUE);
    when(preferenceManager.getClientPreferences()).thenReturn(mockCapabilies);
    InitializeResult result = initialize(true);
    assertNull(result.getCapabilities().getExecuteCommandProvider());
}
Also used : InitializeResult(org.eclipse.lsp4j.InitializeResult) ClientPreferences(org.eclipse.jdt.ls.core.internal.preferences.ClientPreferences) AbstractProjectsManagerBasedTest(org.eclipse.jdt.ls.core.internal.managers.AbstractProjectsManagerBasedTest) Test(org.junit.Test)

Example 8 with ClientPreferences

use of org.eclipse.jdt.ls.core.internal.preferences.ClientPreferences in project eclipse.jdt.ls by eclipse.

the class CompletionHandlerTest method mockClientPreferences.

private ClientPreferences mockClientPreferences(boolean supportCompletionSnippets, boolean supportSignatureHelp) {
    ClientPreferences mockCapabilies = Mockito.mock(ClientPreferences.class);
    Mockito.when(preferenceManager.getClientPreferences()).thenReturn(mockCapabilies);
    Mockito.when(mockCapabilies.isCompletionSnippetsSupported()).thenReturn(supportCompletionSnippets);
    Mockito.when(mockCapabilies.isSignatureHelpSupported()).thenReturn(supportSignatureHelp);
    return mockCapabilies;
}
Also used : ClientPreferences(org.eclipse.jdt.ls.core.internal.preferences.ClientPreferences)

Example 9 with ClientPreferences

use of org.eclipse.jdt.ls.core.internal.preferences.ClientPreferences in project eclipse.jdt.ls by eclipse.

the class CompletionHandlerTest method mockLSPClient.

private void mockLSPClient(boolean isSnippetSupported, boolean isSignatureHelpSuported) {
    reset(preferenceManager);
    ClientPreferences mockCapabilies = mock(ClientPreferences.class);
    // Mock the preference manager to use LSP v3 support.
    when(preferenceManager.getClientPreferences()).thenReturn(mockCapabilies);
    when(mockCapabilies.isCompletionSnippetsSupported()).thenReturn(isSnippetSupported);
    when(mockCapabilies.isSignatureHelpSupported()).thenReturn(isSignatureHelpSuported);
    when(preferenceManager.getClientPreferences()).thenReturn(mockCapabilies);
}
Also used : ClientPreferences(org.eclipse.jdt.ls.core.internal.preferences.ClientPreferences)

Aggregations

ClientPreferences (org.eclipse.jdt.ls.core.internal.preferences.ClientPreferences)9 Test (org.junit.Test)6 AbstractProjectsManagerBasedTest (org.eclipse.jdt.ls.core.internal.managers.AbstractProjectsManagerBasedTest)5 InitializeResult (org.eclipse.lsp4j.InitializeResult)4 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 IFile (org.eclipse.core.resources.IFile)1 IProject (org.eclipse.core.resources.IProject)1 IResource (org.eclipse.core.resources.IResource)1 IPath (org.eclipse.core.runtime.IPath)1 Path (org.eclipse.core.runtime.Path)1 IBuffer (org.eclipse.jdt.core.IBuffer)1 IJavaProject (org.eclipse.jdt.core.IJavaProject)1 WorkingCopyOwner (org.eclipse.jdt.core.WorkingCopyOwner)1 DocumentAdapter (org.eclipse.jdt.ls.core.internal.DocumentAdapter)1 FileSystemWatcher (org.eclipse.jdt.ls.core.internal.FileSystemWatcher)1 Lsp4jAssertions.assertTextEdit (org.eclipse.jdt.ls.core.internal.Lsp4jAssertions.assertTextEdit)1 SimpleLogListener (org.eclipse.jdt.ls.core.internal.SimpleLogListener)1 ProgressReporterManager (org.eclipse.jdt.ls.core.internal.handlers.ProgressReporterManager)1