void (List<? super FoldingDescriptor> descriptors, ASTNode node) { if (!isMultiLineStringLiteral(node)) return; if (!node.getElementType().equals(GroovyElementTypes.GSTRING) && !node.getElementType().equals(GroovyElementTypes.REGEX)) { descriptors.add(new FoldingDescriptor(node, node.getTextRange(), null, multiLineStringLiteralPlaceholder(node), false, Collections.emptySet())); return; } final GrString grString = (GrString)node.getPsi(); if (grString == null) return; final GrStringInjection[] injections = grString.getInjections(); if (injections.length == 0) { descriptors.add(new FoldingDescriptor(node, node.getTextRange(), null, multiLineStringLiteralPlaceholder(node), false, Collections.emptySet())); return; } final FoldingGroup group = FoldingGroup.newGroup("GString"); final TextRange nodeRange = node.getTextRange(); int startOffset = nodeRange.getStartOffset(); GrStringInjection injection = injections[0]; TextRange injectionRange = injection.getTextRange(); if (startOffset + 1 < injectionRange.getStartOffset()) { final String start_quote = GrStringUtil.getStartQuote(node.getText()); descriptors.add(new FoldingDescriptor(node, new TextRange(startOffset, injectionRange.getStartOffset()), group, start_quote, false, Collections.emptySet())); } startOffset = injectionRange.getEndOffset(); for (int i = 1; i < injections.length; i++) { injection = injections[i]; injectionRange = injection.getTextRange(); final int endOffset = injectionRange.getStartOffset(); if (endOffset - startOffset >= 2) { descriptors.add(new FoldingDescriptor(injection.getNode().getTreePrev(), new TextRange(startOffset, endOffset), group, " ", false, Collections.emptySet())); } startOffset = injectionRange.getEndOffset(); } if (startOffset + 1 < nodeRange.getEndOffset()) { final String end_quote = GrStringUtil.getEndQuote(node.getText()); descriptors.add(new FoldingDescriptor(node.getLastChildNode(), new TextRange(startOffset, nodeRange.getEndOffset()), group, end_quote, false, Collections.emptySet())); } }