void () { PsiElementPattern.Capture<PsiElement> startOfLine = psiElement() .withLanguage(PythonLanguage.getInstance()) .and(FIRST_ON_LINE) .andNot(IN_IMPORT_STMT) .andNot(IN_PARAM_LIST) .andNot(IN_ARG_LIST) .andNot(BEFORE_COND) .andNot(AFTER_QUALIFIER) .andNot(IN_STRING_LITERAL); extend( CompletionType.BASIC, startOfLine, new CompletionProvider<>() { @Override protected void addCompletions( @NotNull final CompletionParameters parameters, @NotNull final ProcessingContext context, @NotNull final CompletionResultSet result ) { putKeywords(result, TailTypes.noneType(), PyNames.DEF, PyNames.CLASS, PyNames.FOR, PyNames.IF, PyNames.WHILE, PyNames.WITH); putKeywords(result, TailTypes.caseColonType(), PyNames.TRY); } } ); extend( CompletionType.BASIC, startOfLine.and(PY310), new CompletionProvider<>() { @Override protected void addCompletions( @NotNull final CompletionParameters parameters, @NotNull final ProcessingContext context, @NotNull final CompletionResultSet result ) { putKeywords(result, TailTypes.noneType(), PyNames.MATCH); } } ); }