@Nullable
  public static ASTNode parseFragment(final ASTNode chameleon,
                                      final BasicJavaParserUtil.ParserWrapper wrapper,
                                      final boolean eatAll,
                                      final LanguageLevel level,
                                      Function<LanguageLevel, JavaDocLexer> javaDocLexer,
                                      Function<LanguageLevel, BasicJavaLexer> javaLexer) {
    final PsiElement psi = chameleon.getTreeParent() != null ? chameleon.getTreeParent().getPsi() : chameleon.getPsi();
    assert psi != null : chameleon;
    final Project project = psi.getProject();

    final PsiBuilderFactory factory = PsiBuilderFactory.getInstance();
    final Lexer lexer = BasicJavaAstTreeUtil.is(chameleon, BASIC_DOC_COMMENT) ? javaDocLexer.apply(level) : javaLexer.apply(level);
    final PsiBuilder builder =
      factory.createBuilder(project, chameleon, lexer, chameleon.getElementType().getLanguage(), chameleon.getChars());
    setLanguageLevel(builder, level);

    long startTime = System.nanoTime();
    final PsiBuilder.Marker root = builder.mark();
    wrapper.parse(builder);
    if (!builder.eof()) {
      if (!eatAll) throw new AssertionError("Unexpected token: '" + builder.getTokenText() + "'");
      final PsiBuilder.Marker extras = builder.mark();
      while (!builder.eof()) builder.advanceLexer();
      extras.error(JavaPsiBundle.message("unexpected.tokens"));
    }
    root.done(chameleon.getElementType());
    ASTNode result = builder.getTreeBuilt().getFirstChildNode();
    ParsingDiagnostics.registerParse(builder, chameleon.getElementType().getLanguage(), System.nanoTime() - startTime);
    return result;
  }
@Nullable
  public static ASTNode parseFragment(final ASTNode chameleon,
                                      final BasicJavaParserUtil.ParserWrapper wrapper,
                                      final boolean eatAll,
                                      final LanguageLevel level,
                                      Function<LanguageLevel, JavaDocLexer> javaDocLexer,
                                      Function<LanguageLevel, BasicJavaLexer> javaLexer)