From 66a9aa8fe35922ad322e24471c368b90c4da2518 Mon Sep 17 00:00:00 2001 From: BoykoAlex Date: Thu, 7 Jun 2018 16:50:28 -0400 Subject: [PATCH] PT #156686000: Fix additional cases with javadoc doc for property keys --- .../ide/vscode/commons/jandex/BindingKeyUtils.java | 2 +- .../ide/vscode/commons/util/Renderables.java | 6 ++++++ .../ide/vscode/boot/metadata/hints/StsValueHint.java | 2 +- .../ide/vscode/boot/metadata/types/TypeUtil.java | 9 +++++++-- .../ide/vscode/boot/metadata/util/PropertyDocUtils.java | 4 ++-- .../yaml/completions/ApplicationYamlAssistContext.java | 8 ++++++-- 6 files changed, 23 insertions(+), 8 deletions(-) diff --git a/headless-services/commons/commons-java/src/main/java/org/springframework/ide/vscode/commons/jandex/BindingKeyUtils.java b/headless-services/commons/commons-java/src/main/java/org/springframework/ide/vscode/commons/jandex/BindingKeyUtils.java index 845539cff..0ae8e6096 100644 --- a/headless-services/commons/commons-java/src/main/java/org/springframework/ide/vscode/commons/jandex/BindingKeyUtils.java +++ b/headless-services/commons/commons-java/src/main/java/org/springframework/ide/vscode/commons/jandex/BindingKeyUtils.java @@ -59,7 +59,7 @@ class BindingKeyUtils { } sb.append(')'); sb.append(getGeneralTypeBindingKey(method.returnType())); - return method.name().toString(); + return sb.toString(); } public static String getGeneralTypeBindingKey(Type type) { diff --git a/headless-services/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/Renderables.java b/headless-services/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/Renderables.java index 19eed5258..f4be49563 100644 --- a/headless-services/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/Renderables.java +++ b/headless-services/commons/commons-util/src/main/java/org/springframework/ide/vscode/commons/util/Renderables.java @@ -142,6 +142,12 @@ public class Renderables { // The correct implementation should probably check wether text in buffer already // ends with newline(s) and add more only if needed. Then it should // also append double newline at its end. + + //TODO: verify that the if below solves the above "todo" + if (buffer.length() > 0 && buffer.charAt(buffer.length() - 1) != '\n') { + // 2 spaces and then new line would create a line break in text + buffer.append(" "); + } buffer.append("\n"); text.renderAsMarkdown(buffer); buffer.append("\n"); diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/metadata/hints/StsValueHint.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/metadata/hints/StsValueHint.java index fc16269c7..5d01a2086 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/metadata/hints/StsValueHint.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/metadata/hints/StsValueHint.java @@ -124,7 +124,7 @@ public class StsValueHint { private static Renderable javaDocSnippet(IJavaProject project, IJavaElement je) { return Renderables.lazy(() -> { SourceLinks sourceLinks = SourceLinkFactory.createSourceLinks(null); - return PropertyDocUtils.documentJavaValue(sourceLinks, project, je); + return PropertyDocUtils.documentJavaElement(sourceLinks, project, je); }); } diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/metadata/types/TypeUtil.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/metadata/types/TypeUtil.java index 5d5cabb56..395f3a5af 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/metadata/types/TypeUtil.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/metadata/types/TypeUtil.java @@ -35,10 +35,13 @@ import java.util.stream.Stream; import javax.inject.Provider; import org.springframework.ide.vscode.boot.configurationmetadata.Deprecation; +import org.springframework.ide.vscode.boot.java.links.SourceLinkFactory; +import org.springframework.ide.vscode.boot.java.links.SourceLinks; import org.springframework.ide.vscode.boot.metadata.ResourceHintProvider; import org.springframework.ide.vscode.boot.metadata.ValueProviderRegistry.ValueProviderStrategy; import org.springframework.ide.vscode.boot.metadata.hints.StsValueHint; import org.springframework.ide.vscode.boot.metadata.util.DeprecationUtil; +import org.springframework.ide.vscode.boot.metadata.util.PropertyDocUtils; import org.springframework.ide.vscode.commons.java.Flags; import org.springframework.ide.vscode.commons.java.IField; import org.springframework.ide.vscode.commons.java.IJavaElement; @@ -638,6 +641,8 @@ public class TypeUtil { //TODO: handle type parameters. if (typeFromIndex != null) { + SourceLinks sourceLinks = SourceLinkFactory.createSourceLinks(null); + IJavaProject project = getJavaProject(); ArrayList properties = new ArrayList<>(); getGetterMethods(typeFromIndex).forEach(m -> { Deprecation deprecation = DeprecationUtil.extract(m); @@ -649,11 +654,11 @@ public class TypeUtil { } if (beanMode.includesHyphenated()) { properties.add(new TypedProperty(getterOrSetterNameToProperty(m.getElementName()), propType, - deprecation)); + PropertyDocUtils.documentJavaElement(sourceLinks, project, m), deprecation)); } if (beanMode.includesCamelCase()) { properties.add(new TypedProperty(getterOrSetterNameToCamelName(m.getElementName()), propType, - deprecation)); + PropertyDocUtils.documentJavaElement(sourceLinks, project, m), deprecation)); } }); return properties; diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/metadata/util/PropertyDocUtils.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/metadata/util/PropertyDocUtils.java index 5e65fbde3..65b8c0a56 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/metadata/util/PropertyDocUtils.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/metadata/util/PropertyDocUtils.java @@ -41,7 +41,7 @@ public class PropertyDocUtils { * @param je * @return */ - public static Renderable documentation(SourceLinks sourceLinks, IJavaProject project, IJavaElement je) { + public static Renderable javadocContent(SourceLinks sourceLinks, IJavaProject project, IJavaElement je) { Builder renderableBuilder = ImmutableList.builder(); IJavadoc javadoc = je.getJavaDoc(); renderableBuilder.add(Renderables.lineBreak()); @@ -57,7 +57,7 @@ public class PropertyDocUtils { * @param je * @return */ - public static Renderable documentJavaValue(SourceLinks sourceLinks, IJavaProject project, IJavaElement je) { + public static Renderable documentJavaElement(SourceLinks sourceLinks, IJavaProject project, IJavaElement je) { Builder renderableBuilder = ImmutableList.builder(); if (je instanceof IMember) { IMember member = (IMember) je; diff --git a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/yaml/completions/ApplicationYamlAssistContext.java b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/yaml/completions/ApplicationYamlAssistContext.java index 9789f32f7..8bb37414a 100644 --- a/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/yaml/completions/ApplicationYamlAssistContext.java +++ b/headless-services/spring-boot-language-server/src/main/java/org/springframework/ide/vscode/boot/yaml/completions/ApplicationYamlAssistContext.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2015, 2016 Pivotal, Inc. + * Copyright (c) 2015, 2018 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 @@ -27,6 +27,7 @@ import org.springframework.ide.vscode.boot.common.PropertyCompletionFactory; import org.springframework.ide.vscode.boot.common.RelaxedNameConfig; import org.springframework.ide.vscode.boot.configurationmetadata.Deprecation; import org.springframework.ide.vscode.boot.java.links.SourceLinkFactory; +import org.springframework.ide.vscode.boot.java.links.SourceLinks; import org.springframework.ide.vscode.boot.metadata.IndexNavigator; import org.springframework.ide.vscode.boot.metadata.PropertyInfo; import org.springframework.ide.vscode.boot.metadata.hints.HintProvider; @@ -41,6 +42,7 @@ import org.springframework.ide.vscode.boot.metadata.types.TypedProperty; import org.springframework.ide.vscode.boot.metadata.util.PropertyDocUtils; import org.springframework.ide.vscode.commons.java.IField; import org.springframework.ide.vscode.commons.java.IJavaElement; +import org.springframework.ide.vscode.commons.java.IJavaProject; import org.springframework.ide.vscode.commons.java.IMember; import org.springframework.ide.vscode.commons.languageserver.completion.DocumentEdits; import org.springframework.ide.vscode.commons.languageserver.completion.ICompletionProposal; @@ -549,7 +551,9 @@ public abstract class ApplicationYamlAssistContext extends AbstractYamlAssistCon if (jes != null) { for (IJavaElement je : jes) { if (je instanceof IMember) { - return PropertyDocUtils.documentation(SourceLinkFactory.createSourceLinks(null), typeUtil.getJavaProject(), je); + SourceLinks sourceLinks = SourceLinkFactory.createSourceLinks(null); + IJavaProject project = typeUtil.getJavaProject(); + return PropertyDocUtils.documentJavaElement(sourceLinks, project, je); } } }