void (String dir, Project project) { VirtualFile config = LocalFileSystem.getInstance().findFileByPath((dir.endsWith("/")?dir:dir+"/")+"conf.py"); if (config == null) return; PsiFile configFile = PsiManager.getInstance(project).findFile(config); if (configFile instanceof PyFile file) { List<PyFunction> functions = file.getTopLevelFunctions(); for (PyFunction function : functions) { if (!"setup".equals(function.getName())) continue; PyStatementList stList = function.getStatementList(); PyStatement[] statements = stList.getStatements(); for (PyElement statement : statements) { if (statement instanceof PyExpressionStatement) statement = ((PyExpressionStatement)statement).getExpression(); if (statement instanceof PyCallExpression) { if (((PyCallExpression)statement).isCalleeText("add_role")) { PyExpression arg = ((PyCallExpression)statement).getArguments()[0]; if (arg instanceof PyStringLiteralExpression) mySphinxRoles.add(((PyStringLiteralExpression)arg).getStringValue()); } } } } } }