PsiElement[] (PsiElement[] codeBlockChildren) { int resultLast = codeBlockChildren.length; if (codeBlockChildren.length == 0) return PsiElement.EMPTY_ARRAY; final PsiElement first = codeBlockChildren[0]; int resultStart = 0; if (PsiUtil.isJavaToken(first, JavaTokenType.LBRACE)) { resultStart++; } final PsiElement last = codeBlockChildren[codeBlockChildren.length - 1]; if (PsiUtil.isJavaToken(last, JavaTokenType.RBRACE)) { resultLast--; } final ArrayList<PsiElement> result = new ArrayList<>(); for (int i = resultStart; i < resultLast; i++) { PsiElement element = codeBlockChildren[i]; if (!(element instanceof PsiWhiteSpace)) { result.add(element); } } return PsiUtilCore.toPsiElementArray(result); }