use of org.eclipse.lsp4j.MarkupContent in project eclipse.jdt.ls by eclipse.
the class SnippetUtilsTest method testWhenMarkDownSupported.
@Test
public void testWhenMarkDownSupported() {
ClientPreferences mockCapabilies = mock(ClientPreferences.class);
when(mockCapabilies.isSupportsCompletionDocumentationMarkdown()).thenReturn(Boolean.TRUE);
when(preferenceManager.getClientPreferences()).thenReturn(mockCapabilies);
String raw = "System.out.println(${0});";
Either<String, MarkupContent> result = SnippetUtils.beautifyDocument(raw);
assertNotNull(result);
assertNull(result.getLeft());
assertNotNull(result.getRight());
assertEquals(result.getRight().getValue(), "```java\nSystem.out.println();\n```");
}
use of org.eclipse.lsp4j.MarkupContent in project eclipse.jdt.ls by eclipse.
the class SnippetUtilsTest method testMultipleVariablesInput.
@Test
public void testMultipleVariablesInput() {
ClientPreferences mockCapabilies = mock(ClientPreferences.class);
when(mockCapabilies.isSupportsCompletionDocumentationMarkdown()).thenReturn(Boolean.FALSE);
when(preferenceManager.getClientPreferences()).thenReturn(mockCapabilies);
// @formatter:off
String raw = "for (${1:int} ${2:i} = ${3:0}; ${2:i} < ${4:args.length}; ${2:i}++) {\n" + "\t${0}\n" + "}";
// @formatter:on
Either<String, MarkupContent> result = SnippetUtils.beautifyDocument(raw);
// @formatter:off
String expected = "for (int i = 0; i < args.length; i++) {\n" + "\t\n" + "}";
// @formatter:on
assertEquals(result.getLeft(), expected);
}
use of org.eclipse.lsp4j.MarkupContent in project eclipse.jdt.ls by eclipse.
the class SnippetUtilsTest method testSelectedTextPlaceholder.
@Test
public void testSelectedTextPlaceholder() {
ClientPreferences mockCapabilies = mock(ClientPreferences.class);
when(mockCapabilies.isSupportsCompletionDocumentationMarkdown()).thenReturn(Boolean.FALSE);
when(preferenceManager.getClientPreferences()).thenReturn(mockCapabilies);
// @formatter:off
String raw = "for (${1:int} ${2:i} = ${3:0}; ${2:i} < ${4:args.length}; ${2:i}++) {\n" + "\t$TM_SELECTED_TEXT${0}\n" + "}";
// @formatter:on
Either<String, MarkupContent> result = SnippetUtils.beautifyDocument(raw);
// @formatter:off
String expected = "for (int i = 0; i < args.length; i++) {\n" + "\t\n" + "}";
// @formatter:on
assertEquals(result.getLeft(), expected);
}
use of org.eclipse.lsp4j.MarkupContent in project eclipse.jdt.ls by eclipse.
the class SnippetUtilsTest method testWhenMarkDownNotSupported.
@Test
public void testWhenMarkDownNotSupported() {
ClientPreferences mockCapabilies = mock(ClientPreferences.class);
when(mockCapabilies.isSupportsCompletionDocumentationMarkdown()).thenReturn(Boolean.FALSE);
when(preferenceManager.getClientPreferences()).thenReturn(mockCapabilies);
String raw = "System.out.println(${0});";
Either<String, MarkupContent> result = SnippetUtils.beautifyDocument(raw);
assertNotNull(result);
assertNull(result.getRight());
assertNotNull(result.getLeft());
assertEquals(result.getLeft(), "System.out.println();");
}
Aggregations