PsiBuilder (final PsiBuilder builder) { final PsiBuilder.Marker pos = builder.mark(); int braceCount = 1; while (!builder.eof()) { final IElementType tokenType = builder.getTokenType(); if (tokenType == JavaTokenType.LBRACE) { braceCount++; } else if (tokenType == JavaTokenType.RBRACE) braceCount--; if (braceCount == 0) break; builder.advanceLexer(); } final int stopAt = builder.getCurrentOffset(); pos.rollbackTo(); return stoppingBuilder(builder, stopAt); }