void (final PsiBuilder builder, final boolean isAnnotation) { final BaseContext context = isAnnotation ? BaseContext.ANNOTATION_INTERFACE : BaseContext.CLASS; PsiBuilder.Marker invalidElements = null; while (true) { final IElementType tokenType = builder.getTokenType(); if (tokenType == null || tokenType == JavaTokenType.RBRACE) break; if (tokenType == JavaTokenType.SEMICOLON) { if (invalidElements != null) { invalidElements.error(JavaPsiBundle.message("unexpected.token")); invalidElements = null; } builder.advanceLexer(); continue; } final PsiBuilder.Marker declaration = parse(builder, context); if (declaration != null) { if (invalidElements != null) { invalidElements.errorBefore(JavaPsiBundle.message("unexpected.token"), declaration); invalidElements = null; } continue; } if (invalidElements == null) { invalidElements = builder.mark(); } // adding a reference, not simple tokens allows "Browse ..." to work well final PsiBuilder.Marker ref = myParser.getReferenceParser().parseJavaCodeReference(builder, true, true, false, false); if (ref == null) { builder.advanceLexer(); } } if (invalidElements != null) { invalidElements.error(JavaPsiBundle.message("unexpected.token")); } }