in code_samples/simple_language_plugin/src/main/java/org/intellij/sdk/language/SimpleFoldingBuilder.java [41:61]
public void visitLiteralExpression(@NotNull PsiLiteralExpression literalExpression) {
super.visitLiteralExpression(literalExpression);
String value = PsiLiteralUtil.getStringLiteralContent(literalExpression);
if (value != null &&
value.startsWith(SimpleAnnotator.SIMPLE_PREFIX_STR + SimpleAnnotator.SIMPLE_SEPARATOR_STR)) {
Project project = literalExpression.getProject();
String key = value.substring(
SimpleAnnotator.SIMPLE_PREFIX_STR.length() + SimpleAnnotator.SIMPLE_SEPARATOR_STR.length()
);
// find SimpleProperty for the given key in the project
SimpleProperty simpleProperty = ContainerUtil.getOnlyItem(SimpleUtil.findProperties(project, key));
if (simpleProperty != null) {
// Add a folding descriptor for the literal expression at this node.
descriptors.add(new FoldingDescriptor(literalExpression.getNode(),
new TextRange(literalExpression.getTextRange().getStartOffset() + 1,
literalExpression.getTextRange().getEndOffset() - 1),
group, Collections.singleton(simpleProperty)));
}
}
}