use of com.redhat.qute.parser.template.Template in project quarkus-ls by redhat-developer.
the class QuteProject method findInsertTagParameter.
public List<QuteIndex> findInsertTagParameter(String templateId, String insertParamater) {
TemplateProvider provider = openedDocuments.get(templateId);
if (provider != null) {
Template template = provider.getTemplate().getNow(null);
if (template != null) {
List<QuteIndex> indexes = new ArrayList<>();
collectInsert(insertParamater, template, template, indexes);
return indexes;
}
return Collections.emptyList();
}
indexer.scanAsync();
return indexer.find(templateId, "insert", insertParamater);
}
use of com.redhat.qute.parser.template.Template 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;
}
use of com.redhat.qute.parser.template.Template in project quarkus-ls by redhat-developer.
the class QuteCompletionForTagSection method doCompleteTagSection.
public void doCompleteTagSection(CompletionRequest completionRequest, String filterPrefix, QuteCompletionSettings completionSettings, QuteFormattingSettings formattingSettings, CancelChecker cancelChecker, CompletionList list) {
// Completion for user tags
Template template = completionRequest.getTemplate();
QuteProject project = template.getProject();
if (project != null) {
project.collectUserTagSuggestions(completionRequest, filterPrefix, "}", list);
}
// Completion for #for, #if, etc
completionsForSnippets.collectSnippetSuggestions(completionRequest, filterPrefix, "}", list);
}
use of com.redhat.qute.parser.template.Template in project quarkus-ls by redhat-developer.
the class QuteCompletionsForExpression method doCompleteExpressionForObjectPartWithParameterAlias.
private void doCompleteExpressionForObjectPartWithParameterAlias(Template template, Range range, CompletionList list) {
List<String> aliases = //
template.getChildren().stream().filter(//
n -> n.getKind() == NodeKind.ParameterDeclaration).map(//
n -> ((ParameterDeclaration) n).getAlias()).filter(//
alias -> alias != null).collect(Collectors.toList());
for (String alias : aliases) {
CompletionItem item = new CompletionItem();
item.setLabel(alias);
item.setKind(CompletionItemKind.Reference);
TextEdit textEdit = new TextEdit(range, alias);
item.setTextEdit(Either.forLeft(textEdit));
list.getItems().add(item);
}
}
use of com.redhat.qute.parser.template.Template in project quarkus-ls by redhat-developer.
the class QutePositionUtility method selectAlias.
public static Range selectAlias(ParameterDeclaration parameter) {
Template template = parameter.getOwnerTemplate();
int startOffset = parameter.getAliasStart();
int endOffset = parameter.getAliasEnd();
return createRange(startOffset, endOffset, template);
}
Aggregations