boolean (@NotNull PsiReference reference, @NotNull IProperty property, @NotNull List<? super FoldingDescriptor> result) { int before = result.size(); PsiElement referenceElement = reference.getElement(); // all arguments[i+1..] are considered template arguments String key = property.getUnescapedKey(); if (key == null) return false; PsiElement psiElement = property.getPsiElement(); String text = psiElement.getText(); PsiElement[] arguments = referenceElement.getLanguage().getID().equals("kotlin") ? getKotlinArguments(referenceElement) : getJavaArguments(referenceElement); if (arguments == null) return false; for (int i=0; i<arguments.length; i++) { PsiElement argument = arguments[i]; String templateText = "{" + i + "}"; int offset = text.indexOf(templateText, key.length()); if (offset != -1) { int start = psiElement.getTextRange().getStartOffset(); result.add(new FoldingDescriptor(psiElement, start+ offset, start+offset+templateText.length(), null, (argument.getText()))); } } return result.size() != before; }