Search in sources :

Example 6 with CodeLensParams

use of org.eclipse.lsp4j.CodeLensParams in project eclipse.jdt.ls by eclipse.

the class CodeLensHandlerTest method testGetCodeLenseBoundaries.

@Test
public void testGetCodeLenseBoundaries() {
    List<CodeLens> result = handler.getCodeLensSymbols(null, monitor);
    assertNotNull(result);
    assertEquals(0, result.size());
    String payload = createCodeLensSymbolsRequest("src/java/Missing.java");
    CodeLensParams codeLensParams = getParams(payload);
    String uri = codeLensParams.getTextDocument().getUri();
    result = handler.getCodeLensSymbols(uri, monitor);
    assertEquals(0, result.size());
}
Also used : CodeLens(org.eclipse.lsp4j.CodeLens) CodeLensParams(org.eclipse.lsp4j.CodeLensParams) AbstractProjectsManagerBasedTest(org.eclipse.jdt.ls.core.internal.managers.AbstractProjectsManagerBasedTest) Test(org.junit.Test)

Example 7 with CodeLensParams

use of org.eclipse.lsp4j.CodeLensParams 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 8 with CodeLensParams

use of org.eclipse.lsp4j.CodeLensParams 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)

Example 9 with CodeLensParams

use of org.eclipse.lsp4j.CodeLensParams in project sts4 by spring-projects.

the class LanguageServerHarness method getCodeLenses.

public List<? extends CodeLens> getCodeLenses(TextDocumentInfo document) throws Exception {
    CodeLensParams params = new CodeLensParams();
    params.setTextDocument(document.getId());
    return getServer().getTextDocumentService().codeLens(params).get();
}
Also used : CodeLensParams(org.eclipse.lsp4j.CodeLensParams)

Aggregations

CodeLensParams (org.eclipse.lsp4j.CodeLensParams)9 CodeLens (org.eclipse.lsp4j.CodeLens)8 AbstractProjectsManagerBasedTest (org.eclipse.jdt.ls.core.internal.managers.AbstractProjectsManagerBasedTest)7 Test (org.junit.Test)7 Preferences (org.eclipse.jdt.ls.core.internal.preferences.Preferences)4 List (java.util.List)2 URI (java.net.URI)1 Lsp4jAssertions.assertRange (org.eclipse.jdt.ls.core.internal.Lsp4jAssertions.assertRange)1 CompletionList (org.eclipse.lsp4j.CompletionList)1 Range (org.eclipse.lsp4j.Range)1 TextDocumentIdentifier (org.eclipse.lsp4j.TextDocumentIdentifier)1 Extension (org.eclipse.xtext.xbase.lib.Extension)1