GrCaseSection (@NotNull String text) { final GrStatement statement = createStatementFromText("switch (a) {\n" + text + "\n}"); if (!(statement instanceof GrSwitchElement)) { throw new IncorrectOperationException("Cannot create switch section from text: " + text); } final GrCaseSection[] sections = ((GrSwitchElement)statement).getCaseSections(); if (sections.length != 1) throw new IncorrectOperationException("Cannot create switch section from text: " + text); return sections[0]; }