Ensure hovers don't have string null in the description part

This commit is contained in:
BoykoAlex
2016-12-12 18:16:05 -05:00
parent d17359ab11
commit 672cc6874f
3 changed files with 26 additions and 2 deletions

View File

@@ -343,6 +343,20 @@ public class Editor {
assertContains(expectSnippet, hover.getContents().toString());
}
/**
* Verifies an expected textSnippet is contained in the hover text that is
* computed when hovering mouse at position at the end of first occurrence of
* a given string in the editor.
*/
public void assertHoverExactText(String afterString, String expectSnippet) throws Exception {
int pos = getRawText().indexOf(afterString);
if (pos>=0) {
pos += afterString.length();
}
Hover hover = harness.getHover(document, document.toPosition(pos));
assertEquals(expectSnippet, hover.getContents().toString());
}
public void assertCompletionDetails(String expectLabel, String expectDetail, String expectDocSnippet) throws Exception {
CompletionItem it = harness.resolveCompletionItem(assertCompletionWithLabel(expectLabel));
if (expectDetail!=null) {

View File

@@ -24,12 +24,14 @@ public class InformationTemplates {
public static Renderable createHover(PropertyInfo info) {
Deprecation deprecation = createDeprecation(info);
return InformationTemplates.createHover(info.getId(), info.getType(), info.getDefaultValue(), text(info.getDescription()), deprecation);
Renderable description = info.getDescription() == null ? null : text(info.getDescription());
return InformationTemplates.createHover(info.getId(), info.getType(), info.getDefaultValue(), description, deprecation);
}
public static Renderable createCompletionDocumentation(PropertyInfo info) {
Deprecation deprecation = createDeprecation(info);
return InformationTemplates.createCompletionDocumentation(text(info.getDescription()), info.getDefaultValue(), deprecation);
Renderable description = info.getDescription() == null ? null : text(info.getDescription());
return InformationTemplates.createCompletionDocumentation(description, info.getDefaultValue(), deprecation);
}
public static Renderable createHover(String id, String type, Object defaultValue, Renderable description, Deprecation deprecation) {

View File

@@ -1577,6 +1577,14 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest {
editor.assertNoHover("ggggg.kkkk");
}
@Test public void testEmptyDescriptionHover() throws Exception {
data("debug", "java.lang.String", null, null);
Editor editor = newEditor(
"debug=something\n"
);
editor.assertHoverExactText("debug", "[**debug** \n[java.lang.String](null)]");
}
@Override
protected SimpleLanguageServer newLanguageServer() {
BootPropertiesLanguageServer server = new BootPropertiesLanguageServer(md.getIndexProvider(), typeUtilProvider, javaProjectFinder);