CompletionResultSet (@NotNull final PsiElement original, @NotNull final CompletionResultSet result, final int offset) { PyStringLiteralExpression prevElement = PsiTreeUtil.getPrevSiblingOfType(original, PyStringLiteralExpression.class); if (prevElement != null) { ASTNode prevNode = prevElement.getNode(); if (prevNode != null) { if (prevNode.getElementType() != PyTokenTypes.LBRACKET) { return result.withPrefixMatcher(findPrefix(prevElement, offset)); } } } final PsiElement parentElement = original.getParent(); if (parentElement != null) { if (parentElement instanceof PyStringLiteralExpression) { return result.withPrefixMatcher(findPrefix((PyElement)parentElement, offset)); } } final PyNumericLiteralExpression number = PsiTreeUtil.findElementOfClassAtOffset(original.getContainingFile(), offset - 1, PyNumericLiteralExpression.class, false); if (number != null) { return result.withPrefixMatcher(findPrefix(number, offset)); } return result; }