use of com.perl5.lang.tt2.psi.TemplateToolkitString in project Perl5-IDEA by Camelcade.
the class TemplateToolkitBlocksCompletionProvider method addCompletions.
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull final CompletionResultSet result) {
PsiElement element = parameters.getOriginalPosition();
if (element == null) {
return;
}
PsiElement stringElement = element.getParent();
if (!(stringElement instanceof TemplateToolkitString)) {
return;
}
PsiElement container = stringElement.getParent();
if (!TemplateToolkitStringMixin.BLOCK_NAME_TARGETED_CONTAINERS.contains(PsiUtilCore.getElementType(container))) {
return;
}
PsiTreeUtil.processElements(element.getContainingFile(), element1 -> {
if (element1 instanceof TemplateToolkitNamedBlock) {
String blockName = ((TemplateToolkitNamedBlock) element1).getName();
if (StringUtil.isNotEmpty(blockName)) {
result.addElement(LookupElementBuilder.create(blockName).withTypeText("BLOCK", true).withIcon(element1.getIcon(0)));
}
}
return true;
});
}
Aggregations