use of org.eclipse.lsp4j.CodeLensParams in project eclipse.jdt.ls by eclipse.
the class CodeLensHandlerTest method testEnableImplementationsCodeLensSymbols.
@Test
public void testEnableImplementationsCodeLensSymbols() 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 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(2, result.size());
CodeLens lens = result.get(1);
@SuppressWarnings("unchecked") List<Object> data = (List<Object>) lens.getData();
String type = (String) data.get(2);
assertEquals(type, "implementations");
}
use of org.eclipse.lsp4j.CodeLensParams in project eclipse.jdt.ls by eclipse.
the class CodeLensHandlerTest method testIgnoreLombokCodeLensSymbols.
@Test
public void testIgnoreLombokCodeLensSymbols() throws Exception {
String payload = createCodeLensSymbolsRequest("src/java/Bar.java");
CodeLensParams codeLensParams = getParams(payload);
String uri = codeLensParams.getTextDocument().getUri();
assertFalse(uri.isEmpty());
// when
List<CodeLens> result = handler.getCodeLensSymbols(uri, monitor);
// then
assertEquals("Found " + result, 4, result.size());
// CodeLens on constructor
CodeLens cl = result.get(0);
assertRange(7, 11, 14, cl.getRange());
// CodeLens on somethingFromJPAModelGen
cl = result.get(1);
assertRange(16, 16, 40, cl.getRange());
// CodeLens on foo
cl = result.get(2);
assertRange(22, 16, 19, cl.getRange());
// CodeLens on Bar type
cl = result.get(3);
assertRange(5, 13, 16, cl.getRange());
}
use of org.eclipse.lsp4j.CodeLensParams in project eclipse.jdt.ls by eclipse.
the class CodeLensHandlerTest method testGetCodeLensSymbols.
@Test
public void testGetCodeLensSymbols() throws Exception {
String payload = createCodeLensSymbolsRequest("src/java/Foo.java");
CodeLensParams codeLensParams = getParams(payload);
String uri = codeLensParams.getTextDocument().getUri();
assertFalse(uri.isEmpty());
// when
List<CodeLens> result = handler.getCodeLensSymbols(uri, monitor);
// then
assertEquals("Found " + result, 3, result.size());
CodeLens cl = result.get(0);
Range r = cl.getRange();
// CodeLens on main method
assertRange(7, 20, 24, r);
cl = result.get(1);
r = cl.getRange();
// CodeLens on foo method
assertRange(14, 13, 16, r);
cl = result.get(2);
r = cl.getRange();
// CodeLens on Foo type
assertRange(5, 13, 16, r);
}
use of org.eclipse.lsp4j.CodeLensParams in project xtext-core by eclipse.
the class AbstractLanguageServerTest method testCodeLens.
protected void testCodeLens(final Procedure1<? super AbstractLanguageServerTest.TestCodeLensConfiguration> configurator) {
try {
@Extension final AbstractLanguageServerTest.TestCodeLensConfiguration configuration = new AbstractLanguageServerTest.TestCodeLensConfiguration();
configuration.setFilePath(("MyModel." + this.fileExtension));
configurator.apply(configuration);
final String filePath = this.initializeContext(configuration).getUri();
CodeLensParams _codeLensParams = new CodeLensParams();
final Procedure1<CodeLensParams> _function = (CodeLensParams it) -> {
TextDocumentIdentifier _textDocumentIdentifier = new TextDocumentIdentifier(filePath);
it.setTextDocument(_textDocumentIdentifier);
};
CodeLensParams _doubleArrow = ObjectExtensions.<CodeLensParams>operator_doubleArrow(_codeLensParams, _function);
final CompletableFuture<List<? extends CodeLens>> codeLenses = this.languageServer.codeLens(_doubleArrow);
final Function1<CodeLens, CodeLens> _function_1 = (CodeLens it) -> {
try {
return this.languageServer.resolveCodeLens(it).get();
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
};
final List<CodeLens> result = IterableExtensions.<CodeLens>toList(ListExtensions.map(codeLenses.get(), _function_1));
if ((configuration.assertCodeLenses != null)) {
configuration.assertCodeLenses.apply(result);
} else {
this.assertEquals(configuration.expectedCodeLensItems, this.toExpectation(result));
}
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
use of org.eclipse.lsp4j.CodeLensParams 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());
}
Aggregations