ASTNode (@NotNull ASTNode node) { final LanguageLevel languageLevel = getLanguageLevel(node.getPsi()); PythonRuntimeService instance = PythonRuntimeService.getInstance(); if (instance != null) { PythonConsoleData consoleData = instance.getPythonConsoleData(node); if (consoleData != null) { return parseConsoleCode(node, consoleData); } } final PsiElement psi = node.getPsi(); if (psi != null) { final Project project = psi.getProject(); final PsiBuilderFactory factory = PsiBuilderFactory.getInstance(); final Language language = getLanguage(); final ParserDefinition parserDefinition = LanguageParserDefinitions.INSTANCE.forLanguage(language); if (parserDefinition == null) { return null; } final Lexer lexer = parserDefinition.createLexer(project); final PsiParser parser = parserDefinition.createParser(project); final PsiBuilder builder = factory.createBuilder(project, node, lexer, language, node.getChars()); if (parser instanceof PyParser) { final PythonParser pythonParser = (PythonParser)parser; pythonParser.setLanguageLevel(languageLevel); } return parser.parse(this, builder).getFirstChildNode(); } return null; }