Search in sources :

Example 1 with SourceLinks

use of org.springframework.ide.vscode.boot.java.links.SourceLinks in project sts4 by spring-projects.

the class LiveHoverUtils method showBeanWithResource.

public static String showBeanWithResource(BootJavaLanguageServerComponents server, LiveBean bean, String indentStr, IJavaProject project) {
    // Note: the double space before newline makes markdown see it as a real line break
    String newline = "  \n" + indentStr;
    String type = bean.getType(true);
    StringBuilder buf = new StringBuilder("Bean: ");
    buf.append(bean.getId());
    SourceLinks sourceLinks = SourceLinkFactory.createSourceLinks(server);
    if (type != null) {
        // Try creating a URL link to open source for the type
        buf.append(newline);
        buf.append("Type: ");
        Optional<String> url = sourceLinks.sourceLinkUrlForFQName(project, type);
        if (url.isPresent()) {
            buf.append(Renderables.link(type, url.get()).toMarkdown());
        } else {
            buf.append("`" + type + "`");
        }
    }
    String resource = bean.getResource();
    if (StringUtil.hasText(resource)) {
        buf.append(newline);
        buf.append("Resource: ");
        buf.append(showResource(sourceLinks, resource, project));
    }
    return buf.toString();
}
Also used : SourceLinks(org.springframework.ide.vscode.boot.java.links.SourceLinks)

Aggregations

SourceLinks (org.springframework.ide.vscode.boot.java.links.SourceLinks)1