PsiElement (@NotNull String text, @NotNull IElementType type, @Nullable PsiElement context) { DummyHolder result = DummyHolderFactory.createHolder(myManager, context); FileElement holder = result.getTreeElement(); Language language = type.getLanguage(); ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(language); assert parserDefinition != null : "No parser definition for language " + language; Project project = myManager.getProject(); Lexer lexer = parserDefinition.createLexer(project); PsiBuilder builder = PsiBuilderFactory.getInstance().createBuilder(project, holder, lexer, language, text); ASTNode node = parserDefinition.createParser(project).parse(type, builder); holder.rawAddChildren((TreeElement)node); PsiElement psi = node.getPsi(); assert psi != null : text; return psi; }