Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@sysint64
Created November 18, 2017 07:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sysint64/43f8b51708e058fc2d626a498518c30b to your computer and use it in GitHub Desktop.
Save sysint64/43f8b51708e058fc2d626a498518c30b to your computer and use it in GitHub Desktop.
public String getPlaceholderText(@NotNull final ASTNode node) {
...
if (psi instanceof DLanguageBlockStatement) {
final DLanguageBlockStatement block = (DLanguageBlockStatement) psi;
final PsiElement inner = getInnerStatementBlockForDisplayInPlaceholder(block);
if (inner != null) {
return "{ " + inner.getText().trim() + " }";
} else {
return "{...}";
}
}
...
}
private PsiElement getInnerStatementBlockForDisplayInPlaceholder(final DLanguageBlockStatement blockStatement) {
if (blockStatement.getChildren().length == 0)
return null;
final PsiElement inner = blockStatement.getChildren()[0];
final String innerText = inner.getText();
if (innerText.contains("\n") || innerText.contains("\r") ||
inner.getTextLength() > MAX_BODY_LENGTH_TO_DISPLAY)
{
return null;
}
return inner;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment