use of com.redhat.qute.ls.commons.snippets.Snippet in project quarkus-ls by redhat-developer.
the class QuteHover method doHoverForSection.
private CompletableFuture<Hover> doHoverForSection(Section section, Template template, HoverRequest hoverRequest, CancelChecker cancelChecker) {
if (section.hasTag()) {
// the section defines a tag (e : {#for
String tagName = section.getTag();
if (section.getSectionKind() == SectionKind.CUSTOM) {
// custom tag: search information about user tag
QuteProject project = template.getProject();
if (project != null) {
UserTag userTag = project.findUserTag(tagName);
if (userTag != null) {
Range range = createSectionTagRange(section, hoverRequest);
if (range != null) {
boolean hasMarkdown = hoverRequest.canSupportMarkupKind(MarkupKind.MARKDOWN);
MarkupContent content = DocumentationUtils.getDocumentation(userTag, hasMarkdown);
Hover hover = new Hover(content, range);
return CompletableFuture.completedFuture(hover);
}
}
}
} else {
// core tag like #for, #if, etc: display document hover for the section
Optional<Snippet> snippetSection = //
snippetRegistryProvider.getSnippetRegistry().getSnippets().stream().filter(//
snippet -> tagName.equals(snippet.getLabel())).findFirst();
if (snippetSection.isPresent()) {
Snippet snippet = snippetSection.get();
Range range = createSectionTagRange(section, hoverRequest);
if (range != null) {
boolean hasMarkdown = hoverRequest.canSupportMarkupKind(MarkupKind.MARKDOWN);
MarkupContent content = DocumentationUtils.getDocumentation(snippet, hasMarkdown);
Hover hover = new Hover(content, range);
return CompletableFuture.completedFuture(hover);
}
}
}
}
return NO_HOVER;
}
Aggregations