Search in sources :

Example 6 with Preferences

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

the class NavigateToDefinitionHandlerTest method setUp.

@Before
public void setUp() throws Exception {
    preferenceManager = mock(PreferenceManager.class);
    when(preferenceManager.getPreferences()).thenReturn(new Preferences());
    handler = new NavigateToDefinitionHandler(preferenceManager);
    importProjects("maven/salut");
    project = WorkspaceHelper.getProject("salut");
}
Also used : Preferences(org.eclipse.jdt.ls.core.internal.preferences.Preferences) PreferenceManager(org.eclipse.jdt.ls.core.internal.preferences.PreferenceManager) Before(org.junit.Before)

Example 7 with Preferences

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

the class CodeLensHandlerTest method setup.

@Before
public void setup() throws Exception {
    importProjects("eclipse/hello");
    project = WorkspaceHelper.getProject("hello");
    preferenceManager = mock(PreferenceManager.class);
    when(preferenceManager.getPreferences()).thenReturn(new Preferences());
    handler = new CodeLensHandler(preferenceManager);
}
Also used : Preferences(org.eclipse.jdt.ls.core.internal.preferences.Preferences) PreferenceManager(org.eclipse.jdt.ls.core.internal.preferences.PreferenceManager) Before(org.junit.Before)

Example 8 with Preferences

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

the class CodeLensHandlerTest method testGetCodeLensSymbolsForClass.

@Test
public void testGetCodeLensSymbolsForClass() throws Exception {
    Preferences implementationsCodeLenses = Preferences.createFrom(Collections.singletonMap(Preferences.IMPLEMENTATIONS_CODE_LENS_ENABLED_KEY, "true"));
    Mockito.reset(preferenceManager);
    when(preferenceManager.getPreferences()).thenReturn(implementationsCodeLenses);
    handler = new CodeLensHandler(preferenceManager);
    String uriString = ClassFileUtil.getURI(project, "java.lang.Runnable");
    String payload = createCodeLensSymbolRequest(new URI(uriString));
    CodeLensParams codeLensParams = getParams(payload);
    String uri = codeLensParams.getTextDocument().getUri();
    assertFalse(uri.isEmpty());
    List<CodeLens> lenses = handler.getCodeLensSymbols(uri, monitor);
    assertEquals("Found " + lenses, 3, lenses.size());
}
Also used : CodeLens(org.eclipse.lsp4j.CodeLens) CodeLensParams(org.eclipse.lsp4j.CodeLensParams) Preferences(org.eclipse.jdt.ls.core.internal.preferences.Preferences) URI(java.net.URI) AbstractProjectsManagerBasedTest(org.eclipse.jdt.ls.core.internal.managers.AbstractProjectsManagerBasedTest) Test(org.junit.Test)

Example 9 with Preferences

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

the class CodeLensHandlerTest method testDisableCodeLensSymbols.

@Test
public void testDisableCodeLensSymbols() throws Exception {
    Preferences noCodeLenses = Preferences.createFrom(Collections.singletonMap(Preferences.REFERENCES_CODE_LENS_ENABLED_KEY, "false"));
    Mockito.reset(preferenceManager);
    when(preferenceManager.getPreferences()).thenReturn(noCodeLenses);
    handler = new CodeLensHandler(preferenceManager);
    String payload = createCodeLensSymbolsRequest("src/java/IFoo.java");
    CodeLensParams codeLensParams = getParams(payload);
    String uri = codeLensParams.getTextDocument().getUri();
    assertFalse(uri.isEmpty());
    // when
    List<CodeLens> result = handler.getCodeLensSymbols(uri, monitor);
    // then
    assertEquals(0, result.size());
}
Also used : CodeLens(org.eclipse.lsp4j.CodeLens) CodeLensParams(org.eclipse.lsp4j.CodeLensParams) Preferences(org.eclipse.jdt.ls.core.internal.preferences.Preferences) AbstractProjectsManagerBasedTest(org.eclipse.jdt.ls.core.internal.managers.AbstractProjectsManagerBasedTest) Test(org.junit.Test)

Example 10 with Preferences

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

the class CodeLensHandlerTest method testDisableImplementationsCodeLensSymbols.

@Test
public void testDisableImplementationsCodeLensSymbols() throws Exception {
    Preferences noImplementationsCodeLenses = Preferences.createFrom(Collections.singletonMap(Preferences.IMPLEMENTATIONS_CODE_LENS_ENABLED_KEY, "false"));
    Mockito.reset(preferenceManager);
    when(preferenceManager.getPreferences()).thenReturn(noImplementationsCodeLenses);
    Preferences noReferencesCodeLenses = Preferences.createFrom(Collections.singletonMap(Preferences.REFERENCES_CODE_LENS_ENABLED_KEY, "false"));
    Mockito.reset(preferenceManager);
    when(preferenceManager.getPreferences()).thenReturn(noReferencesCodeLenses);
    handler = new CodeLensHandler(preferenceManager);
    String payload = createCodeLensSymbolsRequest("src/java/IFoo.java");
    CodeLensParams codeLensParams = getParams(payload);
    String uri = codeLensParams.getTextDocument().getUri();
    assertFalse(uri.isEmpty());
    // when
    List<CodeLens> result = handler.getCodeLensSymbols(uri, monitor);
    // then
    assertEquals(0, result.size());
}
Also used : CodeLens(org.eclipse.lsp4j.CodeLens) CodeLensParams(org.eclipse.lsp4j.CodeLensParams) Preferences(org.eclipse.jdt.ls.core.internal.preferences.Preferences) AbstractProjectsManagerBasedTest(org.eclipse.jdt.ls.core.internal.managers.AbstractProjectsManagerBasedTest) Test(org.junit.Test)

Aggregations

Preferences (org.eclipse.jdt.ls.core.internal.preferences.Preferences)17 Before (org.junit.Before)8 PreferenceManager (org.eclipse.jdt.ls.core.internal.preferences.PreferenceManager)7 AbstractProjectsManagerBasedTest (org.eclipse.jdt.ls.core.internal.managers.AbstractProjectsManagerBasedTest)5 Test (org.junit.Test)5 CodeLens (org.eclipse.lsp4j.CodeLens)4 CodeLensParams (org.eclipse.lsp4j.CodeLensParams)4 IJavaProject (org.eclipse.jdt.core.IJavaProject)3 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 CoreException (org.eclipse.core.runtime.CoreException)2 ClientPreferences (org.eclipse.jdt.ls.core.internal.preferences.ClientPreferences)2 URI (java.net.URI)1 List (java.util.List)1 IFile (org.eclipse.core.resources.IFile)1 IResource (org.eclipse.core.resources.IResource)1 IPath (org.eclipse.core.runtime.IPath)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1 IBuffer (org.eclipse.jdt.core.IBuffer)1