void () { extend( CompletionType.BASIC, psiElement() .withLanguage(PythonLanguage.getInstance()) .and(FIRST_ON_LINE) .andOr(IN_TRY_BODY, IN_EXCEPT_BODY, AFTER_TRY, IN_ELSE_BODY_OF_TRY) //.andNot(RIGHT_AFTER_COLON) .andNot(AFTER_QUALIFIER).andNot(IN_STRING_LITERAL) .andNot(AFTER_FINALLY) , new CompletionProvider<>() { @Override protected void addCompletions( @NotNull final CompletionParameters parameters, @NotNull final ProcessingContext context, @NotNull final CompletionResultSet result ) { putKeyword(PyNames.FINALLY, PyUnindentingInsertHandler.INSTANCE, TailTypes.caseColonType(), result); } } ); extend( CompletionType.BASIC, psiElement() .withLanguage(PythonLanguage.getInstance()) .and(FIRST_ON_LINE) .andOr(IN_TRY_BODY, IN_EXCEPT_BODY, AFTER_TRY, IN_ELSE_BODY_OF_TRY) //.andNot(RIGHT_AFTER_COLON) .andNot(AFTER_QUALIFIER).andNot(IN_STRING_LITERAL) .andNot(AFTER_FINALLY).andNot(AFTER_ELSE) , new CompletionProvider<>() { @Override protected void addCompletions( @NotNull final CompletionParameters parameters, @NotNull final ProcessingContext context, @NotNull final CompletionResultSet result ) { putKeyword(PyNames.EXCEPT, PyUnindentingInsertHandler.INSTANCE, TailTypes.noneType(), result); } } ); }