From 6a9e40dbbb3a02928db66091c9dfdbced7753ce3 Mon Sep 17 00:00:00 2001 From: BoykoAlex Date: Wed, 9 Jan 2019 19:13:59 -0500 Subject: [PATCH] PT #135782951: (Part 1) Completions for deprecated properties --- .../completion/ICompletionProposal.java | 4 +- .../VscodeCompletionEngineAdapter.java | 5 +- .../languageserver/testharness/Editor.java | 14 ++- .../boot/common/AbstractPropertyProposal.java | 5 +- .../boot/common/InformationTemplates.java | 87 +++++++++++-------- .../harness/AbstractPropsEditorTest.java | 20 ++--- .../editor/harness/StyledStringMatcher.java | 74 ---------------- .../test/ApplicationPropertiesEditorTest.java | 37 ++++---- .../boot/test/ApplicationYamlEditorTest.java | 52 ++++++----- 9 files changed, 122 insertions(+), 176 deletions(-) delete mode 100644 headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/editor/harness/StyledStringMatcher.java diff --git a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/ICompletionProposal.java b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/ICompletionProposal.java index 23b759565..3056553b1 100644 --- a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/ICompletionProposal.java +++ b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/ICompletionProposal.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2016-2018 Pivotal, Inc. + * Copyright (c) 2016, 2019 Pivotal, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -40,4 +40,6 @@ public interface ICompletionProposal { default InsertTextFormat getInsertTextFormat() { return InsertTextFormat.Snippet; } + default boolean isDeprecated() { return false; } + } diff --git a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/VscodeCompletionEngineAdapter.java b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/VscodeCompletionEngineAdapter.java index e63321b41..e1526a65b 100644 --- a/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/VscodeCompletionEngineAdapter.java +++ b/headless-services/commons/commons-language-server/src/main/java/org/springframework/ide/vscode/commons/languageserver/completion/VscodeCompletionEngineAdapter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2016, 2018 Pivotal, Inc. + * Copyright (c) 2016, 2019 Pivotal, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -178,6 +178,9 @@ public class VscodeCompletionEngineAdapter implements VscodeCompletionEngine { item.setSortText(sortkeys.next()); item.setFilterText(completion.getFilterText()); item.setDetail(completion.getDetail()); + if (completion.isDeprecated()) { + item.setDeprecated(completion.isDeprecated()); + } resolveEdits(doc, completion, item); //Warning. Its not allowed by LSP spec to resolveEdits //lazy as we used to do in the past. if (resolver!=null) { diff --git a/headless-services/commons/language-server-test-harness/src/main/java/org/springframework/ide/vscode/languageserver/testharness/Editor.java b/headless-services/commons/language-server-test-harness/src/main/java/org/springframework/ide/vscode/languageserver/testharness/Editor.java index 209bd74d0..62eca92c0 100644 --- a/headless-services/commons/language-server-test-harness/src/main/java/org/springframework/ide/vscode/languageserver/testharness/Editor.java +++ b/headless-services/commons/language-server-test-harness/src/main/java/org/springframework/ide/vscode/languageserver/testharness/Editor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2016-2018 Pivotal, Inc. + * Copyright (c) 2016, 2019 Pivotal, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -668,6 +668,18 @@ public class Editor { return it; } + public CompletionItem assertCompletionDetailsWithDeprecation(String expectLabel, String expectDetail, String expectDocSnippet, Boolean deprecated) throws Exception { + CompletionItem it = harness.resolveCompletionItem(assertCompletionWithLabel(expectLabel)); + if (expectDetail!=null) { + assertEquals(expectDetail, it.getDetail()); + } + if (expectDocSnippet!=null) { + assertContains(expectDocSnippet, getDocString(it)); + } + assertEquals(deprecated, it.getDeprecated()); + return it; + } + protected CompletionItem assertCompletionWithLabel(Predicate expectLabel) throws Exception { List completions = getCompletions(); Optional completion = completions.stream() diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/common/AbstractPropertyProposal.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/common/AbstractPropertyProposal.java index a98ebea26..27ee02331 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/common/AbstractPropertyProposal.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/common/AbstractPropertyProposal.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015, 2016 Pivotal, Inc. + * Copyright (c) 2015, 2019 Pivotal, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -72,7 +72,8 @@ public abstract class AbstractPropertyProposal extends ScoreableProposal { // return result; // } - protected boolean isDeprecated() { + @Override + public boolean isDeprecated() { return isDeprecated; } public void deprecate() { diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/common/InformationTemplates.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/common/InformationTemplates.java index 2b028c9e4..ae65f1e06 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/common/InformationTemplates.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/common/InformationTemplates.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2016-2017 Pivotal, Inc. + * Copyright (c) 2016, 2019 Pivotal, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -32,76 +32,87 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList.Builder; public class InformationTemplates { - + + private static final String ARROW = "\u2192"; + public static Renderable createHover(PropertyInfo info) { Deprecation deprecation = createDeprecation(info); 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); Renderable description = info.getDescription() == null ? null : text(info.getDescription()); - return InformationTemplates.createCompletionDocumentation(description, info.getDefaultValue(), deprecation); + return InformationTemplates.createCompletionDocumentation(info.getId(), description, info.getDefaultValue(), deprecation); } - + public static Renderable createHover(String id, String type, Object defaultValue, Renderable description, Deprecation deprecation) { Builder renderableBuilder = ImmutableList.builder(); renderId(renderableBuilder, id, deprecation); - + if (type==null) { type = Object.class.getName(); } renderableBuilder.add(lineBreak()); actionLink(renderableBuilder, type); - + String deflt = formatDefaultValue(defaultValue); if (deflt!=null) { renderableBuilder.add(lineBreak()); renderableBuilder.add(lineBreak()); defaultValueRenderable(renderableBuilder, deflt); } - + if (deprecation != null) { renderableBuilder.add(lineBreak()); renderableBuilder.add(lineBreak()); depreactionRenderable(renderableBuilder, deprecation); } - - if (description!=null) { - renderableBuilder.add(lineBreak()); - descriptionRenderable(renderableBuilder, description); - } - - return concat(renderableBuilder.build()); - } - - public static Renderable createCompletionDocumentation(Renderable description, Object defaultValue, Deprecation deprecation) { - Builder renderableBuilder = ImmutableList.builder(); if (description!=null) { + renderableBuilder.add(lineBreak()); descriptionRenderable(renderableBuilder, description); } - + + return concat(renderableBuilder.build()); + } + + public static Renderable createCompletionDocumentation(String id, Renderable description, Object defaultValue, Deprecation deprecation) { + Builder renderableBuilder = ImmutableList.builder(); + + boolean idInserted = false; + if (deprecation != null && deprecation.getReplacement() != null) { + renderId(renderableBuilder, id, deprecation); + idInserted = true; + } + + if (description!=null) { + if (idInserted) { + renderableBuilder.add(lineBreak()); + } + descriptionRenderable(renderableBuilder, description); + } + String deflt = formatDefaultValue(defaultValue); if (deflt!=null) { - if (description != null) { + if (idInserted || description != null) { renderableBuilder.add(lineBreak()); } defaultValueRenderable(renderableBuilder, deflt); } - + if (deprecation != null) { - if (description != null) { + if (idInserted || description != null) { renderableBuilder.add(lineBreak()); } depreactionRenderable(renderableBuilder, deprecation); - } - - + } + + ImmutableList pieces = renderableBuilder.build(); - + // Special case when there is no description, default value and deprecation data -> return `null` documentation. if (pieces.size() == 1 && pieces.get(0) == Renderables.NO_DESCRIPTION) { pieces = ImmutableList.of(); @@ -109,7 +120,7 @@ public class InformationTemplates { return pieces.isEmpty() ? null : concat(pieces); } - + private static Deprecation createDeprecation(PropertyInfo info) { Deprecation deprecation = null; if (info.isDeprecated()) { @@ -119,7 +130,7 @@ public class InformationTemplates { } return deprecation; } - + private static void renderId(Builder renderableBuilder, String id, Deprecation deprecation) { if (deprecation == null) { renderableBuilder.add(bold(text(id))); @@ -127,11 +138,11 @@ public class InformationTemplates { renderableBuilder.add(strikeThrough(text(id))); String replacement = deprecation.getReplacement(); if (StringUtil.hasText(replacement)) { - renderableBuilder.add(text(" -> " + replacement)); + renderableBuilder.add(text(" " + ARROW + " " + replacement)); } } } - + private static String formatDefaultValue(Object defaultValue) { if (defaultValue!=null) { if (defaultValue instanceof String) { @@ -159,24 +170,24 @@ public class InformationTemplates { private static void actionLink(Builder renderableBuilder, String displayString) { renderableBuilder.add(link(displayString, "null")); } - + private static void defaultValueRenderable(Builder renderableBuilder, String defaultValue) { renderableBuilder.add(text("Default: ")); renderableBuilder.add(italic(text(defaultValue))); } - + private static void depreactionRenderable(Builder renderableBuilder, Deprecation deprecation) { String reason = deprecation.getReason(); if (StringUtil.hasText(reason)) { - renderableBuilder.add(bold(text("Deprecated: "))); - renderableBuilder.add(text(reason)); + renderableBuilder.add(bold(text("Deprecated:"))); + renderableBuilder.add(text(" " + reason)); } else { renderableBuilder.add(bold(text("Deprecated!"))); - } + } } - + private static void descriptionRenderable(Builder renderableBuilder, Renderable description) { renderableBuilder.add(paragraph(description)); } - + } diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/editor/harness/AbstractPropsEditorTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/editor/harness/AbstractPropsEditorTest.java index b9880f572..ad46c243d 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/editor/harness/AbstractPropsEditorTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/editor/harness/AbstractPropsEditorTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2017 Pivotal, Inc. + * Copyright (c) 2017, 2019 Pivotal, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -119,6 +119,11 @@ public abstract class AbstractPropsEditorTest { editor.assertCompletionDetails(expectLabel, expectDetail, expectDocumenation); } + public void assertCompletionDetailsWithDeprecation(String editorText, String expectLabel, String expectDetail, String expectDocumenation, Boolean deprecated) throws Exception { + Editor editor = newEditor(editorText); + editor.assertCompletionDetailsWithDeprecation(expectLabel, expectDetail, expectDocumenation, deprecated); + } + public boolean isEmptyMetadata() { return md.isEmpty(); } @@ -247,19 +252,6 @@ public abstract class AbstractPropsEditorTest { } } - public void assertStyledCompletions(String editorText, StyledStringMatcher... expectStyles) throws Exception { - Editor editor = newEditor(editorText); - List completions = editor.getCompletions(); - assertEquals("Wrong number of elements", expectStyles.length, completions.size()); - for (int i = 0; i < expectStyles.length; i++) { - CompletionItem completion = completions.get(i); - throw new UnsupportedOperationException("Suport for styled labels not implemented"); -// StyledString actualLabel = getStyledDisplayString(completion); -// expectStyles[i].match(actualLabel); - } - } - - public void deprecate(String key, String replacedBy, String reason) { md.deprecate(key, replacedBy, reason); } diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/editor/harness/StyledStringMatcher.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/editor/harness/StyledStringMatcher.java deleted file mode 100644 index d3d11b22f..000000000 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/editor/harness/StyledStringMatcher.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 Pivotal, Inc. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * Pivotal, Inc. - initial API and implementation - *******************************************************************************/ -package org.springframework.ide.vscode.boot.editor.harness; - -//import org.eclipse.jface.viewers.StyledString; -//import org.eclipse.swt.custom.StyleRange; - -public abstract class StyledStringMatcher { - -// public abstract void match(StyledString styledString) throws Exception; - - /** - * Creates a matcher that matches a given {@link StyledString} if a given String - * equals the concatenation of all the text in the {@link StyledString} formatted - * in 'plain' font (currently 'plain' just means that it is not using 'strikeout' - * as that is the only other style we currently care about). - */ - public static StyledStringMatcher plainFont(final String string) { - throw new UnsupportedOperationException("Not yet implemented"); -// return new StyledStringMatcher() { -// @Override -// public String toString() { -// return "plain("+string+")"; -// } -// -// @Override -// public void match(StyledString styledString) throws Exception { -// StringBuilder extractedText = new StringBuilder(); -// String string = styledString.getString(); -// for (StyleRange styleRange : styledString.getStyleRanges()) { -// if (!styleRange.strikeout) { -// extractedText.append(string.substring(styleRange.start, styleRange.start + styleRange.length)); -// } -// } -// assertEquals(string, extractedText.toString()); -// } -// }; - } - - /** - * Creates a matcher that matches a given {@link StyledString} if a given String - * equals the concatenation of all the text in the {@link StyledString} formatted - * in 'strikeout' font. - */ - public static StyledStringMatcher strikeout(final String expectedString) { - throw new UnsupportedOperationException("Not yet implemented"); -// return new StyledStringMatcher() { -// @Override -// public String toString() { -// return "strikeout("+expectedString+")"; -// } -// @Override -// public void match(StyledString styledString) throws Exception { -// StringBuilder extractedText = new StringBuilder(); -// String unstyledString = styledString.getString(); -// for (StyleRange styleRange : styledString.getStyleRanges()) { -// if (styleRange.strikeout) { -// extractedText.append(unstyledString.substring(styleRange.start, styleRange.start + styleRange.length)); -// } -// } -// assertEquals(expectedString, extractedText.toString()); -// } -// }; - } - -} diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationPropertiesEditorTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationPropertiesEditorTest.java index 940a853d3..7e668de8f 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationPropertiesEditorTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationPropertiesEditorTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2016, 2018 Pivotal, Inc. + * Copyright (c) 2016, 2019 Pivotal, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -10,7 +10,6 @@ *******************************************************************************/ package org.springframework.ide.vscode.boot.test; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.springframework.ide.vscode.boot.properties.reconcile.ApplicationPropertiesProblemType.PROP_DUPLICATE_KEY; @@ -37,7 +36,6 @@ import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest; import org.springframework.ide.vscode.boot.bootiful.PropertyEditorTestConf; import org.springframework.ide.vscode.boot.editor.harness.AbstractPropsEditorTest; import org.springframework.ide.vscode.boot.editor.harness.AdHocPropertyHarness; -import org.springframework.ide.vscode.boot.editor.harness.StyledStringMatcher; import org.springframework.ide.vscode.boot.metadata.CachingValueProvider; import org.springframework.ide.vscode.boot.metadata.PropertiesLoader; import org.springframework.ide.vscode.commons.java.IJavaProject; @@ -957,19 +955,24 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest { } - @Ignore @Test public void testDeprecatedPropertyCompletion() throws Exception { + @Test public void testDeprecatedPropertyCompletion() throws Exception { data("error.path", "java.lang.String", null, "Path of the error controller."); data("server.error.path", "java.lang.String", null, "Path of the error controller."); deprecate("error.path", "server.error.path", "This is old."); assertCompletionsDisplayString("error.pa<*>", + true, "server.error.path : String", // should be first because it is not deprecated, even though it is not as good a pattern match "error.path : String" ); //TODO: could we check that 'deprecated' completions are formatted with 'strikethrough font? - assertStyledCompletions("error.pa<*>", - StyledStringMatcher.plainFont("server.error.path : String"), - StyledStringMatcher.strikeout("error.path") - ); + assertCompletionDetailsWithDeprecation("error.pa<*>", "server.error.path", "String", null, null); + assertCompletionDetailsWithDeprecation("error.pa<*>", "error.path", "String", + "~~error.path~~ \u2192 server.error.path \n" + + "\n" + + "Path of the error controller.\n" + + "\n" + + "**Deprecated:** This is old", + Boolean.TRUE); } @Test public void testDeprecatedPropertyHoverInfo() throws Exception { @@ -980,15 +983,15 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest { ); deprecate("error.path", "server.error.path", null); - editor.assertHoverText("path", "~~error.path~~ -> server.error.path"); + editor.assertHoverText("path", "~~error.path~~ \u2192 server.error.path"); editor.assertHoverText("path", "**Deprecated!**"); deprecate("error.path", "server.error.path", "This is old."); - editor.assertHoverText("path", "~~error.path~~ -> server.error.path"); - editor.assertHoverText("path", "**Deprecated: **This is old"); + editor.assertHoverText("path", "~~error.path~~ \u2192 server.error.path"); + editor.assertHoverText("path", "**Deprecated:** This is old"); deprecate("error.path", null, "This is old."); - editor.assertHoverText("path", "**Deprecated: **This is old"); + editor.assertHoverText("path", "**Deprecated:** This is old"); deprecate("error.path", null, null); editor.assertHoverText("path", "**Deprecated!**"); @@ -1029,16 +1032,14 @@ public class ApplicationPropertiesEditorTest extends AbstractPropsEditorTest { ); } - @Ignore @Test public void testDeprecatedBeanPropertyCompletions() throws Exception { + @Test public void testDeprecatedBeanPropertyCompletions() throws Exception { IJavaProject p = createPredefinedMavenProject("tricky-getters-boot-1.3.1-app"); useProject(p); data("foo", "demo.Deprecater", null, "A Bean with deprecated properties"); - assertStyledCompletions("foo.nam<*>", - StyledStringMatcher.plainFont("new-name : String"), - StyledStringMatcher.strikeout("name"), - StyledStringMatcher.strikeout("alt-name") - ); + assertCompletionDetailsWithDeprecation("foo.nam<*>", "new-name", "String", null, null); + assertCompletionDetailsWithDeprecation("foo.nam<*>", "name", "String", null, Boolean.TRUE); + assertCompletionDetailsWithDeprecation("foo.nam<*>", "alt-name", "String", null, Boolean.TRUE); } @Test public void testCharsetCompletions() throws Exception { diff --git a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationYamlEditorTest.java b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationYamlEditorTest.java index dd2367175..4def55f18 100644 --- a/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationYamlEditorTest.java +++ b/headless-services/spring-boot-language-server/src/test/java/org/springframework/ide/vscode/boot/test/ApplicationYamlEditorTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2016, 2018 Pivotal, Inc. + * Copyright (c) 2016, 2019 Pivotal, Inc. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -32,7 +32,6 @@ import org.springframework.context.annotation.Import; import org.springframework.ide.vscode.boot.bootiful.BootLanguageServerTest; import org.springframework.ide.vscode.boot.bootiful.PropertyEditorTestConf; import org.springframework.ide.vscode.boot.editor.harness.AbstractPropsEditorTest; -import org.springframework.ide.vscode.boot.editor.harness.StyledStringMatcher; import org.springframework.ide.vscode.boot.metadata.CachingValueProvider; import org.springframework.ide.vscode.boot.metadata.PropertyInfo; import org.springframework.ide.vscode.commons.java.IJavaProject; @@ -2669,23 +2668,27 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest { ); } - @Ignore @Test public void testDeprecatedPropertyCompletion() throws Exception { + @Test public void testDeprecatedPropertyCompletion() throws Exception { data("error.path", "java.lang.String", null, "Path of the error controller."); data("server.error.path", "java.lang.String", null, "Path of the error controller."); deprecate("error.path", "server.error.path", "This is old."); assertCompletionsDisplayString( - "errorpa<*>" - , // => + "errorpa<*>", + true, // => "server.error.path : String", // should be first because it is not deprecated, even though it is not as good a pattern match "error.path : String" ); - assertStyledCompletions("error.pa<*>", - StyledStringMatcher.plainFont("server.error.path : String"), - StyledStringMatcher.strikeout("error.path") - ); + assertCompletionDetailsWithDeprecation("error.pa<*>", "server.error.path", "String", null, null); + assertCompletionDetailsWithDeprecation("error.pa<*>", "error.path", "String", + "~~error.path~~ \u2192 server.error.path \n" + + "\n" + + "Path of the error controller.\n" + + "\n" + + "**Deprecated:** This is old", + Boolean.TRUE); } - @Ignore @Test public void testDeprecatedPropertyHoverInfo() throws Exception { + @Test public void testDeprecatedPropertyHoverInfo() throws Exception { data("error.path", "java.lang.String", null, "Path of the error controller."); Editor editor = newEditor( "# a comment\n"+ @@ -2694,21 +2697,21 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest { ); deprecate("error.path", "server.error.path", null); - editor.assertHoverContains("path", "error.path -> server.error.path"); - editor.assertHoverContains("path", "Deprecated!"); + editor.assertHoverContains("path", "~~error.path~~ \u2192 server.error.path"); + editor.assertHoverContains("path", "**Deprecated!**"); deprecate("error.path", "server.error.path", "This is old."); - editor.assertHoverContains("path", "error.path -> server.error.path"); - editor.assertHoverContains("path", "Deprecated: This is old"); + editor.assertHoverContains("path", "~~error.path~~ \u2192 server.error.path"); + editor.assertHoverContains("path", "**Deprecated:** This is old"); deprecate("error.path", null, "This is old."); - editor.assertHoverContains("path", "Deprecated: This is old"); + editor.assertHoverContains("path", "**Deprecated:** This is old"); deprecate("error.path", null, null); - editor.assertHoverContains("path", "Deprecated!"); + editor.assertHoverContains("path", "**Deprecated!**"); } - @Ignore @Test public void testDeprecatedBeanPropertyHoverInfo() throws Exception { + @Test public void testDeprecatedBeanPropertyHoverInfo() throws Exception { IJavaProject jp = createPredefinedMavenProject("tricky-getters-boot-1.3.1-app"); useProject(jp); data("foo", "demo.Deprecater", null, "A bean with deprecated property."); @@ -2718,7 +2721,7 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest { " name: foo\n" ); - editor.assertHoverContains("name", "Deprecated!"); + editor.assertHoverContains("name", "**Deprecated!**"); } @Test public void testDeprecatedBeanPropertyReconcile() throws Exception { @@ -2754,19 +2757,14 @@ public class ApplicationYamlEditorTest extends AbstractPropsEditorTest { } - @Ignore @Test public void testDeprecatedBeanPropertyCompletions() throws Exception { + @Test public void testDeprecatedBeanPropertyCompletions() throws Exception { IJavaProject jp = createPredefinedMavenProject("tricky-getters-boot-1.3.1-app"); useProject(jp); data("foo", "demo.Deprecater", null, "A Bean with deprecated properties"); - assertStyledCompletions( - "foo:\n" + - " nam<*>" - , // => - StyledStringMatcher.plainFont("new-name : String"), - StyledStringMatcher.strikeout("name"), - StyledStringMatcher.strikeout("alt-name") - ); + assertCompletionDetailsWithDeprecation("foo:\n nam<*>", "new-name", "String", null, null); + assertCompletionDetailsWithDeprecation("foo:\n nam<*>", "name", "String", null, Boolean.TRUE); + assertCompletionDetailsWithDeprecation("foo:\n nam<*>", "alt-name", "String", null, Boolean.TRUE); } @Ignore @Test public void testDeprecatedPropertyQuickfixSimple() throws Exception {