ASTNode (@NotNull ASTNode chameleon, @NotNull PsiElement outerPsi) { PsiElement psi = chameleon.getPsi(); Project project = psi.getProject(); Language languageForParser = getLanguageForParser(psi); RegExpParserDefinition definition = (RegExpParserDefinition)LanguageParserDefinitions.INSTANCE.forLanguage(languageForParser); EnumSet<RegExpCapability> capabilities = setupCapabilities(psi, EnumSet.copyOf(definition.getDefaultCapabilities())); RegExpLexer lexer = definition.createLexer(project, capabilities); PsiParser parser = definition.createParser(project, capabilities); PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(project, chameleon, lexer, languageForParser, chameleon.getChars()); ((LightPsiParser)parser).parseLight(this, builder); return builder.getTreeBuilt().getFirstChildNode(); }