HoverInfo -> Renderable refactoring

This commit is contained in:
BoykoAlex
2016-11-21 16:49:08 -05:00
parent b33f34e288
commit f19a4e0bfa
19 changed files with 133 additions and 128 deletions

View File

@@ -7,13 +7,16 @@ import org.springframework.ide.vscode.application.properties.metadata.util.Depre
import org.springframework.ide.vscode.commons.java.IJavaElement;
import org.springframework.ide.vscode.commons.java.IJavaProject;
import org.springframework.ide.vscode.commons.java.IType;
import org.springframework.ide.vscode.commons.languageserver.hover.HoverInfo;
import org.springframework.ide.vscode.commons.util.Assert;
import org.springframework.ide.vscode.commons.util.HtmlBuffer;
import org.springframework.ide.vscode.commons.util.HtmlSnippet;
import org.springframework.ide.vscode.commons.util.Log;
import org.springframework.ide.vscode.commons.util.Renderable;
import org.springframework.ide.vscode.commons.util.Renderables;
import org.springframework.ide.vscode.commons.util.StringUtil;
import org.springframework.ide.vscode.commons.yaml.util.DescriptionProviders;
import com.google.common.base.Supplier;
import com.google.common.base.Suppliers;
/**
* Sts version of {@link ValueHint} contains similar data, but accomoates
@@ -29,7 +32,7 @@ public class StsValueHint {
private final String value;
private final HoverInfo description;
private final Renderable description;
private final Deprecation deprecation;
/**
@@ -38,7 +41,7 @@ public class StsValueHint {
* This constructor is private. Use one of the provided
* static 'create' methods instead.
*/
private StsValueHint(String value, HoverInfo description, Deprecation deprecation) {
private StsValueHint(String value, Renderable description, Deprecation deprecation) {
this.value = value==null?"null":value.toString();
Assert.isLegal(!this.value.startsWith("StsValueHint"));
this.description = description;
@@ -58,7 +61,7 @@ public class StsValueHint {
}
public static StsValueHint create(String value) {
return new StsValueHint(value, DescriptionProviders.NO_DESCRIPTION, null);
return new StsValueHint(value, Renderables.NO_DESCRIPTION, null);
}
public static StsValueHint create(ValueHint hint) {
@@ -92,46 +95,46 @@ public class StsValueHint {
/**
* Create a html snippet from a text snippet.
*/
private static HoverInfo textSnippet(String description) {
private static Renderable textSnippet(String description) {
if (StringUtil.hasText(description)) {
return DescriptionProviders.text(description);
return Renderables.text(description);
}
return DescriptionProviders.NO_DESCRIPTION;
return Renderables.NO_DESCRIPTION;
}
public String getValue() {
return value;
}
public HoverInfo getDescription() {
public Renderable getDescription() {
return description;
}
public HoverInfo getDescriptionProvider() {
public Renderable getDescriptionProvider() {
return description;
}
public static HoverInfo javaDocSnippet(IJavaElement je) {
private static Renderable javaDocSnippet(IJavaElement je) {
try {
HtmlSnippet jdoc = je.getJavaDoc();
Supplier<HtmlSnippet> jdoc = Suppliers.memoize(() -> je.getJavaDoc());
if (jdoc != null) {
return new HoverInfo() {
return new Renderable() {
@Override
public void renderAsMarkdown(StringBuilder buffer) {
// TODO not correct md
buffer.append(jdoc.toString());
buffer.append(jdoc.get().toString());
}
@Override
public void renderAsHtml(HtmlBuffer buffer) {
buffer.raw(jdoc.toHtml());
buffer.raw(jdoc.get().toHtml());
}
};
}
} catch (Exception e) {
Log.log(e);
}
return DescriptionProviders.NO_DESCRIPTION;
return Renderables.NO_DESCRIPTION;
}
@Override

View File

@@ -1,11 +1,9 @@
package org.springframework.ide.vscode.application.properties.metadata.types;
import javax.inject.Provider;
import org.springframework.boot.configurationmetadata.Deprecation;
import org.springframework.ide.vscode.commons.languageserver.hover.HoverInfo;
import org.springframework.ide.vscode.commons.util.Renderable;
import org.springframework.ide.vscode.commons.util.Renderables;
import org.springframework.ide.vscode.commons.yaml.schema.YTypedProperty;
import org.springframework.ide.vscode.commons.yaml.util.DescriptionProviders;
/**
* Represents a property on a Type that can be accessed by name.
@@ -27,15 +25,15 @@ public class TypedProperty implements YTypedProperty {
/**
* Provides a description for this property.
*/
private final HoverInfo descriptionProvider;
private final Renderable descriptionProvider;
private final Deprecation deprecation;
public TypedProperty(String name, Type type, Deprecation deprecation) {
this(name, type, DescriptionProviders.NO_DESCRIPTION, deprecation);
this(name, type, Renderables.NO_DESCRIPTION, deprecation);
}
public TypedProperty(String name, Type type, HoverInfo descriptionProvider, Deprecation deprecation) {
public TypedProperty(String name, Type type, Renderable descriptionProvider, Deprecation deprecation) {
this.name = name;
this.type = type;
this.descriptionProvider = descriptionProvider;
@@ -56,7 +54,7 @@ public class TypedProperty implements YTypedProperty {
}
@Override
public HoverInfo getDescription() {
public Renderable getDescription() {
//TODO: real implementation that somehow gets this from somewhere (i.e. the JavaDoc)
// Note that presently the application.yml and application.properties editor do not actually
// use this description provider but produce hover infos in a different way (so this is only

View File

@@ -12,11 +12,12 @@ package org.springframework.ide.vscode.commons.languageserver.hover;
import org.springframework.ide.vscode.commons.languageserver.util.IDocument;
import org.springframework.ide.vscode.commons.languageserver.util.IRegion;
import org.springframework.ide.vscode.commons.util.Renderable;
import reactor.util.function.Tuple2;
public interface HoverInfoProvider {
Tuple2<HoverInfo, IRegion> getHoverInfo(IDocument document, int offset) throws Exception;
Tuple2<Renderable, IRegion> getHoverInfo(IDocument document, int offset) throws Exception;
}

View File

@@ -23,6 +23,7 @@ import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguage
import org.springframework.ide.vscode.commons.languageserver.util.SimpleTextDocumentService;
import org.springframework.ide.vscode.commons.languageserver.util.TextDocument;
import org.springframework.ide.vscode.commons.util.Futures;
import org.springframework.ide.vscode.commons.util.Renderable;
import reactor.util.function.Tuple2;
@@ -49,9 +50,9 @@ public class VscodeHoverEngineAdapter implements VscodeHoverEngine {
if (doc!=null) {
int offset = doc.toOffset(params.getPosition());
Tuple2<HoverInfo, IRegion> hoverTuple = hoverInfoProvider.getHoverInfo(doc, offset);
Tuple2<Renderable, IRegion> hoverTuple = hoverInfoProvider.getHoverInfo(doc, offset);
if (hoverTuple != null) {
HoverInfo hoverInfo = hoverTuple.getT1();
Renderable hoverInfo = hoverTuple.getT1();
IRegion region = hoverTuple.getT2();
Range range = doc.toRange(region.getOffset(), region.getLength());

View File

@@ -21,6 +21,12 @@
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
<!-- HTM -> Markdown converter -->
<dependency>
<groupId>com.kotcrab.remark</groupId>
<artifactId>remark</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</project>

View File

@@ -113,10 +113,6 @@ public class HtmlBuffer {
raw("</p>");
}
public void snippet(HtmlSnippet snippet) {
snippet.render(this);
}
public void bold(String string) {
raw("<b>");
text(string);

View File

@@ -8,7 +8,7 @@
* Contributors:
* Pivotal Software, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.vscode.commons.yaml.util;
package org.springframework.ide.vscode.commons.util;
import java.io.BufferedOutputStream;
import java.io.ByteArrayOutputStream;

View File

@@ -8,15 +8,13 @@
* Contributors:
* Pivotal, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.vscode.commons.languageserver.hover;
import org.springframework.ide.vscode.commons.util.HtmlBuffer;
package org.springframework.ide.vscode.commons.util;
/**
* Placeholder. Still need to figure out what exactly we should do with this in
* vscode. TODO: rename to Renderable
*/
public interface HoverInfo {
public interface Renderable {
void renderAsHtml(HtmlBuffer buffer);

View File

@@ -8,20 +8,16 @@
* Contributors:
* Pivotal, Inc. - initial API and implementation
*******************************************************************************/
package org.springframework.ide.vscode.commons.yaml.util;
package org.springframework.ide.vscode.commons.util;
import java.io.InputStream;
import java.util.List;
import javax.inject.Provider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ide.vscode.commons.languageserver.hover.HoverInfo;
import org.springframework.ide.vscode.commons.util.HtmlBuffer;
import org.springframework.ide.vscode.commons.util.HtmlSnippet;
import com.google.common.collect.ImmutableList;
import com.overzealous.remark.Remark;
/**
* Static methods and convenience constants for creating some 'description
@@ -29,44 +25,50 @@ import com.google.common.collect.ImmutableList;
*
* @author Kris De Volder
*/
public class DescriptionProviders {
public class Renderables {
private static final String NO_DESCRIPTION_TEXT = "no description";
final static Logger logger = LoggerFactory.getLogger(DescriptionProviders.class);
final static Logger logger = LoggerFactory.getLogger(Renderables.class);
public static final HoverInfo NO_DESCRIPTION = italic(text(NO_DESCRIPTION_TEXT));
public static Provider<HtmlSnippet> snippet(final HtmlSnippet snippet) {
return new Provider<HtmlSnippet>() {
@Override
public String toString() {
return snippet.toString();
}
@Override
public HtmlSnippet get() {
return snippet;
}
};
public static final Renderable NO_DESCRIPTION = italic(text(NO_DESCRIPTION_TEXT));
private static Remark getHtmlToMarkdownConverter() {
return new Remark();
}
public static HoverInfo concat(HoverInfo... pieces) {
public static Renderable htmlBlob(String html) {
return new Renderable() {
@Override
public void renderAsHtml(HtmlBuffer buffer) {
buffer.raw(html);
}
@Override
public void renderAsMarkdown(StringBuilder buffer) {
buffer.append(getHtmlToMarkdownConverter().convert(html));
}
};
}
public static Renderable concat(Renderable... pieces) {
return concat(ImmutableList.copyOf(pieces));
}
public static HoverInfo concat(List<HoverInfo> pieces) {
public static Renderable concat(List<Renderable> pieces) {
if (pieces == null || pieces.size() == 0) {
throw new IllegalArgumentException("At least one hover information is required for concat");
} else if (pieces.size() == 1) {
return pieces.get(0);
} else {
return new ConcatHoverInfo(pieces);
return new ConcatRenderables(pieces);
}
}
public static HoverInfo italic(HoverInfo text) {
return new HoverInfo() {
public static Renderable italic(Renderable text) {
return new Renderable() {
@Override
public void renderAsMarkdown(StringBuilder buffer) {
@@ -84,8 +86,8 @@ public class DescriptionProviders {
};
}
public static HoverInfo link(String text, String url) {
return new HoverInfo() {
public static Renderable link(String text, String url) {
return new Renderable() {
@Override
public void renderAsMarkdown(StringBuilder buffer) {
@@ -110,8 +112,8 @@ public class DescriptionProviders {
};
}
public static HoverInfo lineBreak() {
return new HoverInfo() {
public static Renderable lineBreak() {
return new Renderable() {
@Override
public void renderAsMarkdown(StringBuilder buffer) {
@@ -125,9 +127,9 @@ public class DescriptionProviders {
};
}
public static HoverInfo bold(HoverInfo text) {
public static Renderable bold(Renderable text) {
return new HoverInfo() {
return new Renderable() {
@Override
public void renderAsMarkdown(StringBuilder buffer) {
@@ -145,8 +147,8 @@ public class DescriptionProviders {
};
}
public static HoverInfo text(String text) {
return new HoverInfo() {
public static Renderable text(String text) {
return new Renderable() {
@Override
public void renderAsMarkdown(StringBuilder buffer) {
// TODO: handle escaping
@@ -160,8 +162,8 @@ public class DescriptionProviders {
};
}
public static HoverInfo fromClasspath(final Class<?> klass, final String resourcePath) {
return new HoverInfo() {
public static Renderable fromClasspath(final Class<?> klass, final String resourcePath) {
return new Renderable() {
@Override
public void renderAsMarkdown(StringBuilder buffer) {
@@ -199,28 +201,28 @@ public class DescriptionProviders {
};
}
private static class ConcatHoverInfo implements HoverInfo {
private static class ConcatRenderables implements Renderable {
private HoverInfo[] pieces;
private Renderable[] pieces;
ConcatHoverInfo(HoverInfo[] pieces) {
ConcatRenderables(Renderable[] pieces) {
this.pieces = pieces;
}
public ConcatHoverInfo(List<HoverInfo> pieces) {
this(pieces.toArray(new HoverInfo[pieces.size()]));
public ConcatRenderables(List<Renderable> pieces) {
this(pieces.toArray(new Renderable[pieces.size()]));
}
@Override
public void renderAsHtml(HtmlBuffer buffer) {
for (HoverInfo hoverInfo : pieces) {
for (Renderable hoverInfo : pieces) {
hoverInfo.renderAsHtml(buffer);
}
}
@Override
public void renderAsMarkdown(StringBuilder buffer) {
for (HoverInfo hoverInfo : pieces) {
for (Renderable hoverInfo : pieces) {
hoverInfo.renderAsMarkdown(buffer);
}
}

View File

@@ -14,8 +14,8 @@ import java.util.Collection;
import java.util.Collections;
import org.springframework.ide.vscode.commons.languageserver.completion.ICompletionProposal;
import org.springframework.ide.vscode.commons.languageserver.hover.HoverInfo;
import org.springframework.ide.vscode.commons.languageserver.util.DocumentRegion;
import org.springframework.ide.vscode.commons.util.Renderable;
import org.springframework.ide.vscode.commons.yaml.path.YamlPathSegment;
import org.springframework.ide.vscode.commons.yaml.structure.YamlDocument;
import org.springframework.ide.vscode.commons.yaml.structure.YamlStructureParser.SNode;
@@ -52,17 +52,17 @@ public abstract class TopLevelAssistContext implements YamlAssistContext {
}
@Override
public HoverInfo getHoverInfo() {
public Renderable getHoverInfo() {
return null;
}
@Override
public HoverInfo getHoverInfo(YamlPathSegment lastSegment) {
public Renderable getHoverInfo(YamlPathSegment lastSegment) {
return null;
}
@Override
public HoverInfo getValueHoverInfo(YamlDocument doc, DocumentRegion documentRegion) {
public Renderable getValueHoverInfo(YamlDocument doc, DocumentRegion documentRegion) {
return null;
}

View File

@@ -22,10 +22,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.ide.vscode.commons.languageserver.completion.DocumentEdits;
import org.springframework.ide.vscode.commons.languageserver.completion.ICompletionProposal;
import org.springframework.ide.vscode.commons.languageserver.hover.HoverInfo;
import org.springframework.ide.vscode.commons.languageserver.util.DocumentRegion;
import org.springframework.ide.vscode.commons.util.CollectionUtil;
import org.springframework.ide.vscode.commons.util.FuzzyMatcher;
import org.springframework.ide.vscode.commons.util.Renderable;
import org.springframework.ide.vscode.commons.yaml.hover.YPropertyHoverInfo;
import org.springframework.ide.vscode.commons.yaml.path.YamlPath;
import org.springframework.ide.vscode.commons.yaml.path.YamlPathSegment;
@@ -219,7 +219,7 @@ public class YTypeAssistContext extends AbstractYamlAssistContext {
@Override
public HoverInfo getHoverInfo() {
public Renderable getHoverInfo() {
if (parent!=null) {
return parent.getHoverInfo(contextPath.getLastSegment());
}
@@ -231,7 +231,7 @@ public class YTypeAssistContext extends AbstractYamlAssistContext {
}
@Override
public HoverInfo getHoverInfo(YamlPathSegment lastSegment) {
public Renderable getHoverInfo(YamlPathSegment lastSegment) {
//Hoverinfo is only attached to YTypedProperties so...
switch (lastSegment.getType()) {
case VAL_AT_KEY:
@@ -247,7 +247,7 @@ public class YTypeAssistContext extends AbstractYamlAssistContext {
}
@Override
public HoverInfo getValueHoverInfo(YamlDocument doc, DocumentRegion documentRegion) {
public Renderable getValueHoverInfo(YamlDocument doc, DocumentRegion documentRegion) {
//By default we don't provide value-specific hover, so just show the same hover
// as the assistContext the value is in. This is likely more interesting than showing nothing at all.
return getHoverInfo();

View File

@@ -13,8 +13,8 @@ package org.springframework.ide.vscode.commons.yaml.completion;
import java.util.Collection;
import org.springframework.ide.vscode.commons.languageserver.completion.ICompletionProposal;
import org.springframework.ide.vscode.commons.languageserver.hover.HoverInfo;
import org.springframework.ide.vscode.commons.languageserver.util.DocumentRegion;
import org.springframework.ide.vscode.commons.util.Renderable;
import org.springframework.ide.vscode.commons.yaml.path.YamlNavigable;
import org.springframework.ide.vscode.commons.yaml.path.YamlPathSegment;
import org.springframework.ide.vscode.commons.yaml.structure.YamlDocument;
@@ -28,8 +28,8 @@ public interface YamlAssistContext extends YamlNavigable<YamlAssistContext> {
//TODO: conceptually... the right thing would be to only implement the second of these
// two methods and get rid of the first one.
HoverInfo getHoverInfo();
HoverInfo getHoverInfo(YamlPathSegment lastSegment);
Renderable getHoverInfo();
Renderable getHoverInfo(YamlPathSegment lastSegment);
HoverInfo getValueHoverInfo(YamlDocument doc, DocumentRegion documentRegion);
Renderable getValueHoverInfo(YamlDocument doc, DocumentRegion documentRegion);
}

View File

@@ -10,13 +10,13 @@
*******************************************************************************/
package org.springframework.ide.vscode.commons.yaml.hover;
import static org.springframework.ide.vscode.commons.yaml.util.DescriptionProviders.bold;
import static org.springframework.ide.vscode.commons.yaml.util.DescriptionProviders.concat;
import static org.springframework.ide.vscode.commons.yaml.util.DescriptionProviders.lineBreak;
import static org.springframework.ide.vscode.commons.yaml.util.DescriptionProviders.link;
import static org.springframework.ide.vscode.commons.yaml.util.DescriptionProviders.text;
import static org.springframework.ide.vscode.commons.util.Renderables.bold;
import static org.springframework.ide.vscode.commons.util.Renderables.concat;
import static org.springframework.ide.vscode.commons.util.Renderables.lineBreak;
import static org.springframework.ide.vscode.commons.util.Renderables.link;
import static org.springframework.ide.vscode.commons.util.Renderables.text;
import org.springframework.ide.vscode.commons.languageserver.hover.HoverInfo;
import org.springframework.ide.vscode.commons.util.Renderable;
import org.springframework.ide.vscode.commons.util.StringUtil;
import org.springframework.ide.vscode.commons.yaml.schema.YType;
import org.springframework.ide.vscode.commons.yaml.schema.YTypedProperty;
@@ -31,9 +31,9 @@ import com.google.common.collect.ImmutableList.Builder;
*/
public class YPropertyHoverInfo {
public static HoverInfo create(String contextProperty, YType contextType, YTypedProperty prop) {
public static Renderable create(String contextProperty, YType contextType, YTypedProperty prop) {
Builder<HoverInfo> html = ImmutableList.builder();
Builder<Renderable> html = ImmutableList.builder();
if (StringUtil.hasText(contextProperty)) {
html.add(text(contextProperty));
html.add(text("."));
@@ -48,7 +48,7 @@ public class YPropertyHoverInfo {
html.add(link(type.toString(), /* no URL */ null));
}
HoverInfo description = prop.getDescription();
Renderable description = prop.getDescription();
if (description != null) {
html.add(lineBreak());
html.add(description);

View File

@@ -12,13 +12,13 @@ package org.springframework.ide.vscode.commons.yaml.hover;
import java.util.List;
import org.springframework.ide.vscode.commons.languageserver.hover.HoverInfo;
import org.springframework.ide.vscode.commons.languageserver.hover.HoverInfoProvider;
import org.springframework.ide.vscode.commons.languageserver.util.DocumentRegion;
import org.springframework.ide.vscode.commons.languageserver.util.IDocument;
import org.springframework.ide.vscode.commons.languageserver.util.IRegion;
import org.springframework.ide.vscode.commons.languageserver.util.Region;
import org.springframework.ide.vscode.commons.util.Assert;
import org.springframework.ide.vscode.commons.util.Renderable;
import org.springframework.ide.vscode.commons.yaml.ast.NodeRef;
import org.springframework.ide.vscode.commons.yaml.ast.YamlASTProvider;
import org.springframework.ide.vscode.commons.yaml.ast.YamlFileAST;
@@ -59,7 +59,7 @@ public class YamlHoverInfoProvider implements HoverInfoProvider {
}
@Override
public Tuple2<HoverInfo, IRegion> getHoverInfo(IDocument doc, int offset) throws Exception {
public Tuple2<Renderable, IRegion> getHoverInfo(IDocument doc, int offset) throws Exception {
YamlFileAST ast = getAst(doc);
if (ast != null) {
IRegion region = getHoverRegion(ast, offset);
@@ -82,10 +82,10 @@ public class YamlHoverInfoProvider implements HoverInfoProvider {
assistContext = assistPath.traverse(assistContext);
if (assistContext != null) {
if (path.pointsAtValue()) {
HoverInfo info = assistContext.getValueHoverInfo(ymlDoc, new DocumentRegion(doc, region));
Renderable info = assistContext.getValueHoverInfo(ymlDoc, new DocumentRegion(doc, region));
return Tuples.of(info, region);
}
HoverInfo info = assistContext.getHoverInfo();
Renderable info = assistContext.getHoverInfo();
return Tuples.of(info, region);
}
}

View File

@@ -21,10 +21,10 @@ import java.util.Set;
import javax.inject.Provider;
import org.springframework.ide.vscode.commons.languageserver.hover.HoverInfo;
import org.springframework.ide.vscode.commons.util.EnumValueParser;
import org.springframework.ide.vscode.commons.util.Renderable;
import org.springframework.ide.vscode.commons.util.Renderables;
import org.springframework.ide.vscode.commons.util.ValueParser;
import org.springframework.ide.vscode.commons.yaml.util.DescriptionProviders;
/**
* Static utility method for creating YType objects representing either
@@ -193,7 +193,7 @@ public class YTypeFactory {
propertyList.add(p);
}
public void addProperty(String name, YType type, HoverInfo description) {
public void addProperty(String name, YType type, Renderable description) {
YTypedPropertyImpl prop;
addProperty(prop = new YTypedPropertyImpl(name, type));
prop.setDescriptionProvider(description);
@@ -314,7 +314,7 @@ public class YTypeFactory {
final private String name;
final private YType type;
private HoverInfo description = DescriptionProviders.NO_DESCRIPTION;
private Renderable description = Renderables.NO_DESCRIPTION;
private YTypedPropertyImpl(String name, YType type) {
this.name = name;
@@ -337,11 +337,11 @@ public class YTypeFactory {
}
@Override
public HoverInfo getDescription() {
public Renderable getDescription() {
return description;
}
public void setDescriptionProvider(HoverInfo description) {
public void setDescriptionProvider(Renderable description) {
this.description = description;
}
}

View File

@@ -10,7 +10,7 @@
*******************************************************************************/
package org.springframework.ide.vscode.commons.yaml.schema;
import org.springframework.ide.vscode.commons.languageserver.hover.HoverInfo;
import org.springframework.ide.vscode.commons.util.Renderable;
/**
* @author Kris De Volder
@@ -18,5 +18,5 @@ import org.springframework.ide.vscode.commons.languageserver.hover.HoverInfo;
public interface YTypedProperty {
String getName();
YType getType();
HoverInfo getDescription();
Renderable getDescription();
}

View File

@@ -38,11 +38,11 @@ import org.springframework.ide.vscode.commons.languageserver.completion.IComplet
import org.springframework.ide.vscode.commons.languageserver.completion.LazyProposalApplier;
import org.springframework.ide.vscode.commons.languageserver.completion.ProposalApplier;
import org.springframework.ide.vscode.commons.languageserver.completion.ScoreableProposal;
import org.springframework.ide.vscode.commons.languageserver.hover.HoverInfo;
import org.springframework.ide.vscode.commons.languageserver.util.DocumentRegion;
import org.springframework.ide.vscode.commons.util.CollectionUtil;
import org.springframework.ide.vscode.commons.util.FuzzyMatcher;
import org.springframework.ide.vscode.commons.util.Log;
import org.springframework.ide.vscode.commons.util.Renderable;
import org.springframework.ide.vscode.commons.util.StringUtil;
import org.springframework.ide.vscode.commons.yaml.completion.AbstractYamlAssistContext;
import org.springframework.ide.vscode.commons.yaml.completion.TopLevelAssistContext;
@@ -376,19 +376,19 @@ public abstract class ApplicationYamlAssistContext extends AbstractYamlAssistCon
@Override
public HoverInfo getHoverInfo(YamlPathSegment lastSegment) {
public Renderable getHoverInfo(YamlPathSegment lastSegment) {
// TODO Auto-generated method stub
return null;
}
@Override
public HoverInfo getValueHoverInfo(YamlDocument doc, DocumentRegion documentRegion) {
public Renderable getValueHoverInfo(YamlDocument doc, DocumentRegion documentRegion) {
// TODO Auto-generated method stub
return null;
}
@Override
public HoverInfo getHoverInfo() {
public Renderable getHoverInfo() {
// TODO Auto-generated method stub
return null;
}
@@ -504,19 +504,19 @@ public abstract class ApplicationYamlAssistContext extends AbstractYamlAssistCon
}
@Override
public HoverInfo getHoverInfo() {
public Renderable getHoverInfo() {
// TODO Auto-generated method stub
return null;
}
@Override
public HoverInfo getHoverInfo(YamlPathSegment lastSegment) {
public Renderable getHoverInfo(YamlPathSegment lastSegment) {
// TODO Auto-generated method stub
return null;
}
@Override
public HoverInfo getValueHoverInfo(YamlDocument doc, DocumentRegion documentRegion) {
public Renderable getValueHoverInfo(YamlDocument doc, DocumentRegion documentRegion) {
// TODO Auto-generated method stub
return null;
}

View File

@@ -15,7 +15,8 @@ import java.util.Set;
import javax.inject.Provider;
import org.springframework.ide.vscode.commons.languageserver.hover.HoverInfo;
import org.springframework.ide.vscode.commons.util.Renderable;
import org.springframework.ide.vscode.commons.util.Renderables;
import org.springframework.ide.vscode.commons.yaml.schema.YType;
import org.springframework.ide.vscode.commons.yaml.schema.YTypeFactory;
import org.springframework.ide.vscode.commons.yaml.schema.YTypeFactory.YAtomicType;
@@ -24,7 +25,6 @@ import org.springframework.ide.vscode.commons.yaml.schema.YTypeFactory.YTypedPro
import org.springframework.ide.vscode.commons.yaml.schema.YTypeUtil;
import org.springframework.ide.vscode.commons.yaml.schema.YValueHint;
import org.springframework.ide.vscode.commons.yaml.schema.YamlSchema;
import org.springframework.ide.vscode.commons.yaml.util.DescriptionProviders;
import com.google.common.collect.ImmutableSet;
@@ -106,11 +106,11 @@ public class ManifestYmlSchema implements YamlSchema {
}
}
private HoverInfo descriptionFor(String propName) {
return DescriptionProviders.fromClasspath(this.getClass(), "/description-by-prop-name/"+propName);
private Renderable descriptionFor(String propName) {
return Renderables.fromClasspath(this.getClass(), "/description-by-prop-name/"+propName);
}
private HoverInfo descriptionFor(YTypedPropertyImpl prop) {
private Renderable descriptionFor(YTypedPropertyImpl prop) {
return descriptionFor(prop.getName());
}

View File

@@ -19,11 +19,11 @@ import java.util.List;
import java.util.Map;
import org.junit.Test;
import org.springframework.ide.vscode.commons.util.Renderables;
import org.springframework.ide.vscode.commons.util.StringUtil;
import org.springframework.ide.vscode.commons.yaml.schema.YTypedProperty;
import org.springframework.ide.vscode.commons.yaml.schema.YTypeFactory.YBeanType;
import org.springframework.ide.vscode.commons.yaml.schema.YTypeFactory.YSeqType;
import org.springframework.ide.vscode.commons.yaml.util.DescriptionProviders;
import org.springframework.ide.vscode.manifest.yaml.ManifestYmlSchema;
import com.google.common.collect.ImmutableSet;
@@ -113,14 +113,14 @@ public class ManifestYmlSchemaTest {
private void assertHasRealDescription(YTypedProperty p) {
{
String noDescriptionText = DescriptionProviders.NO_DESCRIPTION.toHtml();
String noDescriptionText = Renderables.NO_DESCRIPTION.toHtml();
String actual = p.getDescription().toHtml();
String msg = "Description missing for '"+p.getName()+"'";
assertTrue(msg, StringUtil.hasText(actual));
assertFalse(msg, noDescriptionText.equals(actual));
}
{
String noDescriptionText = DescriptionProviders.NO_DESCRIPTION.toMarkdown();
String noDescriptionText = Renderables.NO_DESCRIPTION.toMarkdown();
String actual = p.getDescription().toMarkdown();
String msg = "Description missing for '"+p.getName()+"'";
assertTrue(msg, StringUtil.hasText(actual));