Don't suggest live template inside string literals (PY-12349)

The previous fix was unsuccessful since we ignored only string literal
elements but not their subparts.
This commit is contained in:
Andrey Vlasovskikh
2014-12-25 15:37:55 +03:00
parent 3c22af77c7
commit 7b5dfcfd61
@@ -43,13 +43,16 @@ public class PythonTemplateContextType extends FileTypeBasedContextType {
if (super.isInContext(file, offset)) {
final PsiElement element = file.findElementAt(offset);
if (element != null) {
return !(isAfterDot(element) || element instanceof PsiComment || element instanceof PyStringLiteralExpression ||
isInsideParameterList(element));
return !(isAfterDot(element) || element instanceof PsiComment || isInsideStringLiteral(element) || isInsideParameterList(element));
}
}
return false;
}
private static boolean isInsideStringLiteral(@NotNull PsiElement element) {
return PsiTreeUtil.getParentOfType(element, PyStringLiteralExpression.class, false) != null;
}
private static boolean isInsideParameterList(@NotNull PsiElement element) {
return PsiTreeUtil.getParentOfType(element, PyParameterList.class) != null;
}