PsiBuilder (@NotNull LighterLazyParseableNode chameleon, @NotNull Function<PsiElement, LanguageLevel> languageLevelFunction, @NotNull Function<LanguageLevel, BasicJavaLexer> lexerFunction) { final PsiElement psi = chameleon.getContainingFile(); assert psi != null : chameleon; final Project project = psi.getProject(); final PsiBuilderFactory factory = PsiBuilderFactory.getInstance(); final LanguageLevel level = languageLevelFunction.apply(psi); final Lexer lexer = lexerFunction.apply(level); final PsiBuilder builder = factory.createBuilder(project, chameleon, lexer, chameleon.getTokenType().getLanguage(), chameleon.getText()); setLanguageLevel(builder, level); return builder; }